this is the first time in the notebook that the key API is revealed: "legend: true" and it is burried in the middle of a lot of code. Perhaps we could put a much simpler example at the very start to show how easy it is to add a legend? Without that I fear many people will be intimidated by the custom legend code (presumably many are already motivated not to write custom code already).
I try to keep a consistent order in Plot.plot calls, always putting the marks option last. The order I use is:
1. Layout options.
2. Scale definitions.
3. Facet definition.
4. Marks.
Also, I prefer no spaces inside curly braces.
It feels strange to lead-off this notebook with custom legends. My expectation is that this notebook should be about Plot’s built-in legends. I recommend we remove this section and jump straight in to Plot legends. (We can always link to Plot: Scales for more on scales.)
I removed the resin identification codes (https://en.wikipedia.org/wiki/Resin_identification_code) since I found them distracting and also they remind me of how the plastic industry shifts the burden of recycling to the consumer rather than the producer.
Not at the moment. You can already apply arbitrary styles, but I doubt that rotating the whole legend — with style: {transform: "rotate(90deg)"} — will be satisfying. (Please don't hesitate to open an issue or a pull-request on the github repo.)
This seems like a bug to me: if you set a label on the scale explicitly within the chart, that label will be shown in the legend below. We only ignore the label if it was set implicitly from the channels, but that feels like an oversight.