1

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"}
]
Gordon
  • 19,811
  • 4
  • 36
  • 74
MichaelB
  • 175
  • 1
  • 10
  • Welcome to StackOverflow! Please provide some code of what you have already tried referring to [How do I ask a good question](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and edit your question accordingly. – Tom M Mar 15 '19 at 13:26
  • IMO @TomM's edits help but otherwise this is a good question and doesn't need clarification or detail. I guess it's subjective what shows enough effort and when code is needed. – Gordon Mar 15 '19 at 14:20
  • With that out of the way..! if you're not doing any filtering, you don't really need dc.js, but sure... dc.js can do this. If you can flatten your data so that you only have one datum per row, e.g. change to `"key": "First"`, `"value": "77.86"`, that will make it easier. Otherwise it's still possible but you will need fake groups similar to the ones [in this answer](https://stackoverflow.com/questions/24737277/dc-js-how-to-create-a-row-chart-from-multiple-columns). – Gordon Mar 15 '19 at 14:27
  • @Gordon well the gist of this question is "how to do x with this data dump?" so far, which is insufficient and too broad to answer in my opinion – Tom M Mar 15 '19 at 15:44
  • 1
    Thanks @TomM. I understand that opinion, however it's actually not obvious what to do in this case, so I think it is unfair to ask people to write code in order to ask the question. It would just be nonsense code in order to prove effort, and won't help the question. IMO it is possible to ask a programming question without offering code. We'll see if the querent reponds to my request for more info. – Gordon Mar 15 '19 at 15:56
  • @Gordon Thank you for your input then. I will consider this when answering d3-related questions in the future – Tom M Mar 15 '19 at 16:02
  • Thanks @TomM. This guidance is probably more relevant to dc.js (and crossfilter) than d3. Which is why I often remove d3.js from the tags since dc.js is way more specific. At least it's not tagged with [javascript]. :-D – Gordon Mar 15 '19 at 16:29
  • @Gordon: Thanks for you your guidance! Huge help indeed. – MichaelB Mar 16 '19 at 07:48
  • @TomM: apologies if I breached any protocol. To be honest, I hadn't gotten that far yet as my experience to date with dc.js had been with flatter data as Gordon pointed out. I couldn't see clear enough to actually start writing code to create the graph. I played around with trying to pivot the data, build multiple dimensions, and a couple of other bits. Trust me, if come for help, I have searched and experimented to no end. Thanks again gents. – MichaelB Mar 16 '19 at 07:48

0 Answers0