@fundar/data-chart-telling 0.0.32 → 0.0.33

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.
@@ -107,18 +107,6 @@
107
107
  }),
108
108
  );
109
109
 
110
- // Last *real* data point per series (skipping any trailing gap row), with
111
- // its palette index for colour.
112
- const lastPoints = $derived(
113
- resolvedSeries
114
- .map((s, idx) => {
115
- const sy = resolveAccessor(s.y);
116
- const lastRow = [...s.data].reverse().find((d) => !isGapValue(sy(d)));
117
- return { series: s, lastRow, seriesIndex: idx };
118
- })
119
- .filter((p): p is { series: Series<TData>; lastRow: TData; seriesIndex: number } => p.lastRow !== undefined),
120
- );
121
-
122
110
  const hover = $derived({
123
111
  active: tooltip != null || hasHoverMarker(markers),
124
112
  points: hoverPoints,
@@ -153,6 +141,21 @@
153
141
  }),
154
142
  );
155
143
 
144
+ const lastPoints = $derived(
145
+ resolvedSeries
146
+ .map((s, idx) => {
147
+ const sy = resolveAccessor(s.y);
148
+ const lastRow = [...s.data].reverse().find((d) => !isGapValue(sy(d)));
149
+ if (lastRow === undefined) return undefined;
150
+ const group = scopedGroups.find((g) => g.name === s.name);
151
+ const matchedSeg = group?.segments.find((seg) => seg.match(lastRow));
152
+ const color =
153
+ matchedSeg?.color ?? group?.segments[0]?.color ?? group?.color ?? paletteColor(idx, cfg.palette);
154
+ return { series: s, lastRow, color };
155
+ })
156
+ .filter((p): p is { series: Series<TData>; lastRow: TData; color: string } => p !== undefined),
157
+ );
158
+
156
159
  // End-of-line labels can grow past the plot's own content box, into its
157
160
  // margin — reserving real space there (rather than padding the domain,
158
161
  // which would falsely imply data exists past the last real point) is
@@ -3,7 +3,6 @@
3
3
  import { Text, usePlot } from 'svelteplot';
4
4
  import { resolveAccessor } from '../utils/accessors';
5
5
  import { getConfiguration } from '../../configuration/config.svelte';
6
- import { paletteColor } from '../../utils/color';
7
6
  import { declutter1D, laneAssignment } from '../utils/declutter';
8
7
  import { disabledFillOverride, disabledStrokeOverride } from '../utils/legendDisabled';
9
8
  import { watchLabelOverflow } from '../utils/labelOverflow.svelte';
@@ -32,7 +31,7 @@
32
31
  onHoverSeries,
33
32
  onHoverEnd,
34
33
  }: {
35
- lastPoints: { series: Series<TData>; lastRow: TData; seriesIndex: number }[];
34
+ lastPoints: { series: Series<TData>; lastRow: TData; color: string }[];
36
35
  values: ValuesStyle | undefined;
37
36
  /** The plot's own pixel size — together with `numericMargins`, the ground truth for its content box (see `bounds()` below for why `usePlot()`'s own scale range can't be trusted for this). */
38
37
  width: number;
@@ -183,10 +182,9 @@
183
182
  </script>
184
183
 
185
184
  <g bind:this={groupEl}>
186
- {#each lastPoints as { series: s, lastRow, seriesIndex } (s.name)}
185
+ {#each lastPoints as { series: s, lastRow, color: seriesColor } (s.name)}
187
186
  {@const xFn = resolveAccessor(s.x)}
188
187
  {@const yFn = resolveAccessor(s.y)}
189
- {@const seriesColor = paletteColor(seriesIndex, cfg.palette)}
190
188
  {@const offset = declutteredOffsets.get(s.name)}
191
189
  {@const extraDy = offset?.inGroup ? offset.extraDy : 0}
192
190
  {@const baseDx = font?.dx ?? defaultDx}
@@ -7,7 +7,7 @@ declare function $$render<TData extends Record<string, unknown>>(): {
7
7
  lastPoints: {
8
8
  series: Series<TData>;
9
9
  lastRow: TData;
10
- seriesIndex: number;
10
+ color: string;
11
11
  }[];
12
12
  values: ValuesStyle | undefined;
13
13
  /** The plot's own pixel size — together with `numericMargins`, the ground truth for its content box (see `bounds()` below for why `usePlot()`'s own scale range can't be trusted for this). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"