Thanks for pointing out the notebook visualizer and for explaining the dependency.
I added the ability to change the color scheme, but in doing so the legend (which referenced prevScale) caused
chart to regenerate.
In order to avoid this, I added a placeholder scale to the call to add the legend in the
[15, 25, 35, 45],
['#fef0d9', '#fdcc8a', '#fc8d59', '#e34a33', '#b30000']
title: `Adult Prevalence of Obese (%)`,
and then selected and updated the relevant rectangles in the legend in a different cell:
.attr("fill", (d, i) => colorSchemeMap.get(colorScheme)[i]);
Is this the “right” way to perform this transition, or is there something easier that I am missing?
I also had a reference to
classification in the initial version of the legend which would update the title with the classification being displayed. However this also caused
chart to regenerate and so I added a placeholder legend title and created an update to it outside of
chart. However, to select the
<text></text> selector(?) that contains the text of the legend title, I had to resort to noticing that it was the last
<text> element in the
<g class="legend"> element.
Is this the recommended way to do things, or is there a better way to accomplish this?