Skip to main content

bullet

Bullet

Reusable Bullet Chart API class that renders a simple and configurable Bullet Chart.

Requires: module:d3-axis,
Example

let bulletChart = bullet();

bulletChart
.width(containerWidth);

d3Selection.select('.css-selector')
.datum(dataset)
.call(bulletChart);

exports(_selection, _data) ⏏

This function creates the graph using the selection as container

Kind: Exported function

ParamTypeDescription
_selectionD3SelectionA d3 selection that represents the container(s) where the chart(s) will be rendered
_dataBulletChartDataThe data to attach and generate the chart

exports.colorSchema(_x) ⇒ Array.<String> | module

Gets or Sets the colorSchema of the chart. The first color from the array will be applied to range bars (the wider bars). The second color from the array will be applied to measure bars (the narrow bars) and the third color will be applied to the marker lines.

Kind: static method of exports
Returns: Array.<String> | module - Current colorSchema or Chart module to chain calls
Access: public

ParamTypeDescription
_xArray.<String>Desired colorSchema for the graph

exports.customTitle(_x) ⇒ String | module

Gets or Sets the title for measure identifier range.

Kind: static method of exports
Returns: String | module - Current customTitle or Chart module to chain calls
Access: public

ParamTypeDescription
_xStringDesired customTitle for chart

Example

bulletChart.customTitle('CPU Usage')

exports.customSubtitle(_x) ⇒ String | module

Gets or Sets the subtitle for measure identifier range.

Kind: static method of exports
Returns: String | module - current customSubtitle or Chart module to chain calls
Access: public

ParamTypeDescription
_xStringDesired customSubtitle for chart

Example

bulletChart.customSubtitle('GHz')

exports.exportChart(filename, title) ⇒ Promise

Chart exported to png and a download action is fired

Kind: static method of exports
Returns: Promise - Promise that resolves if the chart image was loaded and downloaded successfully
Access: public

ParamTypeDescription
filenameStringFile title for the resulting picture
titleStringTitle to add at the top of the exported picture

exports.height(_x) ⇒ Number | module

Gets or Sets the height of the chart

Kind: static method of exports
Returns: Number | module - Current height or Chart module to chain calls
Access: public

ParamTypeDescription
_xNumberDesired height for the chart

exports.isReverse(_x) ⇒ Boolean | module

Gets or Sets the isReverse status of the chart. If true, the elements will be rendered in reverse order.

Kind: static method of exports
Returns: Boolean | module - Current height or Chart module to chain calls
Access: public

ParamTypeDefaultDescription
_xBooleanfalseDesired height for the chart

exports.margin(_x) ⇒ margin | module

Gets or Sets the margin of the chart

Kind: static method of exports
Returns: margin | module - Current margin or Chart module to chain calls
Access: public

ParamTypeDescription
_xObjectMargin object to get/set

exports.numberFormat(_x) ⇒ string | module

Gets or Sets the number format of the bar chart

Kind: static method of exports
Returns: string | module - Current numberFormat or Chart module to chain calls
Access: public

ParamTypeDescription
_xstring= ',f' Desired numberFormat for the chart. See examples here

exports.paddingBetweenAxisAndChart(_x) ⇒ Number | module

Space between axis and chart

Kind: static method of exports
Returns: Number | module - Current value of paddingBetweenAxisAndChart or Chart module to chain calls
Access: public

ParamTypeDefaultDescription
_xNumber5Space between y axis and chart

exports.startMaxRangeOpacity(_x) ⇒ Number | module

Gets or Sets the starting point of the capacity range.

Kind: static method of exports
Returns: Number | module - current startMaxRangeOpacity or Chart module to chain calls
Access: public

ParamTypeDefaultDescription
_xNumber0.5Desired startMaxRangeOpacity for chart

Example

bulletChart.startMaxRangeOpacity(0.8)

exports.ticks(_x) ⇒ Number | module

Gets or Sets the number of ticks of the x axis on the chart

Kind: static method of exports
Returns: Number | module - Current ticks or Chart module to chain calls
Access: public

ParamTypeDescription
_xNumber= 5 Desired horizontal ticks

exports.width(_x) ⇒ Number | module

Gets or Sets the width of the chart

Kind: static method of exports
Returns: Number | module - Current width or Chart module to chain calls
Access: public

ParamTypeDescription
_xNumberDesired width for the chart

exports~BulletChartData : Object

Kind: inner typedef of exports
Properties

NameTypeDescription
rangesArray.<Number>Range that encodes the qualitative measure
measuresArray.<Number>Range that encodes the performance measure
markersArray.<Number>Marker lines that encode the comparative measure
[title]StringString that sets identification for the measure
[subtitle]StringString that provides more details on measure identification

Example

{
ranges: [130, 160, 250],
measures: [150, 180],
markers: [175],
title: 'Title for Bullet',
subtitle: 'Subtitle'
}