0.0.2 • Published 4 years ago

native-sparkline v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Built With Stencil

Sparklines

This is a zero dependency native web-component for generating sparklines.

Sparklines can be used to show a trend of data, as well as allowing your users to drill into specific metrics.

Getting started

npm i native-sparkline --save

Example

<dan-sparkline
  width=400
  height=100
  data="10,6,26,37,62,86,89,75,102,150,64,22,50"
  stroke-color="hsl(204, 86%, 53%)"
  stroke-width="3"
  spot-size="3"
  cursor-width=0
  animated=true
></dan-sparkline>

Customisation

Properties

PropertyAttributeDescriptionTypeDefault
animatedanimatedWhether the sparkline should be animated.booleanfalse
animationDelayanimation-delayThe delay before the animation takes place.number0
animationDurationanimation-durationThe duration of the animation.number200
animationTimingFunctionanimation-timing-functionWhich timing function to use for the animation.string'linear'
cursorColorcursor-colorThe colour of the cursor line.string'rgba(0,0,0,0.5)'
cursorWidthcursor-widthThe width of the cursor line.number1
datadataThe data which this sparkline should use.stringundefined
fillColorfill-colorThe colour which should be used for the sparkline fill.string'rgba(0,0,0,0)'
heightheightThe height of the sparkline, in pixels.number20
interactiveinteractiveWhether the sparkline should be interactive. When enabled, a cursor will appear next to the closest datapoint when hovered over.booleantrue
maxmaxThe maximum value the trend should use.numberundefined
minminThe minimum value the trend should use.number0
spotSizespot-sizeThe radius of the point which is visible when a datapoint is hovered over.number5
strokeColorstroke-colorThe colour which should be used for the sparkline line.string'rgba(0,0,0,1)'
strokeWidthstroke-widthThe width of the sparkline line, in pixels.number2
widthwidthThe width of the sparkline, in pixels.number100