BulletChart

live example

Explore the API in the live example.

api reference

BulletChart(name[, parent])
The bullet chart widget. The chart extends the following components:

Parameters

NameTypeDescription
namestringName of the chart. Should be a unique identifier.
parentstringoptionalSee [Widget] ../components/widget.html for description. Default value is body.
BulletChart.forecast([forecast])
Sets the forecast value in units of the bar's value.

Parameters

NameTypeDescription
forecastnumberoptionalForecast value in units of the bar value. Default value is 1.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set forecast to the triple of the value.
const bullet = dalian.BulletChart('my-chart')
  .forecast(3)
  .render()

// Reset forecast to default.
bullet.forecast()
  .render()
BulletChart.label(label)
Sets the chart label.

Parameters

NameTypeDescription
labelstringLabel to set for the chart.

Returns

BulletChart
Reference to the BulletChart API.

Examples

const bullet = dalian.BulletChart('my-chart')
  .label('Revenue')
  .render()
BulletChart.rangeColor([color])
Sets the color for the ranges.

Parameters

NameTypeDescription
colorstringoptionalColor to set for the ranges. Default value is #888.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set range color to red.
const bullet = dalian.BulletChart('my-chart')
  .rangeColor('red')
  .render()

// Reset range color to default.
bullet.rangeColor()
  .render()
BulletChart.ranges()
Sets the qualitative ranges.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set poor, satisfactory, good ranges to (0, 60), (60, 90), (90, 100).
const bullet = dalian.BulletChart('my-chart')
  .ranges([0, 60, 90, 100])
  .render()

// Reset ranges to default.
bullet.ranges()
  .render()
BulletChart.target(target)
Sets the target value.

Parameters

NameTypeDescription
targetnumberTarget value to set.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set target to 80.
const bullet = dalian.BulletChart('my-chart')
  .target(80)
  .render()
BulletChart.thickness([thickness])
Sets the thickness of the range.

Parameters

NameTypeDescription
thicknessnumberoptionalThickness to set. Default value is 30.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set thickness to 20px.
const bullet = dalian.BullestChart('my-chart')
  .thickness(20)
  .render()

// Reset thickness to default.
bullet.thickness()
  .render()
BulletChart.unit(unit)
Sets the unit description.

Parameters

NameTypeDescription
unitstringUnit description.

Returns

BulletChart
Reference to the BulletChart API.

Examples

const bullet = dalian.BulletChart('my-chart')
  .unit('USD')
  .render()
BulletChart.value([value])
Sets the bar's value.

Parameters

NameTypeDescription
valuenumberoptionalValue to set the bar to. Default value is 0.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set value to 50.
const bullet = dalian.BulletChart('my-chart')
  .value(50)
  .render()

// Reset value to default.
bullet.value()
  .render()
BulletChart.valueColor([color])
Sets the color of the bar, forecast and target. Note that the forecast bar's color is a lightened version of the value color.

Parameters

NameTypeDescription
colorstringoptionalColor to set for the bar, forecast and target. Default value is #000.

Returns

BulletChart
Reference to the BulletChart API.

Examples

// Set value, forecast and target color to blue.
const bullet = dalian.BulletChart('my-chart')
  .valueColor('blue')
  .render()

// Reset value color to default.
bullet.valueColor()
  .render()