Legends
Legends visualize color and symbol scales to aid chart interpretation. Legends can also serve as interactors that filter or highlight plot content.
WARNING
At present only discrete legends can be used as interactors. We plan to add support for interval selections over continuous color ramps in the future.
colorLegend
colorLegend(options)
Create a new legend for a plot's color
scale. The following options are supported:
- for: A string indicating the name of the corresponding plot.
- as: A Selection updated by interactions with this legend.
- Additional options that will be passed to the Observable Plot legend method.
If invoked as a directive within a plot definition, the for option should not be used, and the legend will be included as part of the plot itself.
If invoked with the for option in a standalone fashion, returns a Web element containing the legend only.
opacityLegend
opacityLegend(options)
Create a new legend for a plot's opacity
scale. The following options are supported:
- for: A string indicating the name of the corresponding plot.
- as: A Selection updated by interactions with this legend.
- Additional options that will be passed to the Observable Plot legend method.
If invoked as a directive within a plot definition, the for option should not be used, and the legend will be included as part of the plot itself.
If invoked with the for option in a standalone fashion, returns a Web element containing the legend only.
symbolLegend
symbolLegend(options)
Create a new legend for a plot's symbol
scale. The following options are supported:
- for: A string indicating the name of the corresponding plot.
- as: A Selection updated by interactions with this legend.
- Additional options that will be passed to the Observable Plot legend method.
If invoked as a directive within a plot definition, the for option should not be used, and the legend will be included as part of the plot itself.
If invoked with the for option in a standalone fashion, returns a Web element containing the legend only.