I am trying to create a graph showing the top 10 rankings for each week from a set of data. I want to create multiple line graphs tracking objects going from, say, #1 last week to #2 today. This would include many different lines being created on the graph, and them not always being present on the graph.
Currently my data is structured in a JSON file that has each “line” object with a set of properties like so
How can I plot all of the “line” instances in my JSON using the data property? Is there a better way to organize the information? I thought making a bunch of objects with a property for every single possible line would be counterintuitive. Any ideas on how to structure or go about this?
I’m not using notebooks, I’m using observable as a JS library. The example you gave looks good, but is their anyway to write a for loop that will plot all possible iterations of the array?
Yes! When you use stroke it automatically defaults a z channel so it draws multiple lines. Check out the Plot documentation here:
If a stroke (or fill ) channel is specified, the z option defaults to the same, automatically grouping series. For this reason, both stroke and z are typically ordinal or categorical.