@fundar/data-chart-telling 1.5.0 → 1.6.1

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,18 @@
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.1] - 2026-11-02
6
+
7
+ ### Fixed
8
+
9
+ - A `delta` marker at a `Date` position no longer turns a date `x` axis into a numeric one: it drew its dots, line and label at the position as a number, which svelteplot read next to the dates of the data as a linear scale, and the axis showed milliseconds.
10
+
11
+ ## [1.6.0] - 2026-11-02
12
+
13
+ ### Added
14
+
15
+ - 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.
16
+
5
17
  ## [1.5.0] - 2026-10-31
6
18
 
7
19
  ### 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) {
@@ -26,7 +26,7 @@
26
26
  return clampRange ? Math.max(clampRange[0], Math.min(clampRange[1], v)) : v;
27
27
  }
28
28
 
29
- function pt(fixed: number, varying: number) {
29
+ function pt(fixed: number | Date, varying: number) {
30
30
  return marker.axis === 'x' ? { x: fixed, y: varying } : { x: varying, y: fixed };
31
31
  }
32
32
 
@@ -44,7 +44,7 @@
44
44
  if (!resolved) return null;
45
45
  const fromVis = clamp(resolved.from ?? 0);
46
46
  const toVis = clamp(resolved.to ?? 0);
47
- const at = resolved.at ?? 0;
47
+ const at = marker.at instanceof Date ? new Date(resolved.at ?? 0) : (resolved.at ?? 0);
48
48
  return {
49
49
  fromPt: pt(at, fromVis),
50
50
  toPt: pt(at, toVis),
@@ -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`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Declarative charts, maps and small multiples for Svelte, built on svelteplot.",
5
5
  "license": "MIT",
6
6
  "author": "Ezequiel Puerta",