Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-d3-speedometer

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-d3-speedometer

React D3 Speedometer Component

  • 0.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.7K
decreased by-52.85%
Maintainers
1
Weekly downloads
 
Created
Source

react-d3-speedometer

react-d3-speedometer is a react component for showing speedometer like gauge using d3.

Build Status

NPM

react-d3-speedometer

Usage:

NPM: npm install --save react-d3-speedometer

Yarn: yarn add react-d3-speedometer

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

Configuration Options:

proptypedefaultcomments
valuenumber0Make sure your value is between your minValue and maxValue
minValuenumber0
maxValuenumber1000
segmentsnumber5Number of segments in the speedometer
widthnumber300diameter of the speedometer and the width of the svg element
heightnumber300height 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
fluidWidthbooleanfalseIf true takes the width of the parent component. See Live Example for more details
needleColorstringsteelblueShould be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
startColorstring#FF471AShould be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
endColorstring#33CC33Should be a valid color code - colorname, hexadecimal name or rgb value. Should be a valid input for d3.interpolateHsl
needleTransitionstringeaseQuadInOutd3-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
needleTransitionDurationnumber500Time in milliseconds.
ringWidthnumber60Width of the speedometer ring.
textColorstring"#666"Should be a valid color code - colorname, hexadecimal name or rgb value. Used for both showing the current value and the segment values

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"
/>
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"
/>

This is the needle transition used in the sample image


Todos:

  • Basic Test coverage (with enzyme)
  • Convert entire code base to ES6

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 bootstrapped with React CDK. Also, many thanks to d3 and react ecosystem contributors.


License:

MIT

Keywords

FAQs

Package last updated on 12 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc