@fundar/data-chart-telling 0.0.49 → 0.0.51

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.
Files changed (40) hide show
  1. package/dist/configuration/config.svelte.js +7 -2
  2. package/dist/configuration/themes/index.d.ts +12 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +1 -1
  5. package/dist/layout/legend/DiscreteBadgeItem.svelte +21 -8
  6. package/dist/layout/legend/DiscreteBadgeItem.svelte.d.ts +1 -0
  7. package/dist/layout/legend/DiscreteSection.svelte +22 -9
  8. package/dist/layout/legend/DiscreteSection.svelte.d.ts +2 -1
  9. package/dist/layout/legend/LegendLayout.svelte +7 -2
  10. package/dist/layout/scales/ScalesLayout.svelte +87 -10
  11. package/dist/layout/scales/buildScale.d.ts +18 -1
  12. package/dist/layout/scales/buildScale.js +49 -2
  13. package/dist/layout/scales/niceDomain.d.ts +6 -0
  14. package/dist/layout/scales/niceDomain.js +34 -0
  15. package/dist/layout/tooltip/controller.svelte.js +23 -11
  16. package/dist/layout/tooltip/utils.js +3 -0
  17. package/dist/markers/BarMarker.svelte +145 -84
  18. package/dist/markers/HoverMarker.svelte +41 -1
  19. package/dist/markers/HoverMarker.svelte.d.ts +7 -1
  20. package/dist/plots/bar/Plot.svelte +46 -20
  21. package/dist/plots/bar/buildBarMarkers.d.ts +4 -14
  22. package/dist/plots/bar/buildBarMarkers.js +73 -53
  23. package/dist/plots/bar/hoverPoints.d.ts +1 -1
  24. package/dist/plots/bar/hoverPoints.js +2 -3
  25. package/dist/plots/bar/layout.svelte.d.ts +4 -0
  26. package/dist/plots/bar/layout.svelte.js +62 -17
  27. package/dist/plots/line/Plot.svelte +29 -14
  28. package/dist/plots/line/buildLineMarkers.d.ts +1 -0
  29. package/dist/plots/line/buildLineMarkers.js +3 -4
  30. package/dist/plots/pyramid/Plot.svelte +10 -6
  31. package/dist/plots/scatter/Plot.svelte +25 -11
  32. package/dist/plots/scatter/buildScatterMarkers.d.ts +1 -0
  33. package/dist/plots/scatter/buildScatterMarkers.js +3 -4
  34. package/dist/plots/utils/legendDisabled.d.ts +13 -1
  35. package/dist/plots/utils/legendDisabled.js +27 -0
  36. package/dist/types/configuration/styling.d.ts +12 -2
  37. package/dist/types/layout/legend.d.ts +15 -10
  38. package/dist/types/layout/tooltip.d.ts +2 -1
  39. package/dist/types/markers/common.d.ts +14 -2
  40. package/package.json +1 -1
@@ -1,3 +1,30 @@
1
+ /** Resolves a {@link LegendDisabledAction} into the style a mark should render with — `'omit'` resolves to fully transparent. */
2
+ export function resolveDisabledStyle(action, fallbackOpacity) {
3
+ if (!action)
4
+ return undefined;
5
+ if (action.mode === 'omit')
6
+ return { opacity: 0 };
7
+ return action.style ?? { opacity: fallbackOpacity };
8
+ }
9
+ /** Drops series toggled off with `disabled: { mode: 'omit' }` from a series list. */
10
+ export function omitDisabledSeries(series, legendInteraction) {
11
+ if (!legendInteraction)
12
+ return series;
13
+ return series.filter((s) => legendInteraction.disabledSeries.get(s.name)?.mode !== 'omit');
14
+ }
15
+ /** Builds a per-series-name → palette index from the full series list, before {@link omitDisabledSeries} filters it. */
16
+ export function buildSeriesColorIndex(series) {
17
+ const index = new Map();
18
+ series.forEach((s, i) => index.set(s.name, i));
19
+ return index;
20
+ }
21
+ /** Resolves the disabled style for a series by name: legend-off state, falling back to hover-isolate dim. */
22
+ export function resolveEffectiveDisabledStyle(name, legendInteraction, disabledOpacity, hoverIsolate, hoverIsolatedSeries) {
23
+ return (resolveDisabledStyle(legendInteraction?.disabledSeries.get(name), disabledOpacity) ??
24
+ (hoverIsolate && hoverIsolatedSeries && hoverIsolatedSeries !== name
25
+ ? { opacity: disabledOpacity }
26
+ : undefined));
27
+ }
1
28
  /**
2
29
  * The three per-mark override layers a legend "disabled" state can apply,
3
30
  * derived once from a {@link LegendDisabledStyle}. Each is `undefined` when
@@ -37,7 +37,7 @@ export type ChartConfig = {
37
37
  gap: string;
38
38
  /** swatch square size */
39
39
  swatchSize: string;
40
- /** Fallback opacity for a legend-disabled series/value when a section doesn't set its own `disabledStyle`. */
40
+ /** Fallback opacity for a legend-disabled series/value when a section doesn't set its own style. */
41
41
  disabledOpacity: number;
42
42
  /** Prev/next arrows shown when a `layout: { type: 'horizontal' }` discrete section overflows `maxRows`. */
43
43
  navButton: {
@@ -144,6 +144,12 @@ export type ChartConfig = {
144
144
  bar: {
145
145
  /** Default gap-fill styling (`BarPlot`'s `styles.gaps`) — the fallback merged under whatever a gap zone's own `style` sets. */
146
146
  gap: AreaStyle;
147
+ /** Fallback `scales.z.seriesPadding` (0–1) for 'grouped' series layout, when a plot doesn't set its own. */
148
+ seriesPadding: number;
149
+ /** Fallback gap (0–1) *between* category groups on BarPlot's own category axis, when a plot doesn't set its own `scales.x/y.paddingInner`. */
150
+ paddingInner: number;
151
+ /** Fallback gap (0–1) before the first and after the last category group on BarPlot's own category axis, when a plot doesn't set its own `scales.x/y.paddingOuter`. */
152
+ paddingOuter: number;
147
153
  };
148
154
  /** Default pyramid-bar styling. */
149
155
  pyramid: {
@@ -160,7 +166,11 @@ export type ChartConfig = {
160
166
  activeColor: string;
161
167
  thickness: number;
162
168
  };
163
- /** In-SVG hover highlight: crosshair rule, dot + value label, and geo feature restyle. */
169
+ /**
170
+ * In-SVG hover highlight: crosshair rule, dot + value label, and the area
171
+ * highlight — a restyled feature on `GeoPlot`, or an `areaX`/`areaY` band
172
+ * on an axis-based plot's band scale.
173
+ */
164
174
  hover: {
165
175
  rule: StrokeStyle;
166
176
  dot: DotStyle;
@@ -17,6 +17,13 @@ export type LegendDisabledStyle = {
17
17
  fill?: string;
18
18
  fillOpacity?: number;
19
19
  };
20
+ /** What a legend toggle does to a series once it's off: `'style'` dims it in place, `'omit'` removes it from the plot entirely. */
21
+ export type LegendDisabledAction = {
22
+ mode: 'style';
23
+ style?: LegendDisabledStyle;
24
+ } | {
25
+ mode: 'omit';
26
+ };
20
27
  export type LegendItem = {
21
28
  name: string;
22
29
  label?: string;
@@ -28,11 +35,9 @@ export type LegendItem = {
28
35
  disabled?: boolean;
29
36
  };
30
37
  /**
31
- * How a discrete section's items flow. `'vertical'` (the default) stacks them
32
- * in a `columns`-wide grid, as it always has. `'horizontal'` flows them left
33
- * to right, wrapping to new rows as needed — and once wrapped rows exceed
34
- * `maxRows` (default 1), the section paginates instead of growing taller,
35
- * surfacing prev/next arrows to page through the rest.
38
+ * How a discrete section's items flow. `'vertical'` stacks them in a
39
+ * `columns`-wide grid; `'horizontal'` flows them left to right, paginating
40
+ * past `maxRows` (default 1) with prev/next arrows.
36
41
  */
37
42
  export type LegendItemsLayout = {
38
43
  type: 'vertical';
@@ -75,8 +80,8 @@ export type DiscreteInteractiveConfig = {
75
80
  enabled?: boolean;
76
81
  /** Item look while `enabled`. Defaults to `'badge'`. */
77
82
  legendStyle?: LegendInteractiveStyle;
78
- /** Style applied to a toggled-off item. Defaults to `{ opacity: cfg.legend.disabledOpacity }`. */
79
- disabledStyle?: LegendDisabledStyle;
83
+ /** What happens to a toggled-off item. Defaults to `{ mode: 'style' }`. */
84
+ disabled?: LegendDisabledAction;
80
85
  /** Shows the symbol icon inside a `'badge'` pill. Defaults to `true`; ignored by `'basic'`, which always shows it. */
81
86
  showIcon?: boolean;
82
87
  };
@@ -85,7 +90,7 @@ export type DiscreteLegendSection = {
85
90
  title?: string;
86
91
  items: LegendItem[];
87
92
  columns?: number;
88
- /** Item flow direction. Defaults to `{ type: 'vertical' }` (unchanged prior behaviour). */
93
+ /** Item flow direction. Defaults to horizontal for a lone section, vertical once there's more than one. */
89
94
  layout?: LegendItemsLayout;
90
95
  interactive?: DiscreteInteractiveConfig;
91
96
  navButton?: LegendNavSnippet;
@@ -129,8 +134,8 @@ export type LegendSection = DiscreteLegendSection | ContinuousLegendSection;
129
134
  * own private store via `createLegendInteraction`.
130
135
  */
131
136
  export type LegendInteractionStore = {
132
- /** Legend item name → resolved style to apply. Presence in the map means "disabled". */
133
- disabledSeries: SvelteMap<string, LegendDisabledStyle>;
137
+ /** Legend item name → action to apply. Presence in the map means "disabled". */
138
+ disabledSeries: SvelteMap<string, LegendDisabledAction>;
134
139
  /**
135
140
  * The active drag state of the (first) interactive continuous section, or
136
141
  * `null` when none is interactive or the user hasn't narrowed it yet (full
@@ -5,8 +5,9 @@ import type { AxisValue } from './scales';
5
5
  * - `'x'` all points sharing the hovered x (default for line / bar).
6
6
  * - `'y'` all points sharing the hovered y (default for pyramid).
7
7
  * - `'punctual'` exact XY match — one cell at a time (default for heatmap).
8
+ * - `'series'` all points sharing the hovered series, regardless of x/y.
8
9
  */
9
- export type HoverStrategy = 'x' | 'y' | 'punctual';
10
+ export type HoverStrategy = 'x' | 'y' | 'punctual' | 'series';
10
11
  /**
11
12
  * Preferred horizontal placement of the floating tooltip relative to the
12
13
  * cursor: `'right'`/`'left'` offset it clear of the cursor (so it never
@@ -22,9 +22,18 @@ export type HoverMarkerConfig = {
22
22
  sync?: boolean;
23
23
  ruleX?: boolean;
24
24
  ruleY?: boolean;
25
+ /**
26
+ * Thickened area in place of a thin crosshair — sized to the hovered
27
+ * bar/cell's own width, spanning the full opposite axis. Off by default;
28
+ * meaningful only on a band (categorical) scale, so it renders nothing on
29
+ * a line/scatter plot's continuous axis.
30
+ */
31
+ areaX?: boolean;
32
+ areaY?: boolean;
25
33
  showLabels?: boolean;
26
34
  format?: (point: HoverDisplayPoint) => string;
27
35
  ruleStyle?: StrokeStyle;
36
+ areaStyle?: AreaStyle;
28
37
  dotStyle?: DotStyle;
29
38
  fontStyle?: FontStyle;
30
39
  };
@@ -40,11 +49,14 @@ export type LineMarkerConfig = {
40
49
  * A single bar mark. `role: 'segment'` is a visible bar
41
50
  * (`x`/`y`/`x1`/`x2`/`y1`/`y2` map to svelteplot's `<BarX>`/`<BarY>` per
42
51
  * `isHorizontal`); `role: 'hitArea'` is an invisible per-category hit region
43
- * for hover, resolved against the live scale at render time.
52
+ * for hover, resolved against the live scale at render time; `role:
53
+ * 'highlight'` is `HoverMarkerConfig`'s `areaX`/`areaY` highlight — a
54
+ * visible, non-interactive rect centered on `category`, spanning the full
55
+ * opposite axis, sized to the category band's own width plus 2px.
44
56
  */
45
57
  export type BarMarkerConfig = {
46
58
  type: 'bar';
47
- role: 'segment' | 'hitArea';
59
+ role: 'segment' | 'hitArea' | 'highlight';
48
60
  isHorizontal: boolean;
49
61
  data: Record<string, unknown>[];
50
62
  x?: (d: any) => AxisValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"