-->

Build line chart from user input in dc.js

2019-07-29 13:03发布

问题:

I do not need to group, reduce or sum data as the info I want to chart is in each row. The idea is that the user would select a Year and a StatKey. I would then like to build a line chart based on their selection and the data in the rest of the row. The x-axis would be comprised of first, tenth and last data columns, whilst the y-axis would be 0 - 120. Below is an example of the data:

[
{"Year": "2002", "StatKey": "02437", "First": "108.26", "Tenth": "101.20", 
"Last": "81.73"},
{"Year": "2002", "StatKey": "102", "First": "81.24", "Tenth": "75.59", 
"Last": "50.37"},
{"Year": "2002", "StatKey": "326", "First": "76.47", "Tenth": "57.14", 
"Last": "5.88"},
{"Year": "2003", "StatKey": "02437", "First": "106.03", "Tenth": "101.79", 
"Last": "87.44"},
{"Year": "2003", "StatKey": "102", "First": "77.86", "Tenth": "73.95", 
"Last": "48.02"},
{"Year": "2003", "StatKey": "326", "First": "55.56", "Tenth": "47.50", 
"Last": "11.76"},
{"Year": "2004", "StatKey": "328", "First": "74.24", "Tenth": "68.65", 
"Last": "48.03"},
{"Year": "2004", "StatKey": "103", "First": "73.27", "Tenth": "69.55", 
"Last": "54.68"},
{"Year": "2004", "StatKey": "102", "First": "77.23", "Tenth": "73.13", 
"Last": "49.88"}
]