Giter VIP home page Giter VIP logo

react-d3-speedometer's Introduction

react-d3-speedometer

React library for showing speedometer like gauge using d3.

react-d3-speedometer

CircleCI Build Status Codecov npm npm code style: prettier

Note: v2.x is compatible with React v18. v1.x is compatible with React 17. Please use latest v0.x (v0.14.1 at the time of writing) if you are using React 16.

NPM

react-d3-speedometer

Getting Started:

Install with yarn or npm.

Yarn:

yarn add react-d3-speedometer

npm:

npm install --save react-d3-speedometer

And, use it like

// import the component
import ReactSpeedometer from "react-d3-speedometer"
// and just use it
<ReactSpeedometer />

Slim Build:

There is a Slim build available without bundling d3. This project uses d3 micro bundles. If your project also uses d3 microbundles, you can opt for slim build. Necessary d3 dependencies required for slim build to work are - d3-array, d3-color, d3-ease, d3-format, d3-interpolate, d3-scale, d3-selection, d3-shape, d3-transition.

// sample slim build usage
import ReactSpeedometer from "react-d3-speedometer/slim"
// and use it
<ReactSpeedometer />

Live Examples

Configuration Options:

prop type default comments
value Number 0 Make sure your value is between your minValue and maxValue
minValue Number 0
maxValue Number 1000
segments Number 5 Number of segments in the speedometer. Please note, segments is calculated with d3-ticks which is an approximate count that is uniformly spaced between min and max. Please refer to d3-ticks and d3-array ticks for more detailed info.
maxSegmentLabels Number value from 'segments' prop Limit the number of segment labels to displayed. This is useful for acheiving a gradient effect by giving arbitrary large number of segments and limiting the labels with this prop. See Live Example. Please note, maxSegmentLabels is calculated with d3-ticks which is an approximate count that is uniformly spaced between min and max. Please refer to d3-ticks and d3-array ticks for more detailed info.
forceRender Boolean false After initial rendering/mounting, when props change, only the value is changed and animated to maintain smooth visualization. But, if you want to force rerender the whole component like change in segments, colors, dimensions etc, you can use this option to force rerender of the whole component on props change.
width Number 300 diameter of the speedometer and the width of the svg element
height Number 300 height of the svg element. Height of the speedometer is always half the width since it is a semi-circle. For fluid width, please refere to fluidWidth config
dimensionUnit String px Default to px for width/height. Possible values - "em" , "ex" , "px" , "in" , "cm" , "mm" , "pt" , ,"pc" ... Please refer to specification for more details
fluidWidth Boolean false If true takes the width of the parent component. See Live Example for more details
needleColor String steelblue Should be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
startColor String #FF471A Should be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
endColor String #33CC33 Should be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
segmentColors Array (of colors) [] Custom segment colors can be given with this option. Should be an array of valid color codes. If this option is given startColor and endColor options will be ignored.
needleTransition String (JS) / Transition (TS) easeQuadInOut d3-easing-identifiers - easeLinear, easeQuadIn, easeQuadOut, easeQuadInOut, easeCubicIn, easeCubicOut, easeCubicInOut, easePolyIn, easePolyOut, easePolyInOut, easeSinIn, easeSinOut, easeSinInOut, easeExpIn, easeExpOut, easeExpInOut, easeCircleIn, easeCircleOut, easeCircleInOut, easeBounceIn, easeBounceOut, easeBounceInOut, easeBackIn, easeBackOut, easeBackInOut, easeElasticIn, easeElasticOut, easeElasticInOut, easeElastic. There is a helper Object/Type 'Transtion', which you can import like import { Transition } from 'react-d3-speedometer' and use it like Transition.easeElastic. This works for both JS and Typescript. For type(script) definitions, please refer here.
needleTransitionDuration Number 500 Time in milliseconds.
needleHeightRatio Float (between 0 and 1) 0.9 Control the height of the needle by giving a number/float between 0 and 1. Default height ratio is 0.9.
ringWidth Number 60 Width of the speedometer ring.
textColor String #666 Should be a valid color code - colorname, hexadecimal name or rgb value. Used for both showing the current value and the segment values
valueFormat String should be a valid format for d3-format. By default, no formatter is used. You can use a valid d3 format identifier (for eg: d to convert float to integers), to format the values. Note: This formatter affects all the values (current value, segment values) displayed in the speedometer
segmentValueFormatter Function value => value Custom segment values formatter function. This function is applied after 'valueFormat' prop if present.
currentValueText String ${value} Should be provided a string which should have ${value} placeholder which will be replaced with current value. By default, current value is shown (formatted with valueFormat). For example, if current Value is 333 if you would like to show Current Value: 333, you should provide a string Current Value: ${value}. See Live Example
currentValuePlaceholderStyle String ${value} Should be provided a placeholder string which will be replaced with current value in currentValueTextProp. For example: you can use ruby like interpolation by giving following props - <ReactSpeedometer currentValueText="Current Value: #{value}" currentValuePlaceholderStyle={"#{value}"} />. This is also helpful if you face no-template-curly-in-string eslint warnings and would like to use different placeholder for current value
customSegmentStops Array [] Array of values starting at min value, and ending at max value. This configuration is useful if you would like to split the segments at custom points or have unequal segments at preferred values. If the values does not begin and end with min and max value respectively, an error will be thrown. This configuration will override segments prop, since total number of segments will be length - 1 of customSegmentProps. For example, [0, 50, 75, 100] value will have three segments - 0-50, 50-75, 75-100. See Live Example
customSegmentLabels Array<CustomSegmentLabel> [] Takes an array of CustomSegmentLabel objects. Please note, the array length should match segments which is automatically calculated by d3-ticks. For more details, please check segment prop section. Each object has following keys for custom rendering of labels - text, fontSize, color, position: OUTSIDE/INSIDE. For position, there is a helper CustomSegmentLabelPosition Object/Type which you can import like import { CustomSegmentLabelPosition } from 'react-d3-speedometer', and use it like CustomSegmentLabelPosition.Inside / CustomSegmentLabelPosition.Outside. This works for both JS and Typescript. For type(script) definitions, please refer here.
labelFontSize String 14px Font size for segment labels/legends
valueTextFontSize String 16px Font size for current value text
valueTextFontWeight String bold Font weight for current value text. Any valid font weight identifier (500, bold etc) can be used.
paddingHorizontal Number 0 Provides right/left space for the label text. Takes a number (without explicit unit, unit will be taken from dimensionUnit config which defaults to px). Helpful when using a bigger font size for label texts.
paddingVertical Number 0 Provides top/bottom space for the current value label text below the needle. Takes a number (without explicit unit, unit will be taken from dimensionUnit config which defaults to px). Helpful when using a bigger font size for label texts.
svgAriaLabel String React d3 speedometer SVG aria-label property for Accessibility purposes

Examples

You can view Live Examples here

Default with no config - Live Example

<ReactSpeedometer />

With configurations - Live Example

<ReactSpeedometer
  maxValue={500}
  value={473}
  needleColor="red"
  startColor="green"
  segments={10}
  endColor="blue"
/>

Custom Segment Colors - Live Example

<ReactSpeedometer
  value={333}
  segments={5}
  segmentColors={[
    "#bf616a",
    "#d08770",
    "#ebcb8b",
    "#a3be8c",
    "#b48ead",
  ]}
  // startColor will be ignored
  // endColor will be ignored
/>

Custom Segment Labels - Live Example

  // 'customSegmentLabels' prop takes an array of 'CustomSegmentLabel' Object
  /*
  type CustomSegmentLabel = {
    text?: string
    position?: OUTSIDE/INSIDE
    fontSize?: string
    color?: string
  }
  */

  <ReactSpeedometer
    value={777}
    currentValueText="Happiness Level"
    customSegmentLabels={[
      {
        text: "Very Bad",
        position: "INSIDE",
        color: "#555",
      },
      {
        text: "Bad",
        position: "INSIDE",
        color: "#555",
      },
      {
        text: "Ok",
        position: "INSIDE",
        color: "#555",
        fontSize: "19px",
      },
      {
        text: "Good",
        position: "INSIDE",
        color: "#555",
      },
      {
        text: "Very Good",
        position: "INSIDE",
        color: "#555",
      },
    ]}
  />

Custom Segment Stops - Live Example

  <ReactSpeedometer
    customSegmentStops={[0, 500, 750, 900, 1000]}
    segmentColors={["firebrick", "tomato", "gold", "limegreen"]}
    value={333}
  />
  // `segments` prop will be ignored since it will be calculated from `customSegmentStops`
  // In this case there will be `4` segments (0-500, 500-750, 750-900, 900-1000)
/>

Fluid Width Example - Live Example

// Speedometer will take the width of the parent div (500)
// any width passed will be ignored
<div style={{
  width: "500px",
  height: "300px",
  background: "#EFEFEF"
}}>
  <ReactSpeedometer
    fluidWidth={true}
    minValue={100}
    maxValue={500}
    value={473}
    needleColor="steelblue"
  />
</div>

Needle Transition Example - Live Example

<ReactSpeedometer
  value={333}
  needleColor="steelblue"
  needleTransitionDuration={4000}
  needleTransition="easeElastic"
/>

Force Render component on props change - Live Example

// By default, when props change, only the value prop is updated and animated. 
// This is to maintain smooth visualization and to ignore breaking appearance changes like segments, colors etc. 
// You can override this behaviour by giving forceRender: true

// render a component initially
<ReactSpeedometer
  width={200}
  height={200}
/>
// Now, if given forceRender: true, and change the appearance all together, the component will rerender completely on props change
<ReactSpeedometer
  forceRender={true}
  segments={15}
  width={500}
  height={500}
/>

Needle Height Configuration Example - Live Example

<ReactSpeedometer
  value={333}
  needleHeightRatio={0.7}
/>

You can give a value between 0 and 1 to control the needle height.

Gradient Like Effect - Live Example

<ReactSpeedometer
  value={333}
  maxSegmentLabels={5}
  segments={1000}
/>

FAQ:

  1. How to use with nextjs?

    react-d3-speedometer uses lodash-es dependency for better tree shaking. For nextjs, please use next-transpile-modules, so that ES module exports from lodash-es package is properly transpiled. You can also nextjs dynamic imports - https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

Please refer to this issue for more details on how to make this library work with next.js - #89

  1. How to use with React 17?

    Please use latest v1.x (v1.0.0 at the time of writing). v1.x is compatible with React 17.

  2. How to use with React 16?

    Please use latest v0.x (v0.14.x at the time of writing). v0.x is compatible with React 16.


Ports:


Todos:

  • Test coverage (with enzyme)
  • Convert entire code base to ES6
  • Split core from lifecycles
  • Typescript support

Tests:

react-d3-speedometer comes with a test suite using enzyme.

// navigate to root folder and run
npm test
// or 'yarn test' if you are using yarn

Feature Updates:

  • [v1.0.0] React v17 support. d3 v6 support. Live Example

  • [v0.14.0] valueTextFontWeight config to control font weight of current value

  • [v0.10.0] Custom labels. Live Example

  • [v0.9.0] Typescript support

  • [v0.8.0] paddingHorizontal, paddingVertical configuration to control spacing around text. Live Example

  • [v0.7.0] Custom segment stops. Live Example

  • [v0.6.0] Custom segment colors. Live Example


Changelog:

View Changelog


Credits:

react-d3-speedometer was started as a react port of the following d3 snippet - http://bl.ocks.org/msqr/3202712. Component template was initially bootstrapped with React CDK. Also, many thanks to react and d3 ecosystem contributors.


Contributing:

PRs are welcome. Please create a issue/bugfix/feature branch and create an issue with your branch details. Probably I will create a similar branch in the upstream repo so that PRs can be raised against that branch instead of master. master-v0.x is the main branch for React 16 compatible changes.

Notes

  • 1.x versions are compatible with React & React DOM Versions v17.x
  • 0.x versions are compatible with React & React DOM Versions v16.x For every subsequent major react upgrade, react-d3-speedometer will be bumped to next major versions. For example 1.x will be compatible with React 17.x so on and so forth ...

For similar library for VueJS, please check out vue-speedometer.

For similar library for Svelte, please check out svelte-speedometer.

License:

MIT

react-d3-speedometer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-d3-speedometer's Issues

[Deprecation Announcement][>=0.5.0 <=0.5.4] Fixed Version => 0.5.5

This issue is to just document and announce the deprecation of following package versions >=0.5.0 <=0.5.4 because of babel 7 runtime error which will possibly throw following error

ModuleNotFoundError
Could not find module in path: 'react-d3-speedometer/dist/Users/Arun/play/github/react-d3-speedometer/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/classCallCheck' relative to '/node_modules/react-d3-speedometer/dist/index.js'

The runtime error was fixed in 0.5.5 and request to upgrade to this version to avoid this error.

Rerender on new width/height

I'm trying to rerender component on resize so I'm storing window's width and height in parent's state and passing them to ReactSpeedometer Component via props. It's getting new props but it doesn't rerender

Responsive for small screen

Hi all, Hi @palerdot ,
I'm using react-d3-speedometer and I created a speedometer successfully. Now a day, I have to create 6 speedometers on a line in small screen, so I had set width = 120 and height = 60 and I used fluidWidth={true} option.
This is my code:

    <div width: "120px",
    height: "60px",
    'text-align': 'center'}}
    <ReactSpeedometer
      value={value}
      fluidWidth={true}
      forceRender={true}
      segments={segments ? segments : 3}
      needleTransitionDuration={duration ? duration : 600}
      maxValue={maxValue ? maxValue : 600}
      startColor={startColor ? startColor : "green"}
      endColor={endColor ? endColor : "red"}
      needleTransition="easeElastic"
      currentValueText="${value}"
    /> </div>

As a result:
44444444444

Please have a look into it and kindly suggest me to resolve the issue.
Sorry for my english.
Thanhnv from Thinklabs - Vietnam

IE9 throws "SCRIPT1014: Invalid character"

IE9 throws "SCRIPT1014: Invalid character", despite page charset being set to UTF-8.

The issue is coming from the ` in the following line 352, index.js:
return new Function(params, "return `"+literal+"`;");

Just needs changing to:
return new Function(params, "return '"+literal+"';");

ie9-script1014-invalid-character

Will raise a pull request to fix.

Removing All Segment Labels

I figured I could set maxSegmentLabels={0} and it wouldn't show any segment labels, however it just ends up re-inheriting the segments value.

Any thought on allowing us to hide the segment labels?

Configuring the needle size.

Hi all, Hi @palerdot ,
I'm using react-d3-speedometer for my project and I have a problem with the size of needle.
I can not find any solution about set size of the needle which is too long.
Observe the following image. In the left image, the text value is overrided by the needle. I can only set the needle color by the needleColor property.
333333

Can it be resolved with d3-speedometer? Thanks.
Thanhnv from Thinklabs - Vietnam

Displaying the Speedometer in wordpress website

I have been trying to display this package (react-d3-speedometer) on my wordpress page. I installed the package in the plugin folder i created using npm but cant seem to make the speedometer display after adding the following to the page;

<div style={{width: "500px",height: "300px",background: "#EFEFEF"}}>
     <ReactSpeedometer />
</div>

Please what am i doing wrong or what am i missing?

a._d3_refs.pointer.transition is not a function

index.js:1 Uncaught TypeError: a._d3_refs.pointer.transition is not a function
at Object.k [as update] (index.js:1)
at b.a (index.js:1)
at b.a (index.js:1)
at b.a (index.js:1)
at commitLifeCycles (react-dom.development.js:8770)
at commitAllLifeCycles (react-dom.development.js:9946)
at HTMLUnknownElement.callCallback (react-dom.development.js:542)
at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
at invokeGuardedCallback (react-dom.development.js:438)
at commitRoot (react-dom.development.js:10050)
at performWorkOnRoot (react-dom.development.js:11017)
at performWork (react-dom.development.js:10967)
at batchedUpdates (react-dom.development.js:11086)
at batchedUpdates (react-dom.development.js:2330)
at dispatchEvent (react-dom.development.js:3421)

index.js:2178 The above error occurred in the component:
in ReactSpeedometer (created by CardInfo)
in div (created by CardInfo)
in div (created by CardInfo)
in div (created by TabPanel)
in TabPanel (created by CardInfo)
in div (created by UncontrolledTabs)
in UncontrolledTabs (created by Tabs)
in Tabs (created by CardInfo)
in div (created by Collapsible)
in div (created by Collapsible)
in div (created by Collapsible)
in Collapsible (created by CardInfo)
in div (created by CardInfo)
in div (created by CardInfo)
in div (created by CardInfo)
in div (created by CardInfo)
in CardInfo (created by CardInfoListItem)
in CardInfoListItem (created by CardsList)
in div (created by CardsList)
in CardsList (created by CardsListContainer)
in CardsListContainer (created by Connect(CardsListContainer))
in Connect(CardsListContainer) (created by Dashboard)
in div (created by Dashboard)
in div (created by Dashboard)
in div (created by Dashboard)
in div (created by Dashboard)
in Dashboard (created by Connect(Dashboard))
in Connect(Dashboard) (created by Route)
in div (created by Route)
in Route (created by PrivateRoute)
in PrivateRoute (created by Connect(PrivateRoute))
in Connect(PrivateRoute) (created by router)
in Switch (created by router)
in div (created by router)
in Router (created by router)
in router (created by App)
in App
in Provider

How to implement gradient in react-d3-speedometer?

Hi,
I have used this library and im trying to make the color shades to be a gradient. As the svg is generated by the component itself , i wasn't able to add linear gradients using css to the svg element. I'm aware that I can add through JS (i.e. document.getElementById's) but other than that any leads with this would help me. Any plan to implement gradients?

maxValue Does Not Update

I am loading data from a JSON file and If the values for minValue or maxValue change, this change is not reflected in the gauge. Setting forceRender to true fixing this issue but also makes the needle reset to its default position making it rapidly swing from 0 to the current value. Is there any way to fix this. Either by making these values update or by making forceRender use an initial value so it does not

unable to resolve module

I removed node_modules completely and then npm install. I can see react-d3-speedometer in my node_modules, but without src folder in it. At least earlier it used to fail with error "Expected Component, but got class", but now it fails even before that with error unable to resolve module. Can you please let me know reason?

Reversing startColor/endColor does not produce expected results

If I use <ReactSpeedometer startColor="#FF471A" endColor="#33CC33" /> I would expect reversing the startColor and endColor (<ReactSpeedometer startColor="#33CC33" endColor="#FF471A" />) would produce a gauge with exactly the opposite color range. However this is not the case.

Observe the following image. The second speedometer starts a shade darker and ends a shade lighter than what I would expect.

image

Show min and max value labels on speedometer

I want a single colour speedometer which I achieve by setting the segment as 1. I set the min and max values. But, the max value is not always shown on the speedometer. For example, the following code will show 0 (minValue) and 20 but not the maxValue of 25 on the screen. Is there a way to force the component to show the min and max values on the screen?

<ReactSpeedometer
    maxValue={25}
    minValue={0}
    value={20}
    needleColor="#5e9da5"
    startColor="#d55b49"
    endColor="#a7abb7"
    ringWidth={10}
    segments={1}
    width={225}/>

Force Rerender happens on any state change, irregardless of direct prop changes

Like the title says, force render is making my component rerender if other states change after the initial component is rendered, even if the parent component state is changed, the child component where the speedometer is affected.

If this is intended behavior, could you point me in the right direction of modifying the Speedometer source code to rerender the maxValue prop on change as well? That would resolve my issue.

inline SVG presentational attributes(width,height) are overriden by other svg css

Hi @palerdot and @tinaboyce
SVG presentational attributes(her width,height) are easily overridden by other external css.
Hence, the inline style element should be used to set width and height of SVG element.
IT SHOULD BE SOMETHING LIKE THIS -->
Check attr() and style() methods on svg below

_renderSVG(a){var b=a.container,c=a.config;return(0,_d.select)(b).append("svg:svg").attr("class","speedometer").style("width",c.width).style("height",c.height)}

INSTEAD OF -->

_renderSVG(a){var b=a.container,c=a.config;return(0,_d.select)(b).append("svg:svg").attr("class","speedometer").attr("width",c.width).attr("height",c.height)}

Please can you make this small change and commit.

Check below link for refrence and understanding problem.
https://css-tricks.com/presentation-attributes-vs-inline-styles/

Unable to resolve module child_process

Hi,
I am using this package in CRNA project where I am getting an Issue "Unable to resolve module child_process "
I am attaching a screenshot for your reference
please have a look into it and kindly suggest me to resolve the issue
screenshot_1537528793

no-template-curly-in-string for currentValueText

When I set currentValueText with the value (e.g. "${value} some text"), I get a compile warning:

Line 275: Unexpected template string expression no-template-curly-in-string

The reason is because ${value} is what you use for es6 template strings.

Is there some work around for this - or should the syntax be changed, so as not to collide with this syntax / warning?

Splitting into unequal Segments

Hello. I want to divide the parts are not equal how will do and the numbers can be decimal?
For example:
Parts 1: 13.5 to 18.4
Parts 2: 18.5 to 24.9
Parts 2: 25 to 29.9
can you help me? thank you very much

unable to resolve dependancy

Yes, I understand that this component can not be used in react-native. However I want to get to the point where it used to resolve at least dependancy, but used to fail during react-native app launch. Now it is failing even before that. I want to fork this project and play with it to make it compatible for react-native

Showing empty speedometer when invalid data is passed to react-d3-speedometer

I love this gauge. I am updating the value from a parent component. Sometimes it passes some sort of undefined value and the app crashes. If that happens, i would like to have an empty gauge or a message "INVALID VALUE" embedded on top of the gauge without crashing. It shall continue to work normal when it gets valid data. How can i do it? Thanks.
....................................
Error Message:
error

How to use mqtt in d3 speedometer using react?

I successfully created speedometer but now I want to show real time data using mqtt in it. I have my mqtt but I dont know how to implement it in the speedometer. Anyone here who used it before? Can it be done with d3-speedometer?

Start and End Color not rendering properly.

Expected Start Color: #27ae60
Expected End Color: #e74c3c

But the expected color in the start and end is only seen appropriately when I increase the no of segments. Can it take same colors in less segments as well?

screen shot 2018-02-22 at 8 36 18 pm

Support for IE11

Hello,

I am using this library in a project where I need to support IE11. However, due to the missing entry in the .babelrc this is currently not supported and on IE11 the page, where the widget is located, is just broken.

Because this project already has a .babelrc file it is also no option to just transpile it together with the rest of the project. My only remaining solution was to fork this project and adjust the .babelrc file manually:

{
  "presets":  [
    [
      "env",
      {
        "targets": {
          "browsers": ["IE 11",
          "> 1%",
          "last 2 versions"]
        }
      }
    ],
    "react-app"
  ],
  "env": {
    "production": {
        "plugins": [
            "transform-remove-console",
            "transform-runtime"
        ],
        "presets": ["babili"]
    }
  }
}

(preset es2015 would also be fine)

Happy to create a PR if thats ok. The better approach would be of course - as the todo notes state - to just convert everything to ES2015, should also clear the issue.

Just Feedback Trendpoints or lables not available

Hi,

Really Cool Npm package, its very easy to integrate.

I just tried to integrate your npm packages, but you missed somthing i guess, your providing the customSegmentStops but there is dont have options to changes values name.

customSegmentStops={[0, 500, 750, 1000]}
In this case there will be 4 segments (0-500, 500-750, 750-1000)

In my case 0-500 label is Low, 500-750 label is Medium, 750-1000 label is High

Just take it as feedback, and also provide some send feedback option in your website.

FYI, So, Currently i have using fushionchart.com that option they are providing.

Thanks,
Gopal R.

How do i pass each slot different color

Each slot i want to pass different color how to pass.
Example: 0 - 100 If it is the max and min values.
0-20 (red)
20-40 (lightred)
40-60(green)
60-80(yellow)
Can any one help me to solve this.

segmentColors not including all specified colors.

When making a custom color sequence for my speedometer I noticed that the following implementation does not end up showing the light green color for the final segment, but instead shows the blue color twice. I assumed that if there are the same number of segments as there are colors that each color should be represented once. It looks like it is something to do with the d3.scaleQuantize function being used on the segmentColors list. I'll try to do some more digging later, but if you know any more about this problem please let me know!

`

    <ReactSpeedometer
        maxSegmentLabels={12}
        segments={6}
        value={470}
        segmentColors={[
            "#006E0D", //dark green
            "#006E0D",
            "#006E0D",
            "#006E0D",
            "#006e9d", //blueish
            "#0FFE0D" // light green
    ]}
    needleColor="#000080"
  />`

Error

Why this error is popping up? I'm trying the simplest form.

.//xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Cannot resolve module 'child_process' in D:\mike\node_modules\xmlhttprequest\lib
resolve module child_process in D:\mike\node_modules\xmlhttprequest\lib
looking for modules in D:\mike\node_modules
D:\mike\node_modules\child_process doesn't exist (module as directory)
resolve 'file' child_process in D:\mike\node_modules
resolve file
D:\mike\node_modules\child_process doesn't exist
D:\mike\node_modules\child_process.js doesn't exist
D:\mike\node_modules\child_process.jsx doesn't exist
[D:\mike\node_modules\child_process]
[D:\mike\node_modules\child_process]
[D:\mike\node_modules\child_process.js]
[D:\mike\node_modules\child_process.jsx]
@ ./
/xmlhttprequest/lib/XMLHttpRequest.js 15:12-36

Unequal segments

Is there a way we can have unequal segments based on a percentage for the dial?

minValue is not showing in speedometer

I am givng minValue but it is not reflect on speedometer.

Here is my code

<ReactSpeedometer maxValue={500} minValue={100} value={473} needleColor="blue" segments={1} needleTransitionDuration={4000} needleTransition="easeElastic" currentValueText="Current Value: ${value}" />

screenshot from 2019-01-09 11-43-52

Bug: (0 , _d.arc) is not a function

Hello, I'm running into this issue :

configure.js:1 Uncaught TypeError: (0 , _d.arc) is not a function
    at _configureArc (configure.js:1)
    at memoized (memoize-one.esm.js:27)
    at _renderArcs (index.js:1)
    at render (index.js:1)
    at b.a (index.js:1)
    at b.a (react-hot-loader.development.js:708)
    at b.a (index.js:1)
    at b.a (react-hot-loader.development.js:698)
    at commitLifeCycles (react-dom.development.js:20049)
    at commitLayoutEffects (react-dom.development.js:22813)
    at HTMLUnknownElement.callCallback (react-dom.development.js:347)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:397)
    at invokeGuardedCallback (react-dom.development.js:454)
    at commitRootImpl (react-dom.development.js:22585)
    at unstable_runWithPriority (scheduler.development.js:643)
    at runWithPriority$2 (react-dom.development.js:11305)
    at commitRoot (react-dom.development.js:22414)
    at runRootCallback (react-dom.development.js:21554)
    at react-dom.development.js:11353
    at unstable_runWithPriority (scheduler.development.js:643)
    at runWithPriority$2 (react-dom.development.js:11305)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11349)
    at flushSyncCallbackQueue (react-dom.development.js:11338)
    at batchedUpdates$1 (react-dom.development.js:21648)
    at Object.notify (Subscription.js:23)
    at Subscription.notifyNestedSubs (Subscription.js:65)
    at Subscription.handleChangeWrapper (Subscription.js:70)
    at notifyListeners (redux-batched-subscribe.js:43)
    at store.js:52
    at notifyListenersBatched (redux-batched-subscribe.js:48)
    at dispatch (redux-batched-subscribe.js:57)
    at middleware.js:22
    at middleware.js:66
    at redux-logger.js:1
    at api.js:31
    at index.js:11
    at dispatch (redux.min.js:1)
    at utils.js:250
    at proc.js:489
    at exec (scheduler.js:19)
    at flush (scheduler.js:60)
    at asap (scheduler.js:33)
    at runPutEffect (proc.js:486)
    at runEffect (proc.js:435)
    at next (proc.js:315)
    at currCb (proc.js:388)
    at checkEffectEnd (proc.js:612)
    at chCbAtKey (proc.js:627)
    at currCb (proc.js:388)
    at runEffect (proc.js:435)

Here is my code <ReactSpeedometer /> and I'm using [email protected] and [email protected]

Giving an invalid needleTransition value does not fail gracefully

Giving an invalid needTransition value (one that's not of the listed ones from d3-easing-identifiers) does not fail gracefully. It crashes the whole React app when the speedometer is rendered and does not give an error message.

This is using react-d3-speedometer version 0.3.2.

It produces the error below when it crashes.

screen shot 2018-08-12 at 8 24 43 pm

screen shot 2018-08-12 at 8 25 02 pm

Upgrade to support react@>=16.0.0

Could you please verify that it works with a newer react version and update the dependencies with the next release? I don't use all the features but it does seem to work fine.

Thanks for your work otherwise!

Supporting Negative range like -120 to 0

Currently if i want to show the range from -120 to 0, its not working as expected.

In util/index.js
calculateSegmentStops returning the following " return (current_stop - customSegmentStops[index - 1]) / max " , Here max is 0 which might be resulting to infinite ,and instead it should be max-min which can fix the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.