1.0.0
Legend is a attachable widget that can be added to other dc charts to render horizontal legend labels.
dc.legend
:
chart.legend(dc.legend().x(400).y(10).itemHeight(13).gap(5))
Concrete bar chart/histogram implementation.
((String | node | d3.selection | dc.compositeChart))
Any valid
d3 single selector
specifying a dom block element such as a div; or a dom element or d3 selection. If the bar
chart is a sub-chart in a
Composite Chart
then pass in the parent
composite chart instance instead.
(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.
dc.barChart
:
// 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);
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.
(Number
= 2
)
Number
:
dc.barChart
:
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.
(Boolean
= false
)
Boolean
:
dc.barChart
:
chart.round(function(n) { return Math.floor(n) + 0.5; });
A box plot is a chart that depicts numerical data via their quartile ranges.
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.boxPlot
:
// create a box plot under #chart-container1 element using the default global chart group
var boxPlot1 = dc.boxPlot('#chart-container1');
// create a box plot under #chart-container2 element using chart group A
var boxPlot2 = dc.boxPlot('#chart-container2', 'chartGroupA');
Get or set the numerical width of the boxplot box. The width may also be a function taking as parameters the chart width excluding the right and left margins, as well as the number of x units.
(Number | Function)
:
dc.boxPlot
:
// Using numerical parameter
chart.boxWidth(10);
// Using function
chart.boxWidth((innerChartWidth, xUnits) { ... });
A concrete implementation of a general purpose bubble chart that allows data visualization using the following dimensions:
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.bubbleChart
:
// create a bubble chart under #chart-container1 element using the default global chart group
var bubbleChart1 = dc.bubbleChart('#chart-container1');
// create a bubble chart under #chart-container2 element using chart group A
var bubbleChart2 = dc.bubbleChart('#chart-container2', 'chartGroupA');
The bubble overlay chart is quite different from the typical bubble chart. With the bubble overlay chart you can arbitrarily place bubbles on an existing svg or bitmap image, thus changing the typical x and y positioning while retaining the capability to visualize data using bubble radius and coloring.
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.bubbleOverlay
:
// create a bubble overlay chart on top of the '#chart-container1 svg' element using the default global chart group
var bubbleChart1 = dc.bubbleOverlayChart('#chart-container1').svg(d3.select('#chart-container1 svg'));
// create a bubble overlay chart on top of the '#chart-container2 svg' element using chart group A
var bubbleChart2 = dc.compositeChart('#chart-container2', 'chartGroupA').svg(d3.select('#chart-container2 svg'));
mandatory
Set the underlying svg image element. Unlike other dc charts this chart will not generate a svg element; therefore the bubble overlay chart will not work if this function is not invoked. If the underlying image is a bitmap, then an empty svg will need to be created on top of the image.
((SVGElement | d3.selection)?)
dc.bubbleOverlay
:
// set up underlying svg element
chart.svg(d3.select('#chart svg'));
mandatory
Set up a data point on the overlay. The name of a data point should match a specific 'key' among data groups generated using keyAccessor. If a match is found (point name <-> data group key) then a bubble will be generated at the position specified by the function. x and y value specified here are relative to the underlying svg.
dc.bubbleOverlay
:
Composite charts are a special kind of chart that render multiple charts on the same Coordinate Grid. You can overlay (compose) different bar/line/area charts in a single composite chart to achieve some quite flexible charting effects.
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.compositeChart
:
// create a composite chart under #chart-container1 element using the default global chart group
var compositeChart1 = dc.compositeChart('#chart-container1');
// create a composite chart under #chart-container2 element using chart group A
var compositeChart2 = dc.compositeChart('#chart-container2', 'chartGroupA');
Combine the given charts into one single composite coordinate grid chart.
(Array<Chart>?)
dc.compositeChart
:
moveChart.compose([
// when creating sub-chart you need to pass in the parent chart
dc.lineChart(moveChart)
.group(indexAvgByMonthGroup) // if group is missing then parent's group will be used
.valueAccessor(function (d){return d.value.avg;})
// most of the normal functions will continue to work in a composed chart
.renderArea(true)
.stack(monthlyMoveGroup, function (d){return d.value;})
.title(function (d){
var value = d.value.avg?d.value.avg:d.value;
if(isNaN(value)) value = 0;
return dateFormat(d.key) + '\n' + numberFormat(value);
}),
dc.barChart(moveChart)
.group(volumeByMonthGroup)
.centerBar(true)
]);
Get or set the y scale for the right axis. The right y scale is typically automatically generated by the chart implementation.
(d3.scale?)
d3.scale
:
dc.compositeChart
:
Set or get the right y axis used by the composite chart. This function is most useful when y axis customization is required. The y axis in dc.js is an instance of a d3 axis object therefore it supports any valid d3 axis manipulation. Caution: The y axis is usually generated internally by dc; resetting it may cause unexpected results.
(d3.svg.axis?)
d3.svg.axis
:
dc.compositeChart
:
// customize y axis tick format
chart.rightYAxis().tickFormat(function (v) {return v + '%';});
// customize y axis tick values
chart.rightYAxis().tickValues([0, 100, 200, 300]);
The data count widget is a simple widget designed to display the number of records selected by the current filters out of the total number of records in the data set. Once created the data count widget will automatically update the text content of the following elements under the parent element.
'.total-count' - total number of records '.filter-count' - number of records matched by the current filters
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.dataCount
:
var ndx = crossfilter(data);
var all = ndx.groupAll();
dc.dataCount('.dc-data-count')
.dimension(ndx)
.group(all);
Gets or sets an optional object specifying HTML templates to use depending how many items are
selected. The text %total-count
will replaced with the total number of records, and the text
%filter-count
will be replaced with the number of selected records.
{some: String, all: String}
:
dc.dataCount
:
counter.html({
some: '%filter-count out of %total-count records selected',
all: 'All records selected. Click on charts to apply filters'
})
Data grid is a simple widget designed to list the filtered records, providing a simple way to define how the items are displayed.
Note: Unlike other charts, the data grid chart (and data table) use the group attribute as a keying function for nesting the data together in groups. Do not pass in a crossfilter group as this will not work.
Examples:
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.dataGrid
:
Get or set the function that formats an item. The data grid widget uses a function to generate dynamic html. Use your favourite templating engine or generate the string directly.
(Function?)
Function
:
dc.dataGrid
:
chart.html(function (d) { return '<div class='item '+data.exampleCategory+''>'+data.exampleString+'</div>';});
The geo choropleth chart is designed as an easy way to create a crossfilter driven choropleth map from GeoJson data. This chart implementation was inspired by the great d3 choropleth example.
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(any)
(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.
(any)
dc.geoChoroplethChart
:
// create a choropleth chart under '#us-chart' element using the default global chart group
var chart1 = dc.geoChoroplethChart('#us-chart');
// create a choropleth chart under '#us-chart2' element using chart group A
var chart2 = dc.compositeChart('#us-chart2', 'chartGroupA');
mandatory
Use this function to insert a new GeoJson map layer. This function can be invoked multiple times if you have multiple GeoJson data layers to render on top of each other. If you overlay multiple layers with the same name the new overlay will override the existing one.
(geoJson)
a geojson feed
(String)
name of the layer
(Function)
accessor function used to extract 'key' from the GeoJson data. The key extracted by
this function should match the keys returned by the crossfilter groups.
dc.geoChoroplethChart
:
// insert a layer for rendering US states
chart.overlayGeoJson(statesJson.features, 'state', function(d) {
return d.properties.name;
})
Set custom geo projection function. See the available d3 geo projection functions.
(d3.projection
= d3.geo.albersUsa()
)
dc.geoChoroplethChart
:
Returns the d3.geo.path object used to render the projection and features. Can be useful for figuring out the bounding box of the feature set and thus a way to calculate scale and translation for the projection.
d3.geo.path
:
A heat map is matrix that represents the values of two dimensions of data using colors.
Type: number
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.heatMap
:
// create a heat map under #chart-container1 element using the default global chart group
var heatMap1 = dc.heatMap('#chart-container1');
// create a heat map under #chart-container2 element using chart group A
var heatMap2 = dc.heatMap('#chart-container2', 'chartGroupA');
Set or get the column label function. The chart class uses this function to render column labels on the X axis. It is passed the column name.
(Function
= function(d){returnd;}
)
Function
:
dc.heatMap
:
// the default label function just returns the name
chart.colsLabel(function(d) { return d; });
Set or get the row label function. The chart class uses this function to render row labels on the Y axis. It is passed the row name.
(Function
= function(d){returnd;}
)
Function
:
dc.heatMap
:
// the default label function just returns the name
chart.rowsLabel(function(d) { return d; });
Gets or sets the handler that fires when an individual cell is clicked in the heatmap. By default, filtering of the cell will be toggled.
(Function?)
Function
:
dc.heatMap
:
// default box on click handler
chart.boxOnClick(function (d) {
var filter = d.key;
events.trigger(function () {
_chart.filter(filter);
_chart.redrawGroup();
});
});
Concrete line/area chart implementation.
Examples:
((String | node | d3.selection | dc.compositeChart))
Any valid
d3 single selector
specifying a dom block element such as a div; or a dom element or d3 selection. If the line
chart is a sub-chart in a
Composite Chart
then pass in the parent
composite chart instance instead.
(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.
dc.lineChart
:
// create a line chart under #chart-container1 element using the default global chart group
var chart1 = dc.lineChart('#chart-container1');
// create a line chart under #chart-container2 element using chart group A
var chart2 = dc.lineChart('#chart-container2', 'chartGroupA');
// create a sub-chart under a composite parent chart
var chart3 = dc.lineChart(compositeChart);
Gets or sets the interpolator to use for lines drawn, by string name, allowing e.g. step functions, splines, and cubic interpolation. This is passed to d3.svg.line.interpolate and d3.svg.area.interpolate, where you can find a complete list of valid arguments
(String
= 'linear'
)
String
:
dc.lineChart
:
Gets or sets the tension to use for lines drawn, in the range 0 to 1. This parameter further customizes the interpolation behavior. It is passed to d3.svg.line.tension and d3.svg.area.tension.
(Number
= 0.7
)
Number
:
dc.lineChart
:
Gets or sets a function that will determine discontinuities in the line which should be skipped: the path will be broken into separate subpaths if some points are undefined. This function is passed to d3.svg.line.defined
Note: crossfilter will sometimes coerce nulls to 0, so you may need to carefully write custom reduce functions to get this to work, depending on your data. See https://github.com/dc-js/dc.js/issues/615#issuecomment-49089248
(Function?)
Function
:
dc.lineChart
:
Always show individual dots for each datapoint.
If options
is falsy, it disables data point rendering.
If no options
are provided, the current options
values are instead returned.
{fillOpacity: Number, strokeOpacity: Number, radius: Number}
:
dc.lineChart
:
chart.renderDataPoints({radius: 2, fillOpacity: 0.8, strokeOpacity: 0.8})
The pie chart implementation is usually used to visualize a small categorical distribution. The pie chart uses keyAccessor to determine the slices, and valueAccessor to calculate the size of each slice relative to the sum of all values. Slices are ordered by ordering which defaults to sorting by key.
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.pieChart
:
// create a pie chart under #chart-container1 element using the default global chart group
var chart1 = dc.pieChart('#chart-container1');
// create a pie chart under #chart-container2 element using chart group A
var chart2 = dc.pieChart('#chart-container2', 'chartGroupA');
Concrete row chart implementation.
Examples:
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.rowChart
:
// create a row chart under #chart-container1 element using the default global chart group
var chart1 = dc.rowChart('#chart-container1');
// create a row chart under #chart-container2 element using chart group A
var chart2 = dc.rowChart('#chart-container2', 'chartGroupA');
Gets or sets the x scale. The x scale can be any d3 quantitive scale
(d3.scale?)
d3.scale
:
dc.rowChart
:
Get the x axis for the row chart instance. Note: not settable for row charts. See the d3 axis object documention for more information.
d3.svg.axis
:
// customize x axis tick format
chart.xAxis().tickFormat(function (v) {return v + '%';});
// customize x axis tick values
chart.xAxis().tickValues([0, 100, 200, 300]);
Get or set the fixed bar height. Default is [false] which will auto-scale bars. For example, if you want to fix the height for a specific number of bars (useful in TopN charts) you could fix height as follows (where count = total number of bars in your TopN and gap is your vertical gap space).
(Boolean | Number)
:
dc.rowChart
:
chart.fixedBarHeight( chartheight - (count + 1) * gap / count);
A scatter plot chart
Examples:
((String | node | d3.selection))
Any valid
d3 single selector
specifying
a dom block element such as a div; or a dom element or d3 selection.
(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.
dc.scatterPlot
:
// create a scatter plot under #chart-container1 element using the default global chart group
var chart1 = dc.scatterPlot('#chart-container1');
// create a scatter plot under #chart-container2 element using chart group A
var chart2 = dc.scatterPlot('#chart-container2', 'chartGroupA');
// create a sub-chart under a composite parent chart
var chart3 = dc.scatterPlot(compositeChart);
Get or set the existence accessor. If a point exists, it is drawn with symbolSize radius and opacity 1; if it does not exist, it is drawn with hiddenSize radius and opacity 0. By default, the existence accessor checks if the reduced value is truthy.
(Function?)
Function
:
dc.scatterPlot
:
// default accessor
chart.existenceAccessor(function (d) { return d.value; });
Clear all filters on all charts within the given chart group. If the chart group is not given then only charts that belong to the default chart group will be reset.
(String?)
Reset zoom level / focus on all charts that belong to the given chart group. If the chart group is not given then only charts that belong to the default chart group will be reset.
(String?)
This function triggers a throttled event function with a specified delay (in milli-seconds). Events that are triggered repetitively due to user interaction such brush dragging might flood the library and invoke more renders than can be executed in time. Using this function to wrap your event function allows the library to smooth out the rendering by throttling events and only responding to the most recent event.
chart.on('renderlet', function(chart) {
// smooth the rendering through event throttling
dc.events.trigger(function(){
// focus some other chart to the range selected by user on this chart
someOtherChart.focus(chart.filter());
});
})
The dc.js filters are functions which are passed into crossfilter to chose which records will be accumulated to produce values for the charts. In the crossfilter model, any filters applied on one dimension will affect all the other dimensions but not that one. dc always applies a filter function to the dimension; the function combines multiple filters and if any of them accept a record, it is filtered in.
These filter constructors are used as appropriate by the various charts to implement brushing. We mention below which chart uses which filter. In some cases, many instances of a filter will be added.
Each of the dc.js filters is an object with the following properties:
isFiltered
- a function that returns true if a value is within the filterfilterType
- a string identifying the filter, here the name of the constructorCurrently these filter objects are also arrays, but this is not a requirement. Custom filters can be used as long as they have the properties above.
dc.baseMixin
is an abstract functional object representing a basic dc
chart object
for all chart and widget implementations. Methods from the dc.baseMixin are inherited
and available on all chart implementations in the dc
library.
(Object)
dc.baseMixin
:
Set or get the height attribute of a chart. The height is applied to the SVGElement generated by the chart when rendered (or re-rendered). If a value is given, then it will be used to calculate the new height and the chart returned for method chaining. The value can either be a numeric, a function, or falsy. If no value is specified then the value of the current height attribute will be returned.
By default, without an explicit height being given, the chart will select the width of its anchor element. If that isn't possible it defaults to 200 (provided by the minHeight property). Setting the value falsy will return the chart to the default behavior.
Number
:
dc.baseMixin
:
// Default height
chart.height(function (element) {
var height = element && element.getBoundingClientRect && element.getBoundingClientRect().height;
return (height && height > chart.minHeight()) ? height : chart.minHeight();
});
chart.height(250); // Set the chart's height to 250px;
chart.height(function(anchor) { return doSomethingWith(anchor); }); // set the chart's height with a function
chart.height(null); // reset the height to the default auto calculation
Set or get the width attribute of a chart.
Number
:
dc.baseMixin
:
// Default width
chart.width(function (element) {
var width = element && element.getBoundingClientRect && element.getBoundingClientRect().width;
return (width && width > chart.minWidth()) ? width : chart.minWidth();
});
mandatory
Set or get the dimension attribute of a chart. In dc
, a dimension can be any valid crossfilter
dimension.
If a value is given, then it will be used as the new dimension. If no value is specified then the current dimension will be returned.
(crossfilter.dimension?)
crossfilter.dimension
:
dc.baseMixin
:
var index = crossfilter([]);
var dimension = index.dimension(dc.pluck('key'));
chart.dimension(dimension);
mandatory
Set or get the dimension attribute of a chart. In dc
, a dimension can be any valid crossfilter
dimension.
If a value is given, then it will be used as the new dimension. If no value is specified then the current dimension will be returned.
(crossfilter.dimension?)
crossfilter.dimension
:
dc.baseMixin
:
var index = crossfilter([]);
var dimension = index.dimension(dc.pluck('key'));
chart.dimension(dimension);
Set the data callback or retrieve the chart's data set. The data callback is passed the chart's group and by default will return group.all. This behavior may be modified to, for instance, return only the top 5 groups.
(Function?)
any
:
dc.baseMixin
:
// Default data function
chart.data(function (group) { return group.all(); });
chart.data(function (group) { return group.top(5); });
mandatory
Set or get the group attribute of a chart. In dc
a group is a
crossfilter group.
Usually the group should be created from the particular dimension associated with the same chart. If a value is
given, then it will be used as the new group.
If no value specified then the current group will be returned.
If name
is specified then it will be used to generate legend label.
(crossfilter.group?)
(String?)
crossfilter.group
:
dc.baseMixin
:
var index = crossfilter([]);
var dimension = index.dimension(dc.pluck('key'));
chart.dimension(dimension);
chart.group(dimension.group(crossfilter.reduceSum()));
mandatory
Set or get the group attribute of a chart. In dc
a group is a
crossfilter group.
Usually the group should be created from the particular dimension associated with the same chart. If a value is
given, then it will be used as the new group.
If no value specified then the current group will be returned.
If name
is specified then it will be used to generate legend label.
(crossfilter.group?)
(String?)
crossfilter.group
:
dc.baseMixin
:
var index = crossfilter([]);
var dimension = index.dimension(dc.pluck('key'));
chart.dimension(dimension);
chart.group(dimension.group(crossfilter.reduceSum()));
Get or set an accessor to order ordinal dimensions. This uses crossfilter.quicksort.by as the sort.
(Function?)
Function
:
dc.baseMixin
:
// Default ordering accessor
_chart.ordering(dc.pluck('key'));
Execute d3 single selection in the chart's scope using the given selector and return the d3 selection.
This function is not chainable since it does not return a chart instance; however the d3 selection result can be chained to d3 function calls.
(any)
d3.selection
:
// Similar to:
d3.select('#chart-id').select(selector);
Execute in scope d3 selectAll using the given selector and return d3 selection result.
This function is not chainable since it does not return a chart instance; however the d3 selection result can be chained to d3 function calls.
(any)
d3.selection
:
// Similar to:
d3.select('#chart-id').selectAll(selector);
Set the root SVGElement to either be an existing chart's root; or any valid d3 single selector specifying a dom block element such as a div; or a dom element or d3 selection. Optionally registers the chart within the chartGroup. This class is called internally on chart initialization, but be called again to relocate the chart. However, it will orphan any previously created SVGElements.
((anchorChart | anchorSelector | anchorNode)?)
(String?)
(String | node | d3.selection)
:
dc.baseMixin
:
Returns the root element where a chart resides. Usually it will be the parent div element where the SVGElement was created. You can also pass in a new root element however this is usually handled by dc internally. Resetting the root element on a chart outside of dc internals may have unexpected consequences.
(HTMLElement?)
HTMLElement
:
dc.baseMixin
:
Returns the top SVGElement for this specific chart. You can also pass in a new SVGElement, however this is usually handled by dc internally. Resetting the SVGElement on a chart outside of dc internals may have unexpected consequences.
((SVGElement | d3.selection)?)
(SVGElement | d3.selection)
:
dc.baseMixin
:
Remove the chart's SVGElements from the dom and recreate the container SVGElement.
SVGElement
:
Set or get the filter printer function. The filter printer function is used to generate human
friendly text for filter value(s) associated with the chart instance. By default dc charts use a
default filter printer printers.filter
that provides simple printing support for both
single value and ranged filters.
(Function
= printers.filter
)
Function
:
dc.baseMixin
:
Turn on optional control elements within the root element. dc currently supports the following html control elements.
dc.baseMixin
:
Turn off optional control elements within the root element.
dc.baseMixin
:
Invoking this method will force the chart to re-render everything from scratch. Generally it should only be used to render the chart for the first time on the page or if you want to make sure everything is redrawn from scratch instead of relying on the default incremental redrawing behaviour.
dc.baseMixin
:
Calling redraw will cause the chart to re-render data changes incrementally. If there is no change in the underlying data dimension then calling this method will have no effect on the chart. Most chart interaction in dc will automatically trigger this method through internal events (in particular dc.redrawAll; therefore, you only need to manually invoke this function if data is manipulated outside of dc's control (for example if data is loaded in the background using crossfilter.add.
dc.baseMixin
:
Gets/sets the commit handler. If the chart has a commit handler, the handler will be called when the chart's filters have changed, in order to send the filter data asynchronously to a server.
Unlike other functions in dc.js, the commit handler is asynchronous. It takes two arguments: a flag indicating whether this is a render (true) or a redraw (false), and a callback to be triggered once the commit is filtered. The callback has the standard node.js continuation signature with error first and result second.
(any)
dc.baseMixin
:
Redraws all charts in the same group as this chart, typically in reaction to a filter change. If the chart has a commitHandler, it will be executed and waited for.
(any)
dc.baseMixin
:
Renders all charts in the same group as this chart. If the chart has a commitHandler, it will be executed and waited for
(any)
dc.baseMixin
:
Set or get the has filter handler. The has filter handler is a function that checks to see if the chart's current filters include a specific filter. Using a custom has filter handler allows you to change the way filters are checked for and replaced.
(Function?)
Function
:
dc.baseMixin
:
// default has filter handler
chart.hasFilterHandler(function (filters, filter) {
if (filter === null || typeof(filter) === 'undefined') {
return filters.length > 0;
}
return filters.some(function (f) {
return filter <= f && filter >= f;
});
});
// custom filter handler (no-op)
chart.hasFilterHandler(function(filters, filter) {
return false;
});
Set or get the remove filter handler. The remove filter handler is a function that removes a filter from the chart's current filters. Using a custom remove filter handler allows you to change how filters are removed or perform additional work when removing a filter, e.g. when using a filter server other than crossfilter.
Any changes should modify the filters
array argument and return that array.
(Function?)
Function
:
dc.baseMixin
:
// default remove filter handler
chart.removeFilterHandler(function (filters, filter) {
for (var i = 0; i < filters.length; i++) {
if (filters[i] <= filter && filters[i] >= filter) {
filters.splice(i, 1);
break;
}
}
return filters;
});
// custom filter handler (no-op)
chart.removeFilterHandler(function(filters, filter) {
return filters;
});
Set or get the add filter handler. The add filter handler is a function that adds a filter to the chart's filter list. Using a custom add filter handler allows you to change the way filters are added or perform additional work when adding a filter, e.g. when using a filter server other than crossfilter.
Any changes should modify the filters
array argument and return that array.
(Function?)
Function
:
dc.baseMixin
:
// default add filter handler
chart.addFilterHandler(function (filters, filter) {
filters.push(filter);
return filters;
});
// custom filter handler (no-op)
chart.addFilterHandler(function(filters, filter) {
return filters;
});
Set or get the reset filter handler. The reset filter handler is a function that resets the chart's filter list by returning a new list. Using a custom reset filter handler allows you to change the way filters are reset, or perform additional work when resetting the filters, e.g. when using a filter server other than crossfilter.
This function should return an array.
(Function?)
dc.baseMixin
:
// default remove filter handler
function (filters) {
return [];
}
// custom filter handler (no-op)
chart.resetFilterHandler(function(filters) {
return filters;
});
Filter the chart by the given value or return the current filter if the input parameter is missing.
If the passed filter is not currently in the chart's filters, it is added to the filters by the
addFilterHandler. If a filter exists already within the chart's
filters, it will be removed by the removeFilterHandler. If
a null
value was passed at the filter, this denotes that the filters should be reset, and is performed
by the resetFilterHandler.
Once the filters array has been updated, the filters are applied to the crossfilter.dimension, using the filterHandler.
(any?)
(any)
dc.baseMixin
:
// filter by a single string
chart.filter('Sunday');
// filter by a single age
chart.filter(18);
This function is passed to d3 as the onClick handler for each chart. The default behavior is to filter on the clicked datum (passed to the callback) and redraw the chart group.
(any)
Set or get the filter handler. The filter handler is a function that performs the filter action on a specific dimension. Using a custom filter handler allows you to perform additional logic before or after filtering.
(Function?)
Function
:
dc.baseMixin
:
// default filter handler
chart.filterHandler(function (dimension, filters) {
dimension.filter(Symbol.for("clear"));
if (filters.length === 0) {
dimension.filter(Symbol.for("clear"));
} else {
dimension.filterFunction(function (d) {
for (var i = 0; i < filters.length; i++) {
var filter = filters[i];
if (filter.isFiltered && filter.isFiltered(d)) {
return true;
} else if (filter <= d && filter >= d) {
return true;
}
}
return false;
});
}
return filters;
});
// custom filter handler
chart.filterHandler(function(dimension, filter){
var newFilter = filter + 10;
dimension.filter(newFilter);
return newFilter; // set the actual filter value to the new value
});
Set or get the key accessor function. The key accessor function is used to retrieve the key value from the crossfilter group. Key values are used differently in different charts, for example keys correspond to slices in a pie chart and x axis positions in a grid coordinate chart.
(Function?)
Function
:
dc.baseMixin
:
// default key accessor
chart.keyAccessor(function(d) { return d.key; });
// custom key accessor for a multi-value crossfilter reduction
chart.keyAccessor(function(p) { return p.value.absGain; });
Set or get the value accessor function. The value accessor function is used to retrieve the value from the crossfilter group. Group values are used differently in different charts, for example values correspond to slice sizes in a pie chart and y axis positions in a grid coordinate chart.
(Function?)
Function
:
dc.baseMixin
:
// default value accessor
chart.valueAccessor(function(d) { return d.value; });
// custom value accessor for a multi-value crossfilter reduction
chart.valueAccessor(function(p) { return p.value.percentageGain; });
Set or get the label function. The chart class will use this function to render labels for each child element in the chart, e.g. slices in a pie chart or bubbles in a bubble chart. Not every chart supports the label function, for example line chart does not use this function at all. By default, enables labels; pass false for the second parameter if this is not desired.
Function
:
dc.baseMixin
:
// default label function just return the key
chart.label(function(d) { return d.key; });
// label function has access to the standard d3 data binding and can get quite complicated
chart.label(function(d) { return d.data.key + '(' + Math.floor(d.data.value / all.value() * 100) + '%)'; });
Set or get the title function. The chart class will use this function to render the SVGElement title (usually interpreted by browser as tooltips) for each child element in the chart, e.g. a slice in a pie chart or a bubble in a bubble chart. Almost every chart supports the title function; however in grid coordinate charts you need to turn off the brush in order to see titles, because otherwise the brush layer will block tooltip triggering.
(Function?)
Function
:
dc.baseMixin
:
// default title function just return the key
chart.title(function(d) { return d.key + ': ' + d.value; });
// title function has access to the standard d3 data binding and can get quite complicated
chart.title(function(p) {
return p.key.getFullYear()
+ '\n'
+ 'Index Gain: ' + numberFormat(p.value.absGain) + '\n'
+ 'Index Gain in Percentage: ' + numberFormat(p.value.percentageGain) + '%\n'
+ 'Fluctuation / Index Ratio: ' + numberFormat(p.value.fluctuationPercentage) + '%';
});
A renderlet is similar to an event listener on rendering event. Multiple renderlets can be added to an individual chart. Each time a chart is rerendered or redrawn the renderlets are invoked right after the chart finishes its transitions, giving you a way to modify the SVGElements. Renderlet functions take the chart instance as the only input parameter and you can use the dc API or use raw d3 to achieve pretty much any effect.
Use on with a 'renderlet' prefix. Generates a random key for the renderlet, which makes it hard to remove.
(Function)
dc.baseMixin
:
// do this instead of .renderlet(function(chart) { ... })
chart.on("renderlet", function(chart){
// mix of dc API and d3 manipulation
chart.select('g.y').style('display', 'none');
// its a closure so you can also access other chart variable available in the closure scope
moveChart.filter(chart.filter());
});
Expire the internal chart cache. dc charts cache some data internally on a per chart basis to speed up rendering and avoid unnecessary calculation; however it might be useful to clear the cache if you have changed state which will affect rendering. For example if you invoke the crossfilter.add function or reset group or dimension after rendering it is a good idea to clear the cache to make sure charts are rendered properly.
dc.baseMixin
:
MAPDC-extension function Destroy all leftover parts of the chart.
dc.baseMixin
:
Attach a dc.legend widget to this chart. The legend widget will automatically draw legend labels based on the color setting and names associated with each group.
(dc.legend?)
dc.legend
:
dc.baseMixin
:
chart.legend(dc.legend().x(400).y(10).itemHeight(13).gap(5))
Set chart options using a configuration object. Each key in the object will cause the method of the same name to be called with the value to set that attribute for the chart.
({})
dc.baseMixin
:
chart.options({dimension: myDimension, group: myGroup});
All dc chart instance supports the following listeners. Supports the following events:
renderlet
- This listener function will be invoked after transitions after redraw and render. Replaces the
deprecated renderlet method.pretransition
- Like .on('renderlet', ...)
but the event is fired before transitions start.preRender
- This listener function will be invoked before chart rendering.postRender
- This listener function will be invoked after chart finish rendering including
all renderlets' logic.preRedraw
- This listener function will be invoked before chart redrawing.postRedraw
- This listener function will be invoked after chart finish redrawing
including all renderlets' logic.filtered
- This listener function will be invoked after a filter is applied, added or removed.zoomed
- This listener function will be invoked after a zoom is triggered.dc.baseMixin
:
.on('renderlet', function(chart, filter){...})
.on('pretransition', function(chart, filter){...})
.on('preRender', function(chart){...})
.on('postRender', function(chart){...})
.on('preRedraw', function(chart){...})
.on('postRedraw', function(chart){...})
.on('filtered', function(chart, filter){...})
.on('zoomed', function(chart, filter){...})
Clear all filters associated with this chart
The same can be achieved by calling chart.filter(Symbol.for("clear")).
(any)
dc.baseMixin
:
Filters chart on click. Determines if filter is inverse and passes that information to _chart.filter. Calls _chart.redrawGroup at the end.
(d3.event)
(any)
dc.baseMixin
:
chart.handleFilterClick(d3.event, filter);
This Mixin provides reusable functionalities for any chart that needs to visualize data using bubbles.
(Object)
dc.bubbleMixin
:
Get or set the bubble radius scale. By default the bubble chart uses d3.scale.linear().domain([0, 100]) as its radius scale.
(d3.scale
= d3.scale.linear().domain([0,100])
)
d3.scale
:
dc.bubbleMixin
:
Get or set the radius value accessor function. If set, the radius value accessor function will be used to retrieve a data value for each bubble. The data retrieved then will be mapped using the r scale to the actual bubble radius. This allows you to encode a data dimension using bubble size.
(Function?)
Function
:
dc.bubbleMixin
:
Cap is a mixin that groups small data elements below a cap into an others grouping for both the Row and Pie Charts.
The top ordered elements in the group up to the cap amount will be kept in the chart, and the rest will be replaced with an others element, with value equal to the sum of the replaced values. The keys of the elements below the cap limit are recorded in order to filter by those keys when the others* element is clicked.
(Object)
dc.capMixin
:
Get or set the grouper function that will perform the insertion of data for the Others slice if the slices cap is specified. If set to a falsy value, no others will be added. By default the grouper function computes the sum of all values below the cap.
(Function?)
Function
:
dc.capMixin
:
// Default others grouper
chart.othersGrouper(function (topRows) {
var topRowsSum = d3.sum(topRows, _chart.valueAccessor()),
allRows = _chart.group().all(),
allRowsSum = d3.sum(allRows, _chart.valueAccessor()),
topKeys = topRows.map(_chart.keyAccessor()),
allKeys = allRows.map(_chart.keyAccessor()),
topSet = d3.set(topKeys),
others = allKeys.filter(function (d) {return !topSet.has(d);});
if (allRowsSum > topRowsSum) {
return topRows.concat([{'others': others, 'key': _othersLabel, 'value': allRowsSum - topRowsSum}]);
}
return topRows;
});
// Custom others grouper
chart.othersGrouper(function (data) {
// compute the value for others, presumably the sum of all values below the cap
var othersSum = yourComputeOthersValueLogic(data)
// the keys are needed to properly filter when the others element is clicked
var othersKeys = yourComputeOthersKeysArrayLogic(data);
// add the others row to the dataset
data.push({'key': 'Others', 'value': othersSum, 'others': othersKeys });
return data;
});
The Color Mixin is an abstract chart functional class providing universal coloring support as a mix-in for any concrete chart implementation.
(Object)
dc.colorMixin
:
Retrieve current color scale or set a new color scale. This methods accepts any function that operates like a d3 scale.
(d3.scale
= d3.scale.category20c()
)
d3.scale
:
dc.colorMixin
:
// alternate categorical scale
chart.colors(d3.scale.category20b());
// ordinal scale
chart.colors(d3.scale.ordinal().range(['red','green','blue']));
// convenience method, the same as above
chart.ordinalColors(['red','green','blue']);
// set a linear scale
chart.linearColors(["#4575b4", "#ffffbf", "#a50026"]);
Convenience method to set the color scale to
d3.scale.ordinal with
range r
.
dc.colorMixin
:
Set or the get color accessor function. This function will be used to map a data point in a crossfilter group to a color value on the color scale. The default function uses the key accessor.
(Function?)
Function
:
dc.colorMixin
:
// default index based color accessor
.colorAccessor(function (d, i){return i;})
// color accessor for a multi-value crossfilter reduction
.colorAccessor(function (d){return d.value.absGain;})
Set the domain by determining the min and max values as retrieved by .colorAccessor over the chart's dataset.
dc.colorMixin
:
Get the color for the datum d and counter i. This is used internally by charts to retrieve a color.
(any?)
any
:
Coordinate Grid is an abstract base chart designed to support a number of coordinate grid based concrete chart types, e.g. bar chart, line chart, and bubble chart.
(Object)
dc.coordinateGridMixin
:
When changing the domain of the x or y scale, it is necessary to tell the chart to recalculate
and redraw the axes. (.rescale()
is called automatically when the x or y scale is replaced
with .x() or .y(), and has
no effect on elastic scales.)
dc.coordinateGridMixin
:
Get or set the range selection chart associated with this instance. Setting the range selection chart using this function will automatically update its selection brush when the current chart zooms in. In return the given range chart will also automatically attach this chart as its focus chart hence zoom in when range brush updates.
(dc.coordinateGridMixin?)
dc.coordinateGridMixin
:
Get or set the root g element. This method is usually used to retrieve the g element in order to overlay custom svg drawing programatically. Caution: The root g element is usually generated by dc.js internals, and resetting it might produce unpredictable result.
(SVGElement?)
SVGElement
:
dc.coordinateGridMixin
:
Set or get mouse zoom capability flag (default: false). When turned on the chart will be zoomable using the mouse wheel. If the range selector chart is attached zooming will also update the range selection brush on the associated range selector chart.
(Boolean
= false
)
Boolean
:
dc.coordinateGridMixin
:
Retrieve the svg group for the chart body.
(SVGElement?)
SVGElement
:
mandatory
Get or set the x scale. The x scale can be any d3 quantitive scale or ordinal scale.
(d3.scale?)
d3.scale
:
dc.coordinateGridMixin
:
// set x to a linear scale
chart.x(d3.scale.linear().domain([-2500, 2500]))
// set x to a time scale to generate histogram
chart.x(d3.time.scale().domain([new Date(1985, 0, 1), new Date(2012, 11, 31)]))
Set or get the xUnits function. The coordinate grid chart uses the xUnits function to calculate the number of data projections on x axis such as the number of bars for a bar chart or the number of dots for a line chart. This function is expected to return a Javascript array of all data points on x axis, or the number of points on the axis. d3 time range functions d3.time.days, d3.time.months, and d3.time.years are all valid xUnits function. dc.js also provides a few units function, see the Utilities section for a list of built-in units functions. The default xUnits function is dc.units.integers.
(Function?)
Function
:
dc.coordinateGridMixin
:
// set x units to count days
chart.xUnits(d3.time.days);
// set x units to count months
chart.xUnits(d3.time.months);
// A custom xUnits function can be used as long as it follows the following interface:
// units in integer
function(start, end, xDomain) {
// simply calculates how many integers in the domain
return Math.abs(end - start);
};
// fixed units
function(start, end, xDomain) {
// be aware using fixed units will disable the focus/zoom ability on the chart
return 1000;
Set or get the x axis used by a particular coordinate grid chart instance. This function is most useful when x axis customization is required. The x axis in dc.js is an instance of a d3 axis object; therefore it supports any valid d3 axis manipulation. Caution: The x axis is usually generated internally by dc; resetting it may cause unexpected results.
(d3.svg.axis
= d3.svg.axis().orient('bottom')
)
d3.svg.axis
:
dc.coordinateGridMixin
:
// customize x axis tick format
chart.xAxis().tickFormat(function(v) {return v + '%';});
// customize x axis tick values
chart.xAxis().tickValues([0, 100, 200, 300]);
Set or get x axis padding for the elastic x axis. The padding will be added to both end of the x axis if elasticX is turned on; otherwise it is ignored.
padding can be an integer or percentage in string (e.g. '10%'). Padding can be applied to number or date x axes. When padding a date axis, an integer represents number of days being padded and a percentage string will be treated the same as an integer.
(Number | String)
:
dc.coordinateGridMixin
:
Returns true if the chart is using ordinal xUnits (dc.units.ordinal, or false otherwise. Most charts behave differently with ordinal data and use the result of this method to trigger the appropriate logic.
Boolean
:
Set or get the x axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.
String
:
Set or get the y axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.
String
:
dc.coordinateGridMixin
:
Get or set the y scale. The y scale is typically automatically determined by the chart implementation.
(d3.scale?)
d3.scale
:
dc.coordinateGridMixin
:
Set or get the y axis used by the coordinate grid chart instance. This function is most useful when y axis customization is required. The y axis in dc.js is simply an instance of a d3 axis object; therefore it supports any valid d3 axis manipulation. Caution: The y axis is usually generated internally by dc; resetting it may cause unexpected results.
(d3.svg.axis
= d3.svg.axis().orient('left')
)
d3.svg.axis
:
dc.coordinateGridMixin
:
// customize y axis tick format
chart.yAxis().tickFormat(function(v) {return v + '%';});
// customize y axis tick values
chart.yAxis().tickValues([0, 100, 200, 300]);
Calculates the minimum x value to display in the chart. Includes xAxisPadding if set.
any
:
Calculates the maximum x value to display in the chart. Includes xAxisPadding if set.
any
:
Calculates the minimum y value to display in the chart. Includes yAxisPadding if set.
any
:
Calculates the maximum y value to display in the chart. Includes yAxisPadding if set.
any
:
Set or get y axis padding for the elastic y axis. The padding will be added to the top of the y axis if elasticY is turned on; otherwise it is ignored.
padding can be an integer or percentage in string (e.g. '10%'). Padding can be applied to number or date axes. When padding a date axis, an integer represents number of days being padded and a percentage string will be treated the same as an integer.
Number
:
dc.coordinateGridMixin
:
Set or get the rounding function used to quantize the selection when brushing is enabled.
(Function?)
Function
:
dc.coordinateGridMixin
:
// set x unit round to by month, this will make sure range selection brush will
// select whole months
chart.round(d3.time.month.round);
Get or set the padding in pixels for the clip path. Once set padding will be applied evenly to the top, left, right, and bottom when the clip path is generated. If set to zero, the clip area will be exactly the chart body area minus the margins.
(Number
= 5
)
Number
:
dc.coordinateGridMixin
:
Zoom this chart to focus on the given range. The given range should be an array containing only
2 elements ([start, end]
) defining a range in the x domain. If the range is not given or set
to null, then the zoom will be reset. _For focus to work elasticX has to be turned off;
otherwise focus will be ignored.
chart.on('renderlet', function(chart) {
// smooth the rendering through event throttling
events.trigger(function(){
// focus some other chart to the range selected by user on this chart
someOtherChart.focus(chart.filter());
});
})
Turn on/off the brush-based range filter. When brushing is on then user can drag the mouse across a chart with a quantitative scale to perform range filtering based on the extent of the brush, or click on the bars of an ordinal bar chart or slices of a pie chart to filter and un-filter them. However turning on the brush filter will disable other interactive elements on the chart such as highlighting, tool tips, and reference lines. Zooming will still be possible if enabled, but only via scrolling (panning will be disabled.)
(Boolean
= true
)
Boolean
:
dc.coordinateGridMixin
:
Coordinate Grid Raster is an abstract base chart designed to support coordinate grid based chart types when the data is backend rendered.
dc.coordinateGridRasterMixin
:
When changing the domain of the x or y scale, it is necessary to tell the chart to recalculate
and redraw the axes. (.rescale()
is called automatically when the x or y scale is replaced
with .x() or .y(), and has
no effect on elastic scales.)
dc.coordinateGridRasterMixin
:
Get or set the root g element. This method is usually used to retrieve the g element in order to overlay custom svg drawing programatically. Caution: The root g element is usually generated by dc.js internals, and resetting it might produce unpredictable result.
(SVGElement?)
SVGElement
:
dc.coordinateGridRasterMixin
:
Set or get the xUnits function. The coordinate grid chart uses the xUnits function to calculate the number of data projections on x axis such as the number of bars for a bar chart or the number of dots for a line chart. This function is expected to return a Javascript array of all data points on x axis, or the number of points on the axis. d3 time range functions d3.time.days, d3.time.months, and d3.time.years are all valid xUnits function. dc.js also provides a few units function, see the Utilities section for a list of built-in units functions. The default xUnits function is units.integers.
(Function?)
Function
:
dc.coordinateGridRasterMixin
:
// set x units to count days
chart.xUnits(d3.time.days)
// set x units to count months
chart.xUnits(d3.time.months)
// A custom xUnits function can be used as long as it follows the following interface:
// units in integer
function(start, end, xDomain) {
// simply calculates how many integers in the domain
return Math.abs(end - start)
}
// fixed units
function(start, end, xDomain) {
// be aware using fixed units will disable the focus/zoom ability on the chart
return 1000
}
Set or get the x axis used by a particular coordinate grid chart instance. This function is most useful when x axis customization is required. The x axis in dc.js is an instance of a d3 axis object; therefore it supports any valid d3 axis manipulation. Caution: The x axis is usually generated internally by dc resetting it may cause unexpected results.
(d3.svg.axis
= d3.svg.axis().orient("bottom")
)
d3.svg.axis
:
dc.coordinateGridRasterMixin
:
// customize x axis tick format
chart.xAxis().tickFormat(function(v) {return v + "%";})
// customize x axis tick values
chart.xAxis().tickValues([0, 100, 200, 300])
Set or get x axis padding for the elastic x axis. The padding will be added to both end of the x axis if elasticX is turned on; otherwise it is ignored.
padding can be an integer or percentage in string (e.g. "10%"). Padding can be applied to number or date x axes. When padding a date axis, an integer represents number of days being padded and a percentage string will be treated the same as an integer.
(Number | String)
:
dc.coordinateGridRasterMixin
:
Returns true if the chart is using ordinal xUnits (units.ordinal, or false otherwise. Most charts behave differently with ordinal data and use the result of this method to trigger the appropriate logic.
Boolean
:
Set or get the x axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.
String
:
Set or get the y axis label. If setting the label, you may optionally include additional padding to the margin to make room for the label. By default the padded is set to 12 to accomodate the text height.
String
:
dc.coordinateGridRasterMixin
:
Set or get the y axis used by the coordinate grid chart instance. This function is most useful when y axis customization is required. The y axis in dc.js is simply an instance of a d3 axis object; therefore it supports any valid d3 axis manipulation. Caution: The y axis is usually generated internally by dc resetting it may cause unexpected results.
(d3.svg.axis
= d3.svg.axis().orient("left")
)
d3.svg.axis
:
dc.coordinateGridRasterMixin
:
// customize y axis tick format
chart.yAxis().tickFormat(function(v) {return v + "%";})
// customize y axis tick values
chart.yAxis().tickValues([0, 100, 200, 300])
Set or get y axis padding for the elastic y axis. The padding will be added to the top of the y axis if elasticY is turned on; otherwise it is ignored.
padding can be an integer or percentage in string (e.g. "10%"). Padding can be applied to number or date axes. When padding a date axis, an integer represents number of days being padded and a percentage string will be treated the same as an integer.
Number
:
dc.coordinateGridRasterMixin
:
Margin is a mixin that provides margin utility functions for both the Row Chart and Coordinate Grid Charts.
(Object)
dc.marginMixin
:
Get or set the margins for a particular coordinate grid chart instance. The margins is stored as an associative Javascript array.
{top: Number, right: Number, left: Number, bottom: Number}
:
dc.marginMixin
:
var leftMargin = chart.margins().left; // 30 by default
chart.margins().left = 50;
leftMargin = chart.margins().left; // now 50
Stack Mixin is an mixin that provides cross-chart support of stackability using d3.layout.stack.
(Object)
dc.stackMixin
:
Stack a new crossfilter group onto this chart with an optional custom value accessor. All stacks in the same chart will share the same key accessor and therefore the same set of keys.
For example, in a stacked bar chart, the bars of each stack will be positioned using the same set of keys on the x axis, while stacked vertically. If name is specified then it will be used to generate the legend label.
Array<{group: crossfilter.group, name: String, accessor: Function}>
:
dc.stackMixin
:
// stack group using default accessor
chart.stack(valueSumGroup)
// stack group using custom accessor
.stack(avgByDayGroup, function(d){return d.value.avgByDay;});
Set or get the title function. Chart class will use this function to render svg title (usually interpreted by browser as tooltips) for each child element in the chart, i.e. a slice in a pie chart or a bubble in a bubble chart. Almost every chart supports title function however in grid coordinate chart you need to turn off brush in order to use title otherwise the brush layer will block tooltip trigger.
If the first argument is a stack name, the title function will get or set the title for that stack. If stackName is not provided, the first stack is implied.
String
:
dc.stackMixin
:
// set a title function on 'first stack'
chart.title('first stack', function(d) { return d.key + ': ' + d.value; });
// get a title function from 'second stack'
var secondTitleFunction = chart.title('second stack');
Set or get the legend text function. The legend widget uses this function to render the legend text on each item. If no function is specified the legend widget will display the names associated with each group.
Default: pluck('name')
// create numbered legend items
chart.legend(dc.legend().legendText(function(d, i) { return i + '. ' + d.name; }))
// create legend displaying group counts
chart.legend(dc.legend().legendText(function(d) { return d.name + ': ' d.data; }))
(any)
END OVERRIDE: dc.bubbleOverlay *
OVERRIDE: dc.heatMap *
Type: number
END OVERRIDE: dc.heatMap *
END OVERRIDE: dc.pieChart *
The default value for .xUnits for the Coordinate Grid Chart and should be used when the x values are a sequence of integers. It is a function that counts the number of integers in the range supplied in its start and end parameters.
Number
:
chart.xUnits(units.integers) // already the default
This argument can be passed to the .xUnits function of the to specify ordinal units for the x axis. Usually this parameter is used in combination with passing d3.scale.ordinal to .x. It just returns the domain passed to it, which for ordinal charts is an array of all values.
Array<String>
:
chart.xUnits(dc.units.ordinal) .x(d3.scale.ordinal())
This function generates an argument for the Coordinate Grid Chart .xUnits function specifying that the x values are floating-point numbers with the given precision. The returned function determines how many values at the given precision will fit into the range supplied in its start and end parameters.
(Number)
Function
:
start-end unit function
// specify values (and ticks) every 0.1 units
chart.xUnits(units.fp.precision(0.1)
// there are 500 units between 0.5 and 1 if the precision is 0.001
var thousandths = units.fp.precision(0.001);
thousandths(0.5, 1.0) // returns 500
TwoDimensionalFilter is a filter which accepts a single two-dimensional value. It is used by the heat map chart to include particular cells as they are clicked. (Rows and columns are filtered by filtering all the cells in the row or column.)
Its filterType
is 'TwoDimensionalFilter'
Array<Number>
:
The RangedTwoDimensionalFilter allows filtering all values which fit within a rectangular region. It is used by the scatter plot to implement rectangular brushing.
It takes two two-dimensional points in the form [[x1,y1],[x2,y2]]
, and normalizes them so that
x1 <= x2
and y1 <- y2
. It then returns a filter which accepts any points which are in the
rectangular range including the lower values but excluding the higher values.
If an array of two values are given to the RangedTwoDimensionalFilter, it interprets the values as
two x coordinates x1
and x2
and returns a filter which accepts any points for which x1 <= x < x2
.
Its filterType
is 'RangedTwoDimensionalFilter'
Array<Array<Number>>
:
Wrapper for binParams in Crossfilter.
(any)
Retrieve the canvas for the chart body.
(SVGElement?)
SVGElement
:
Calculates the distance in meters between two lon/lat coordinates
(number)
Longitude to start from
(number)
Latitude to start from
(number)
Longitude to end at
(number)
Latitude to end at
number
:
Distance in meters from two lon/lat coords
Converts mercator x coordinate to longitude
(number)
X coordinate in mercator projected space
number
:
Longitude
Converts mercator y coordinate to latitude
(number)
Y coordinate in mercator projected space
number
:
Latitude
Converts 2d point in mercator projected space to a lon/lat coordinate
(Point2d)
2d point to store the converted lat/lon coordinate
(Point2d)
2d point in mercator projected space to convert
Point2d
:
Point referred to by the out arg
Converts a longitude coordinate to an x coordinate in mercator projected space
(number)
Longitude
number
:
X coordinate in mercator projected space
Converts a latitude coordinate to a y coordinate in mercator projected space
(any)
(number)
Latitude
number
:
Y coordinate in mercator projected space
Converts 2d lon/lat point to a point in mercator projected space
(Point2d)
2d point to store the converted mercator coordinate
(Point2d)
2d point in lon/lat to convert
Point2d
:
Point referred to by the out arg
Builds the bounds from the incoming poly data
(object)
Object with return data from getResultRowForPixel()
(Number)
Width of the visualization div
(Number)
Height of the visualization div
(any)
(Function)
d3 scale in x dimension from world space to pixel space (i.e. mercatorx-to-pixel)
(Function)
d3 scale in y dimension from world space to pixel space (i.e. mercatory-to-pixel)
(AABox2d)
AABox2d to return
(object)
Margins of the visualization div
Builds the svg path string to use with the d svg attr: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d This function should be called after the getBounds(). The t/s arguments are the transformations to properly place the points underneath a parent SVG group node. That node is what ultimately handles animations and such so we need to transform all the points into local space. t is the translation and s is the scale to transform the points from pixel space to model/object space.