@fundar/data-chart-telling 1.6.1 → 1.7.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.7.0] - 2026-11-02
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `legend.removeItems` leaves automatic items out of the series section by name: a series, or a segment or marker that names itself. A plot that colors its marks through `segments` with a `legend` of their own can list only those, without the one series they come from.
|
|
10
|
+
|
|
5
11
|
## [1.6.1] - 2026-11-02
|
|
6
12
|
|
|
7
13
|
### Fixed
|
|
@@ -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`. `extension.removeItems` leaves
|
|
81
|
+
* automatic items out of it by name. A section whose adjustment sets
|
|
81
82
|
* `enabled: false` is left out.
|
|
82
83
|
*/
|
|
83
84
|
sections(extension?: LegendExtension): LegendSection[];
|
|
@@ -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`. `extension.removeItems` leaves
|
|
199
|
+
* automatic items out of it by name. A section whose adjustment sets
|
|
199
200
|
* `enabled: false` is left out.
|
|
200
201
|
*/
|
|
201
202
|
sections(extension) {
|
|
@@ -203,8 +204,10 @@ export class LegendState {
|
|
|
203
204
|
const cfg = getConfiguration();
|
|
204
205
|
const format = (title) => LegendText.of(title, cfg);
|
|
205
206
|
const adjust = (channel, title) => LegendState.#adjustment(extension?.[channel], title, format);
|
|
207
|
+
const removed = new SvelteSet(extension?.removeItems);
|
|
206
208
|
const items = [];
|
|
207
209
|
const ramps = [];
|
|
210
|
+
let named = false;
|
|
208
211
|
let interactive = false;
|
|
209
212
|
for (const entry of entries) {
|
|
210
213
|
if (entry.type === 'size') {
|
|
@@ -268,12 +271,14 @@ export class LegendState {
|
|
|
268
271
|
}
|
|
269
272
|
ramps.push(section);
|
|
270
273
|
}
|
|
271
|
-
else {
|
|
274
|
+
else if (!removed.has(entry.name)) {
|
|
272
275
|
items.push(LegendState.#itemOf(entry));
|
|
276
|
+
if (entry.type === 'mark')
|
|
277
|
+
named = true;
|
|
273
278
|
}
|
|
274
279
|
}
|
|
275
280
|
items.push(...(extension?.items ?? []));
|
|
276
|
-
|
|
281
|
+
named ||= !!extension?.items?.length;
|
|
277
282
|
const others = [...ramps, ...(extension?.sections ?? [])];
|
|
278
283
|
const title = cfg.legend.seriesTitle.enabled && others.length > 0;
|
|
279
284
|
const discrete = items.length > 1 || (named && items.length > 0)
|
|
@@ -311,6 +311,7 @@ export type LegendExtension = {
|
|
|
311
311
|
*/
|
|
312
312
|
highlight?: string | string[];
|
|
313
313
|
items?: LegendItem[];
|
|
314
|
+
removeItems?: string[];
|
|
314
315
|
sections?: LegendSection[];
|
|
315
316
|
series?: Omit<DiscreteLegendSection, 'type' | 'items'>;
|
|
316
317
|
color?: ColorOverride | ColorOverride[];
|
package/docs/legend.md
CHANGED
|
@@ -110,6 +110,14 @@ legend={{ series: { enabled: false } }} // no series secti
|
|
|
110
110
|
legend={{ color: { match: 'temperature', enabled: false } }} // not that ramp
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
+
### Removing items
|
|
114
|
+
|
|
115
|
+
`removeItems` takes automatic items out of the series section by name - a series, or a segment or marker by the label it names itself with. A name nothing carries is ignored, and items added with `items` stay:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
legend={{ removeItems: ['2017/18'] }}
|
|
119
|
+
```
|
|
120
|
+
|
|
113
121
|
### Turning series off from code
|
|
114
122
|
|
|
115
123
|
`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`.
|