1.0.0 • Published 3 years ago

react-ui-gauge-component v1.0.0

Weekly downloads
29
License
MIT
Repository
github
Last release
3 years ago

Gauge Component for React

A library that provides basic gauge styles and widgets to create gauges efficiently for React projects.

screen shot

Installation and usage

The easiest way to use react-ui-gauge-component is to install it from npm.

npm i react-ui-gauge-component

Then use it in your app

import React, { Fragment } from 'react';
import withGauge, { HeartBeat, Needle } from 'react-ui-gauge-component';

const defaultTitleColor = "black";
const defaultValueColor = "black";

const Gauge1 = withGauge({
    WrappedComponent: Needle({value:data[0], min: 0, max: 100}),
    fields: [{title: "Label 1", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor}]
});

const Gauge2 = withGauge({
    WrappedComponent: HeartBeat,
    colorArray: ["#eb001e", "#000", "#3aff20", "#53a5fd", "#aaaaaa"],
    fields: [
        {title: "Label 1", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 2", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor}]
});

const Gauge3 = withGauge({
    WrappedComponent: HeartBeat,
    fields: [
        {title: "Label 1", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 2", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 3", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor}]
});

const Gauge4 = withGauge({
    WrappedComponent: HeartBeat,
    fields: [
        {title: "Label 1", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 2", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 3", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor},
        {title: "Label 4", value: "100", titleColor: defaultTitleColor, valueColor: defaultValueColor}]
});

const DashboardExample = () => {
    return (
        <Fragment>
            <Gauge1/>
            <Gauge2/>
            <Gauge3/>
            <Gauge4/>
        <Fragment/>
    )
}

export default DashboardExample;

Props

withGauge

  • WrappedComponent - Put a react component as a widget to compose a new gauge. The default widget is the heartbeat icon.
  • colorArray - Put an array of color for the gauge border.
colorArray: ["#eb001e", "#f35120", "#3aff20", "#53a5fd", "#aaaaaa"]
  • fields - Put an array of key, value pairs for the gauge's contents.
fields: [
        {title: "Gauge 1", value: "100", titleColor: "black", valueColor: "black"},
        {title: "Gauge 2", value: "100", titleColor: "black", valueColor: "black"},
        {title: "Gauge 3", value: "100", titleColor: "black", valueColor: "black"},
        {title: "Gauge 4", value: "100", titleColor: "black", valueColor: "black"}]

Needle

  • value: defult value is zero
  • min: defult value is zero
  • max: defult value is 100

License

MIT Licensed. Copyright (c) Jen-Hsuan Hsieh 2021.

About

Links

Refernces

1.0.0

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago