Skip to main content

grouped-bar

Grouped-bar

Grouped Bar Chart reusable API module that allows us rendering a multi grouped bar and configurable chart.

Requires: module:d3-array,
Example

let groupedBar = GroupedBar();

groupedBar
.width(containerWidth);

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

exports(_selection, _data) ⏏

This function creates the graph using the selection and data provided

Kind: Exported function

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

exports.animationDuration(_x) ⇒ duration | module

Gets or Sets the duration of the animation

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

ParamTypeDefaultDescription
_xNumber1200Desired animation duration for the graph

exports.betweenBarsPadding([_x]) ⇒ Number | module

Gets or Sets the padding between bars.

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

ParamTypeDefaultDescription
[_x]Number0.1Padding value to get/set

exports.betweenGroupsPadding([_x]) ⇒ Number | module

Gets or Sets the padding between groups of bars.

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

ParamTypeDefaultDescription
[_x]Number0.1Padding value to get/set

exports.colorMap([_x]) ⇒ object | module

Gets or Sets the colorMap of the chart

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

ParamTypeDefaultDescription
[_x]objectColor map

Example

groupedBar.colorMap({groupName: 'colorHex', groupName2: 'colorString'})

exports.colorSchema(_x) ⇒ colorSchema | module

Gets or Sets the colorSchema of the chart

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

ParamTypeDescription
_xArray.<String>Desired colorSchema for the graph

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.groupLabel(_x) ⇒ groupLabel | module

Deprecated

Gets or Sets the groupLabel of the chart

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

ParamTypeDescription
_xStringDesired groupLabel for the graph

exports.grid([_x]) ⇒ String | module

Gets or Sets the grid mode.

Kind: static method of exports
Returns: String | module - Current mode of the grid or Area Chart module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]StringDesired mode for the grid ('vertical'

exports.height([_x]) ⇒ height | module

Gets or Sets the height of the chart

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

ParamTypeDefaultDescription
[_x]Number500Desired width for the graph

exports.isHorizontal([_x]) ⇒ isHorizontal | module

Gets or Sets the horizontal direction of the chart

Kind: static method of exports
Returns: isHorizontal | module - If it is horizontal or Bar Chart module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]numberfalseDesired horizontal direction for the graph

exports.isAnimated([_x]) ⇒ isAnimated | module

Gets or Sets the isAnimated property of the chart, making it to animate when render. By default this is 'false'

Kind: static method of exports
Returns: isAnimated | module - Current isAnimated flag or Chart module
Access: public

ParamTypeDefaultDescription
[_x]BooleanfalseDesired animation flag

exports.isLoading(flag) ⇒ boolean | module

Gets or Sets the loading state of the chart

Kind: static method of exports
Returns: boolean | module - Current loading state flag or Chart module to chain calls * @public

ParamTypeDescription
flagbooleanDesired value for the loading state

exports.margin(_x) ⇒ margin | module

Gets or Sets the margin of the chart

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

ParamTypeDescription
_xObjectMargin object to get/set

exports.nameLabel(_x) ⇒ nameLabel | module

Deprecated

Gets or Sets the nameLabel of the chart

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

ParamTypeDescription
_xNumberDesired dateLabel for the graph

exports.numberFormat(_x) ⇒ Array.<string> | module

Gets or Sets the numberFormat of the chart

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

ParamTypeDescription
_xArray.<string>= ',f' Desired numberFormat for the chart. See examples here

exports.on() ⇒ module

Exposes an 'on' method that acts as a bridge with the event dispatcher We are going to expose this events: customMouseOver, customMouseMove, customMouseOut, and customClick

Kind: static method of exports
Returns: module - Bar Chart
Access: public

exports.tooltipThreshold([_x]) ⇒ Number | module

Gets or Sets the minimum width of the graph in order to show the tooltip NOTE: This could also depend on the aspect ratio

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

ParamTypeDefaultDescription
[_x]Number480Minimum width of chart to show the tooltip

exports.valueLabel(_x) ⇒ Number | module

Deprecated

Gets or Sets the valueLabel of the chart

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

ParamTypeDescription
_xNumberDesired valueLabel for the graph

exports.valueLocale([_x]) ⇒ LocaleObject | module

Gets or Sets the locale which our formatting functions use. Check the d3-format docs for the required values.

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

ParamTypeDefaultDescription
[_x]LocaleObject_x Desired locale object format.

Example

groupedBarChart
.locale({thousands: '.', grouping: [3], currency: ["$", ""], decimal: "."})

exports.width([_x]) ⇒ Number | module

Gets or Sets the width of the chart

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

ParamTypeDefaultDescription
[_x]Number960Desired width for the graph

exports.xTicks([_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 xTicks or Chart module to chain calls
Access: public

ParamTypeDefaultDescription
[_x]Number5Desired xTicks

exports.yAxisLabel(_x) ⇒ String | module

Gets or Sets the y-axis label of the chart

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

ParamTypeDescription
_xStringDesired label string

Example

groupedBar.yAxisLabel('Ticket Sales')

exports.yAxisLabelOffset([_x]) ⇒ Number | module

Gets or Sets the offset of the yAxisLabel of the chart. The method accepts both positive and negative values.

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

ParamTypeDefaultDescription
[_x]Number-60Desired offset for the label

Example

groupedBar.yAxisLabelOffset(-55)

exports.yTicks([_x]) ⇒ Number | module

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

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

ParamTypeDefaultDescription
[_x]Number5Desired vertical ticks

exports.yTickTextOffset([_x]) ⇒ Object | module

Gets or Sets the x and y offset of ticks of the y axis on the chart

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

ParamTypeDefaultDescription
[_x]Object{ y: -8, x: -20 }Desired offset

exports~GroupedBarChartData : Array.<Object>

Kind: inner typedef of exports
Properties

NameTypeDescription
nameStringName of the entry
groupStringgroup of the entry
valueNumberValue of the entry

Example

[
{
name: "2011-01",
group: "Direct",
value: 0
}
]