Hello,
I have a bunch of line graphs that you can sort by drug name. I want 8th grade to be green, 10th grade to be blue, and 12th grade to be red.
Initially I just did this
color: {
domain: ["8th Grade", "10th Grade", "12th Grade"],
range: ["green", "blue", "red"],
legend: true
},
But for some graphs where I only have 12th grade data the legend would show 8th and 10th grade as well. I just wanted to show 12th grade in the legend. Is there an easy way to do this?
So I tried using the filtered data as the domain and I left the range the same.
color: {
domain: radio.grade,
range: ["green", "blue", "red"],
legend: true
},
The problem here is that it makes 12th grade green instead of red. How would I go about keeping my same color scheme even when the domain changes from three grades to just one grade?
Here is the example notebook with both implementations.