bmcarthur
bmcarthur

Reputation: 11

Accessing data from filtered group dc.js

With regards to the Gain/Loss chart on the dc.js homepage how would i access the gain or loss totals that you see when rolling over the chart.

something similar to this i suspect but i just can't get it to work:

y.innerHTML = String(stores.filter(function(d) { return d.gain != 0; }).length);

Upvotes: 0

Views: 474

Answers (1)

Gordon
Gordon

Reputation: 20150

Crossfilter uses "group" objects to aggregate the data, and this is what dc.js is displaying.

In this case, to fetch the data for the "Days by Gain/Loss" pie chart, you can do

gainOrLossChart.group().all()

which returns an array of {key,value} objects:

[{key: "Gain", value: 3628}, {key: "Loss", value: 3096}]

See the Crossfilter API Reference for more information.

Upvotes: 1

Related Questions