1.1.4 • Published 5 years ago

canvas-bullet-chart v1.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Canvas Bullet Chart

How to use

  1. import bulletChart from 'canvas-bullet-chart'
  2. Call bulletChart(canvas, options).

Or: 1. import { bulletChartImage } from 'canvas-bullet-chart; 2. Call bulletChartImage(options)

Function parameters

canvas

It may be either a <canvas> element or an element id.

options

Object containing the desired options and values.

Allowed options

NameTypeDescriptionDefault
borderFillString / ObjectFill options for the border. Object format explained here#808080
fontSizeNumberFont size for the labels.12
heightDecreaseNumberRate at which successive bars decrease in height.Here
scaleNumberMaximum expected value.1
scalePaddingNumberSpace between the labels and the bullet chart.7
valuesArrayExplained here.[]
withBorderBooleanShould a border be drawn around each boxfalse
scaleColorStringFont color for scale#000
widthNumberWidth of the desired image. Note: for bulletChartImage only1280
heightNumberHeight of the desired image. Note: for bulletChartImage only720

Values

Object containing the values to render.

NameTypeDescriptionDefault
fillColorStringSolid color to fill the bar (e.g.: #f00). Ignored if gradientOptions provided.#000
gradientOptionsObjectAn object with the options for the gradients, explained here.{}
nameStringAt the time, not in use.undefined
valueNumberShould be less than the scale and greater than zero.0

Gradient Options

Object containing the desired gradient options.

NameTypeDescriptionDefault
endColorStringFinal gradient color (e.g.: #0f0).#fff
endStopNumberInitial position for the gradient in the (x0,y0), (x1,y1) diagonal.1
startColorStringInitial gradient color (e.g.: #f00).#000
startStopNumberInitial position for the gradient in the (x0,y0), (x1,y1) diagonal0
x0NumberInitial horizontal position for the gradient0
x1NumberFinal horizontal position for the gradient.<canvas> width
y0NumberInitial vertical position for the gradient0
y1NumberFinal vertical position for the gradient.<canvas> height

Height decrease calculation.

If no heightDecrease value is provided, it's calculated as: (<canvas height> - <fontSize> - <scalePadding>) / <values array length>

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago