dc.js Class: barChart (original) (raw)
dc. barChart
new barChart(parent [, chartGroup])
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
parent | String|node | d3.selection | dc.compositeChart |
chartGroup | String | The name of the chart group this chart instance should be placed in. Interaction with a chart will only trigger events and redraws within the chart's group. |
Mixes In:
Source:
Returns:
Type
Example
// create a bar chart under #chart-container1 element using the default global chart group var chart1 = dc.barChart('#chart-container1'); // create a bar chart under #chart-container2 element using chart group A var chart2 = dc.barChart('#chart-container2', 'chartGroupA'); // create a sub-chart under a composite parent chart var chart3 = dc.barChart(compositeChart);
Methods
alwaysUseRounding( [alwaysUseRounding])
Set or get whether rounding is enabled when bars are centered. If false, using rounding with centered bars will result in a warning and rounding will be ignored. This flag has no effect if bars are not centered. When using standard d3.js rounding methods, the brush often doesn't align correctly with centered bars since the bars are offset. The rounding function must add an offset to compensate, such as in the following example.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
alwaysUseRounding | Boolean | false |
Source:
Returns:
Type
Boolean|dc.barChart
Example
chart.round(function(n) { return Math.floor(n) + 0.5; });
barPadding( [barPadding])
Get or set the spacing between bars as a fraction of bar size. Valid values are between 0-1. Setting this value will also remove any previously set gap. See thed3 docsfor a visual description of how the padding is applied.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
barPadding | Number | 0 |
Source:
Returns:
Type
Number|dc.barChart
centerBar( [centerBar])
Whether the bar chart will render each bar centered around the data position on the x-axis.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
centerBar | Boolean | false |
Source:
Returns:
Type
Boolean|dc.barChart
gap( [gap])
Manually set fixed gap (in px) between bars instead of relying on the default auto-generated gap. By default the bar chart implementation will calculate and set the gap automatically based on the number of data points and the length of the x axis.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
gap | Number | 2 |
Source:
Returns:
Type
Number|dc.barChart
outerPadding( [padding])
Get or set the outer padding on an ordinal bar chart. This setting has no effect on non-ordinal charts. Will pad the width by padding * barWidth
on each side of the chart.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
padding | Number | 0.5 |
Source:
Returns:
Type
Number|dc.barChart