LegendMixin
Auto-generated @jbrowse/mobx-state-tree API for the current JBrowse release — see pluggable elements for concepts. Built into JBrowse core. View source.
#crossCuttingMixin The legend, whole. A display declares the color scales it paints with (colorScales, a getter hook) and the mixin derives the key from them (legendSpec, through legendSpecOf), keeps the showLegend slot's getter and setter, dismisses sections one at a time (dismissLegendSection, undone by re-showing the legend), answers whether there is a key to offer (hasLegendKey) and whether the export parks it beside the plot (svgLegendWidth). DisplayChrome draws the on-screen key and renderDisplaySvg the exported one, so a display places neither
A key derived from the scales the painter resolves colors through lists only colors that were painted. A legend hand-built from a second copy of the rules can list a color nothing painted. The config slot stays per display: the composing schemas default it differently (a Hi-C color scale is off by default, a variant genotype key on) and describe different legends, so this mixin supplies the accessors over the slot and never the slot.
Volatiles
| Member | Description |
|---|---|
dismissedLegendSectionsdismissedLegendSections: [] as string[] | Ids of the scales whose section the reader closed on its own; cleared when the whole legend is shown again. Volatile where showLegend is config: which sections a reader collapsed in one sitting is not how the track is configured. |
Getters
| Member | Description |
|---|---|
showLegendboolean | Whether the legend is drawn. |
colorScalesColorScale[] | Overridable hook (default none): the color scales this display paints with, in the order the key lists them. Each becomes one section of the legend, so a display with two vocabularies (genotype colors and sample groups) declares two. |
legendTopnumber | Overridable hook (default 0): px the on-screen key is pushed down from its own inset. A display that already draws a control of its own in that corner — Hi-C's resolution box — answers that control's height; the chrome adds its own axis captions on top. The export draws no controls, so it does not read this. |
legendSpecLegendSpec | The key, derived from colorScales less the sections the reader dismissed. DisplayChrome renders it on screen and renderDisplaySvg flattens it for the export, so the two describe one set of colors. |
hasLegendKeyboolean | Whether the display has a key at all. The "Show legend" row is offered only when it does. Overridable for a display whose key is only waiting for data: a scale that stays empty until a region lands must not remove the toggle in the meantime. |
Methods
| Member | Description |
|---|---|
svgLegendWidth() => number | Overridable hook (default 0): the width the LGV export reserves beside the plot for this legend. A display whose plot fills its band — the contact matrix, the LD triangle — answers svgLegendGutterWidth(self) so the key does not cover it. |
Actions
| Member | Description |
|---|---|
setShowLegend(arg: boolean) => void | Writes the slot, and showing the legend again restores the sections closed inside it. |
dismissLegendSection(id: string) => void | Close one section of the legend, leaving the others up. |