@fundar/data-chart-telling 0.0.6 → 0.0.8
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/dist/charts/Chart.svelte +1 -0
- package/dist/layout/plot/PlotLayout.svelte +1 -0
- package/dist/layout/timeline/TimelineLayout.svelte +18 -13
- package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -0
- package/dist/plots/bar/Plot.svelte +2 -1
- package/dist/plots/line/Plot.svelte +2 -1
- package/dist/plots/markers/HoverMarker.svelte +26 -11
- package/dist/plots/markers/HoverMarker.svelte.d.ts +1 -0
- package/dist/plots/pyramid/Plot.svelte +1 -0
- package/dist/types/charts/common.d.ts +1 -0
- package/dist/types/layout/tooltip.d.ts +2 -0
- package/dist/types/plots/markers.d.ts +3 -1
- package/package.json +1 -1
package/dist/charts/Chart.svelte
CHANGED
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
progress={timeline.progress}
|
|
109
109
|
values={timeline.values}
|
|
110
110
|
orientation={timeline.orientation}
|
|
111
|
+
show={timeline.show}
|
|
111
112
|
thickness={timeline.thickness ?? cfg.timeline.thickness}
|
|
112
113
|
filterMode={timeline.filterMode}
|
|
113
114
|
interpolate={typeof timeline.interpolate === 'object' ? timeline.interpolate : undefined}
|
|
@@ -210,6 +210,7 @@
|
|
|
210
210
|
ruleX={showRuleX ? ctrl.ruleX : null}
|
|
211
211
|
ruleY={showRuleY ? ctrl.ruleY : null}
|
|
212
212
|
showLabels={unscopedHoverMarker.showLabels ?? showHoverLabels}
|
|
213
|
+
format={unscopedHoverMarker.format}
|
|
213
214
|
ruleStyle={unscopedHoverMarker.ruleStyle}
|
|
214
215
|
dotStyle={unscopedHoverMarker.dotStyle}
|
|
215
216
|
fontStyle={unscopedHoverMarker.fontStyle}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
progress,
|
|
23
23
|
values,
|
|
24
24
|
orientation = 'vertical',
|
|
25
|
+
show = true,
|
|
25
26
|
thickness = 60,
|
|
26
27
|
filterMode = 'exact',
|
|
27
28
|
interpolate,
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
progress: number;
|
|
35
36
|
values?: TimeValue[];
|
|
36
37
|
orientation?: Orientation;
|
|
38
|
+
show?: boolean;
|
|
37
39
|
thickness?: number;
|
|
38
40
|
filterMode?: 'exact' | 'upTo';
|
|
39
41
|
interpolate?: TimelineInterpolation<TRow>;
|
|
@@ -126,32 +128,37 @@
|
|
|
126
128
|
});
|
|
127
129
|
|
|
128
130
|
const isVertical = $derived(orientation === 'vertical');
|
|
129
|
-
const gap = 12;
|
|
131
|
+
const gap = $derived(show ? 12 : 0);
|
|
132
|
+
const effectiveThickness = $derived(show ? thickness : 0);
|
|
130
133
|
const innerWidth = $derived(
|
|
131
|
-
Math.max(0, isVertical ? width -
|
|
134
|
+
Math.max(0, isVertical ? width - effectiveThickness - gap : width),
|
|
132
135
|
);
|
|
133
136
|
const innerHeight = $derived(
|
|
134
|
-
Math.max(0, isVertical ? height : height -
|
|
137
|
+
Math.max(0, isVertical ? height : height - effectiveThickness - gap),
|
|
135
138
|
);
|
|
136
139
|
</script>
|
|
137
140
|
|
|
138
141
|
{#if isVertical}
|
|
139
|
-
<div class="dct-timeline dct-timeline--vertical" style:width="{width}px" style:height="{height}px">
|
|
142
|
+
<div class="dct-timeline dct-timeline--vertical" style:width="{width}px" style:height="{height}px" style:gap="{gap}px">
|
|
140
143
|
<div class="dct-timeline__plot">
|
|
141
144
|
{@render child({ selectedValue, data: filtered, width: innerWidth, height: innerHeight })}
|
|
142
145
|
</div>
|
|
143
|
-
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
+
{#if show}
|
|
147
|
+
<div class="dct-timeline__gutter" style:width="{thickness}px">
|
|
148
|
+
<Timeline currentValue={selectedValue} values={steps} orientation="vertical" width={thickness} height={innerHeight} />
|
|
149
|
+
</div>
|
|
150
|
+
{/if}
|
|
146
151
|
</div>
|
|
147
152
|
{:else}
|
|
148
|
-
<div class="dct-timeline dct-timeline--horizontal" style:width="{width}px" style:height="{height}px">
|
|
153
|
+
<div class="dct-timeline dct-timeline--horizontal" style:width="{width}px" style:height="{height}px" style:gap="{gap}px">
|
|
149
154
|
<div class="dct-timeline__plot">
|
|
150
155
|
{@render child({ selectedValue, data: filtered, width: innerWidth, height: innerHeight })}
|
|
151
156
|
</div>
|
|
152
|
-
|
|
153
|
-
<
|
|
154
|
-
|
|
157
|
+
{#if show}
|
|
158
|
+
<div class="dct-timeline__gutter" style:height="{thickness}px">
|
|
159
|
+
<Timeline currentValue={selectedValue} values={steps} orientation="horizontal" width={innerWidth} height={thickness} />
|
|
160
|
+
</div>
|
|
161
|
+
{/if}
|
|
155
162
|
</div>
|
|
156
163
|
{/if}
|
|
157
164
|
|
|
@@ -161,11 +168,9 @@
|
|
|
161
168
|
}
|
|
162
169
|
.dct-timeline--vertical {
|
|
163
170
|
flex-direction: row;
|
|
164
|
-
gap: 12px;
|
|
165
171
|
}
|
|
166
172
|
.dct-timeline--horizontal {
|
|
167
173
|
flex-direction: column;
|
|
168
|
-
gap: 12px;
|
|
169
174
|
}
|
|
170
175
|
.dct-timeline__plot {
|
|
171
176
|
flex: 1 1 auto;
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
const yAcc = $derived(resolveAccessor(resolvedSeries[0]?.y ?? ((d: TData) => d)));
|
|
64
64
|
const flat = $derived(resolvedSeries.flatMap((s) => s.data));
|
|
65
65
|
const hoverPoints = $derived(
|
|
66
|
-
resolvedSeries.flatMap((s) => {
|
|
66
|
+
resolvedSeries.flatMap((s, idx) => {
|
|
67
67
|
const sx = resolveAccessor(s.x);
|
|
68
68
|
const sy = resolveAccessor(s.y);
|
|
69
69
|
return s.data.map((d) => ({
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
row: d,
|
|
73
73
|
label: String(sy(d)),
|
|
74
74
|
series: s.name,
|
|
75
|
+
color: paletteColor(idx, cfg.palette),
|
|
75
76
|
}));
|
|
76
77
|
}),
|
|
77
78
|
);
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
const yAcc = $derived(resolveAccessor(resolvedSeries[0]?.y ?? ((d: TData) => d)));
|
|
63
63
|
const flat = $derived(resolvedSeries.flatMap((s) => s.data));
|
|
64
64
|
const hoverPoints = $derived(
|
|
65
|
-
resolvedSeries.flatMap((s) => {
|
|
65
|
+
resolvedSeries.flatMap((s, idx) => {
|
|
66
66
|
const sx = resolveAccessor(s.x);
|
|
67
67
|
const sy = resolveAccessor(s.y);
|
|
68
68
|
return s.data.map((d) => ({
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
row: d,
|
|
72
72
|
label: String(sy(d)),
|
|
73
73
|
series: s.name,
|
|
74
|
+
color: paletteColor(idx, cfg.palette),
|
|
74
75
|
}));
|
|
75
76
|
}),
|
|
76
77
|
);
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
ruleX?: AxisValue | null;
|
|
20
20
|
ruleY?: AxisValue | null;
|
|
21
21
|
showLabels?: boolean;
|
|
22
|
+
format?: (point: HoverDisplayPoint) => string;
|
|
22
23
|
ruleStyle?: StrokeStyle;
|
|
23
24
|
dotStyle?: DotStyle;
|
|
24
25
|
fontStyle?: FontStyle;
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
ruleX = null,
|
|
30
31
|
ruleY = null,
|
|
31
32
|
showLabels = true,
|
|
33
|
+
format,
|
|
32
34
|
ruleStyle,
|
|
33
35
|
dotStyle,
|
|
34
36
|
fontStyle,
|
|
@@ -60,19 +62,32 @@
|
|
|
60
62
|
{/if}
|
|
61
63
|
|
|
62
64
|
{#if data.length > 0}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
y={(d) => d.y}
|
|
67
|
-
style={{ ...cfg.hover.dot, ...dotStyle }}
|
|
68
|
-
/>
|
|
69
|
-
{#if showLabels}
|
|
70
|
-
<TextMarker
|
|
71
|
-
{data}
|
|
65
|
+
{#each data as point (point.series ?? `${point.x}_${point.y}`)}
|
|
66
|
+
<DotMarker
|
|
67
|
+
data={[point]}
|
|
72
68
|
x={(d) => d.x}
|
|
73
69
|
y={(d) => d.y}
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
style={{
|
|
71
|
+
...cfg.hover.dot,
|
|
72
|
+
...dotStyle,
|
|
73
|
+
...(dotStyle?.dotFill === 'currentColor' && point.color ? { dotFill: point.color } : {}),
|
|
74
|
+
...(dotStyle?.dotStroke === 'currentColor' && point.color ? { dotStroke: point.color } : {}),
|
|
75
|
+
}}
|
|
76
76
|
/>
|
|
77
|
+
{/each}
|
|
78
|
+
{#if showLabels}
|
|
79
|
+
{#each data as point (point.series ?? `${point.x}_${point.y}`)}
|
|
80
|
+
<TextMarker
|
|
81
|
+
data={[point]}
|
|
82
|
+
x={(d) => d.x}
|
|
83
|
+
y={(d) => d.y}
|
|
84
|
+
text={(d) => format ? format(d) : (d.label ?? '')}
|
|
85
|
+
style={{
|
|
86
|
+
...cfg.hover.font,
|
|
87
|
+
...fontStyle,
|
|
88
|
+
...(fontStyle?.fill === 'currentColor' && point.color ? { fill: point.color } : {}),
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
{/each}
|
|
77
92
|
{/if}
|
|
78
93
|
{/if}
|
|
@@ -13,6 +13,7 @@ interface Props extends MarkerProps<HoverDisplayPoint> {
|
|
|
13
13
|
ruleX?: AxisValue | null;
|
|
14
14
|
ruleY?: AxisValue | null;
|
|
15
15
|
showLabels?: boolean;
|
|
16
|
+
format?: (point: HoverDisplayPoint) => string;
|
|
16
17
|
ruleStyle?: StrokeStyle;
|
|
17
18
|
dotStyle?: DotStyle;
|
|
18
19
|
fontStyle?: FontStyle;
|
|
@@ -52,6 +52,7 @@ export type TimelineConfig<TRow extends Record<string, unknown>> = {
|
|
|
52
52
|
progress: number;
|
|
53
53
|
values?: TimeValue[];
|
|
54
54
|
orientation?: Orientation;
|
|
55
|
+
show?: boolean;
|
|
55
56
|
thickness?: number;
|
|
56
57
|
filterMode?: 'exact' | 'upTo';
|
|
57
58
|
interpolate?: boolean | TimelineInterpolation<TRow>;
|
|
@@ -81,6 +81,8 @@ export type HoverDisplayPoint = {
|
|
|
81
81
|
label: string;
|
|
82
82
|
/** Owning series name; undefined for plot kinds with no series concept (heatmap). */
|
|
83
83
|
series?: string;
|
|
84
|
+
/** Resolved series color — used by HoverMarker when dotFill/fill is `'currentColor'`. */
|
|
85
|
+
color?: string;
|
|
84
86
|
};
|
|
85
87
|
/** A candidate point for hover matching/highlighting — also carries its source row. */
|
|
86
88
|
export type HoverPoint<T> = HoverDisplayPoint & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AxisValue } from './common';
|
|
2
2
|
import type { DotStyle, FontStyle, StrokeStyle } from './styles';
|
|
3
|
-
import type { HoverStrategy } from '../layout/tooltip';
|
|
3
|
+
import type { HoverStrategy, HoverDisplayPoint } from '../layout/tooltip';
|
|
4
4
|
/**
|
|
5
5
|
* Baseline props every marker component receives when mounted by a plot:
|
|
6
6
|
* `data` for the points/values it draws, plus `series`/`seriesColor` when
|
|
@@ -40,6 +40,8 @@ export type HoverMarkerConfig = {
|
|
|
40
40
|
ruleX?: boolean;
|
|
41
41
|
ruleY?: boolean;
|
|
42
42
|
showLabels?: boolean;
|
|
43
|
+
/** Custom label formatter. Receives the matched point; return the string to display. */
|
|
44
|
+
format?: (point: HoverDisplayPoint) => string;
|
|
43
45
|
ruleStyle?: StrokeStyle;
|
|
44
46
|
dotStyle?: DotStyle;
|
|
45
47
|
fontStyle?: FontStyle;
|