@fundar/data-chart-telling 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [1.6.0] - 2026-11-02
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Every legend section takes `enabled`, on unless set: `legend: { series: { enabled: false } }` leaves the series section off the automatic legend, and `color`, `opacity`, `r` and `symbol` (with a `match`, to pick one of several) do the same for theirs. A section added through `legend.sections` takes it too.
|
|
10
|
+
|
|
5
11
|
## [1.5.0] - 2026-10-31
|
|
6
12
|
|
|
7
13
|
### Changed
|
|
@@ -77,7 +77,8 @@ export declare class LegendState {
|
|
|
77
77
|
* scale, each titled by its field name (see `legend.pretty`);
|
|
78
78
|
* then `extension.sections`. A lone series, with nothing else to tell it
|
|
79
79
|
* from, shows no discrete section; with other sections beside it, the
|
|
80
|
-
* discrete one is titled `legend.seriesTitle`.
|
|
80
|
+
* discrete one is titled `legend.seriesTitle`. A section whose adjustment sets
|
|
81
|
+
* `enabled: false` is left out.
|
|
81
82
|
*/
|
|
82
83
|
sections(extension?: LegendExtension): LegendSection[];
|
|
83
84
|
/**
|
|
@@ -195,7 +195,8 @@ export class LegendState {
|
|
|
195
195
|
* scale, each titled by its field name (see `legend.pretty`);
|
|
196
196
|
* then `extension.sections`. A lone series, with nothing else to tell it
|
|
197
197
|
* from, shows no discrete section; with other sections beside it, the
|
|
198
|
-
* discrete one is titled `legend.seriesTitle`.
|
|
198
|
+
* discrete one is titled `legend.seriesTitle`. A section whose adjustment sets
|
|
199
|
+
* `enabled: false` is left out.
|
|
199
200
|
*/
|
|
200
201
|
sections(extension) {
|
|
201
202
|
const entries = this.entries;
|
|
@@ -286,7 +287,7 @@ export class LegendState {
|
|
|
286
287
|
}
|
|
287
288
|
]
|
|
288
289
|
: [];
|
|
289
|
-
return [...discrete, ...others];
|
|
290
|
+
return [...discrete, ...others].filter((section) => section.enabled !== false);
|
|
290
291
|
}
|
|
291
292
|
/** What `override` changes in the section titled `title`: the entries that match it, in order, merged. */
|
|
292
293
|
static #adjustment(override, title, format) {
|
|
@@ -91,6 +91,7 @@ export type DiscreteInteractiveConfig = {
|
|
|
91
91
|
};
|
|
92
92
|
export type DiscreteLegendSection = {
|
|
93
93
|
type: 'discrete';
|
|
94
|
+
enabled?: boolean;
|
|
94
95
|
title?: string;
|
|
95
96
|
items: LegendItem[];
|
|
96
97
|
columns?: number;
|
|
@@ -112,6 +113,7 @@ export type ContinuousInteractiveConfig = {
|
|
|
112
113
|
};
|
|
113
114
|
export type ContinuousLegendSection = {
|
|
114
115
|
type: 'continuous';
|
|
116
|
+
enabled?: boolean;
|
|
115
117
|
title?: string;
|
|
116
118
|
/** The channel the section reads, which tells apart automatic sections that share a title. */
|
|
117
119
|
channel?: Exclude<LegendChannel, 'series'>;
|
|
@@ -138,6 +140,7 @@ export type ContinuousLegendSection = {
|
|
|
138
140
|
*/
|
|
139
141
|
export type SizeLegendSection = {
|
|
140
142
|
type: 'size';
|
|
143
|
+
enabled?: boolean;
|
|
141
144
|
title?: string;
|
|
142
145
|
/** The channel the section reads, which tells apart automatic sections that share a title. */
|
|
143
146
|
channel?: Exclude<LegendChannel, 'series'>;
|
|
@@ -162,6 +165,7 @@ export type SizeLegendSection = {
|
|
|
162
165
|
*/
|
|
163
166
|
export type SymbolLegendSection = {
|
|
164
167
|
type: 'symbol';
|
|
168
|
+
enabled?: boolean;
|
|
165
169
|
title?: string;
|
|
166
170
|
/** The channel the section reads, which tells apart automatic sections that share a title. */
|
|
167
171
|
channel?: Exclude<LegendChannel, 'series'>;
|
|
@@ -276,7 +280,7 @@ export type LegendOverride<TSection extends {
|
|
|
276
280
|
* takes what both sections share, plus each one's own - what a section lacks
|
|
277
281
|
* is ignored. `interactive` takes either section's options.
|
|
278
282
|
*/
|
|
279
|
-
export type ColorOverride = Omit<ContinuousLegendSection, 'type' | 'min' | 'max' | 'colorMin' | 'colorMax' | 'scheme' | 'pivot' | 'opacity' | 'interactive'> & Pick<DiscreteLegendSection, 'layout' | 'navButton'> & {
|
|
283
|
+
export type ColorOverride = Omit<ContinuousLegendSection, 'type' | 'min' | 'max' | 'colorMin' | 'colorMax' | 'scheme' | 'pivot' | 'opacity' | 'interactive'> & Pick<DiscreteLegendSection, 'layout' | 'navButton' | 'enabled'> & {
|
|
280
284
|
interactive?: ContinuousInteractiveConfig & DiscreteInteractiveConfig;
|
|
281
285
|
/** Adjusts only the continuous section titled so. */
|
|
282
286
|
match?: string;
|
package/docs/legend.md
CHANGED
|
@@ -101,6 +101,15 @@ legend={{
|
|
|
101
101
|
|
|
102
102
|
Each key is the name of the channel (the plot's own prop: `r` for the size section) and adjusts the section that channel draws: any section field except what the plots compute (items, ranges, domains). An entry with `match` adjusts only the section whose title matches; a list of entries adjusts several.
|
|
103
103
|
|
|
104
|
+
### Leaving a section disabled
|
|
105
|
+
|
|
106
|
+
Every section takes `enabled`, on unless set. `enabled: false` leaves that section off the legend, while the others stay:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
legend={{ series: { enabled: false } }} // no series section
|
|
110
|
+
legend={{ color: { match: 'temperature', enabled: false } }} // not that ramp
|
|
111
|
+
```
|
|
112
|
+
|
|
104
113
|
### Turning series off from code
|
|
105
114
|
|
|
106
115
|
`off` turns series off as if the reader had clicked them, without a click: a list of names (each dimmed, to `legend.disabledOpacity`), or a name → opacity or name → action map, where an action is the same `{ mode: 'dim' | 'hide' | 'omit' }` a toggle does. `highlight` is its inverse: it keeps the series it names on and dims all the others. An `off` entry for a series wins over `highlight`.
|