So assume that I have a .csv that is formatted like this:
agegroup state gender score1 bin1 score2 bin2
18-25 TX F .15 1 .20 3
18-25 FL F .34 4 .11 7
65+ CA M .72 3 .33 9
46-54 TX M .90 6 .08 1
46-54 TX F .15 1 .11 7
Right now, I can create two bar charts for the columns, bin1 and bin2. I also have a display that will sum up score1 and score2.
However, as I add more scores and bins, I don't want to create more and more bar charts and displays for each column added. So if the new csv looks like this:
agegroup state gender score1 bin1 score2 bin2 score3 bin3 score4 bin4
18-25 TX F .15 1 .20 3 .51 2 .23 6
18-25 FL F .34 4 .11 7 .79 1 .64 4
65+ CA M .72 3 .33 9 .84 7 .55 3
46-54 TX M .90 6 .08 1 .15 2 .47 5
46-54 TX F .15 1 .11 7 .76 8 .09 8
Is there any way I can create a drop-down or something that will tell dc.js which columns (in this case, bin1 through bin4) to create the charts off of and have the display reactive display the correct sums?
You can update the group on the chart and render it.
And working example using two buttons: