layerchart 0.70.2 → 0.70.3
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.
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
accessor,
|
|
24
24
|
chartDataArray,
|
|
25
25
|
defaultChartPadding,
|
|
26
|
+
findRelatedData,
|
|
26
27
|
type Accessor,
|
|
27
28
|
} from '../../utils/common.js';
|
|
28
29
|
|
|
@@ -254,7 +255,7 @@
|
|
|
254
255
|
<slot name="highlight" {...slotProps}>
|
|
255
256
|
{#each series as s, i (s.key)}
|
|
256
257
|
{@const seriesTooltipData =
|
|
257
|
-
s.data && tooltip.data ? s.data
|
|
258
|
+
s.data && tooltip.data ? findRelatedData(s.data, tooltip.data, x) : null}
|
|
258
259
|
|
|
259
260
|
<Highlight
|
|
260
261
|
data={seriesTooltipData}
|
|
@@ -295,12 +296,12 @@
|
|
|
295
296
|
<!-- Reverse series order so tooltip items match stacks -->
|
|
296
297
|
{@const seriesItems = stackSeries ? [...series].reverse() : series}
|
|
297
298
|
{#each seriesItems as s}
|
|
298
|
-
{@const seriesTooltipData = s.data ? s.data
|
|
299
|
+
{@const seriesTooltipData = s.data ? findRelatedData(s.data, data, x) : data}
|
|
299
300
|
{@const valueAccessor = accessor(s.value ?? (s.data ? (y as any) : s.key))}
|
|
300
301
|
|
|
301
302
|
<Tooltip.Item
|
|
302
303
|
label={s.label ?? (s.key !== 'default' ? s.key : 'value')}
|
|
303
|
-
value={valueAccessor(seriesTooltipData)}
|
|
304
|
+
value={seriesTooltipData ? valueAccessor(seriesTooltipData) : null}
|
|
304
305
|
color={s.color}
|
|
305
306
|
{format}
|
|
306
307
|
valueAlign="right"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
accessor,
|
|
21
21
|
chartDataArray,
|
|
22
22
|
defaultChartPadding,
|
|
23
|
+
findRelatedData,
|
|
23
24
|
type Accessor,
|
|
24
25
|
} from '../../utils/common.js';
|
|
25
26
|
|
|
@@ -199,8 +200,7 @@
|
|
|
199
200
|
<slot name="highlight" {...slotProps}>
|
|
200
201
|
{#each series as s, i (s.key)}
|
|
201
202
|
{@const seriesTooltipData =
|
|
202
|
-
s.data && tooltip.data ? s.data
|
|
203
|
-
|
|
203
|
+
s.data && tooltip.data ? findRelatedData(s.data, tooltip.data, x) : null}
|
|
204
204
|
<Highlight
|
|
205
205
|
data={seriesTooltipData}
|
|
206
206
|
y={s.value ?? (s.data ? undefined : s.key)}
|
|
@@ -234,12 +234,12 @@
|
|
|
234
234
|
<Tooltip.Header>{format(x(data))}</Tooltip.Header>
|
|
235
235
|
<Tooltip.List>
|
|
236
236
|
{#each series as s}
|
|
237
|
-
{@const seriesTooltipData = s.data ? s.data
|
|
237
|
+
{@const seriesTooltipData = s.data ? findRelatedData(s.data, data, x) : data}
|
|
238
238
|
{@const valueAccessor = accessor(s.value ?? (s.data ? (y as any) : s.key))}
|
|
239
239
|
|
|
240
240
|
<Tooltip.Item
|
|
241
241
|
label={s.label ?? (s.key !== 'default' ? s.key : 'value')}
|
|
242
|
-
value={valueAccessor(seriesTooltipData)}
|
|
242
|
+
value={seriesTooltipData ? valueAccessor(seriesTooltipData) : null}
|
|
243
243
|
color={s.color}
|
|
244
244
|
{format}
|
|
245
245
|
/>
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -12,4 +12,9 @@ export declare function defaultChartPadding(axis: SimplifiedChartProps['axis'],
|
|
|
12
12
|
bottom: number;
|
|
13
13
|
right: number;
|
|
14
14
|
} | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Find the first instance within `data` with the same value as `original` using prop accessor.
|
|
17
|
+
* Handles complex objects such as `Date` by invoking `.valueOf()`
|
|
18
|
+
*/
|
|
19
|
+
export declare function findRelatedData(data: any[], original: any, accessor: Function): any;
|
|
15
20
|
export {};
|
package/dist/utils/common.js
CHANGED
|
@@ -44,3 +44,12 @@ export function defaultChartPadding(axis, legend) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Find the first instance within `data` with the same value as `original` using prop accessor.
|
|
49
|
+
* Handles complex objects such as `Date` by invoking `.valueOf()`
|
|
50
|
+
*/
|
|
51
|
+
export function findRelatedData(data, original, accessor) {
|
|
52
|
+
return data.find((d) => {
|
|
53
|
+
return accessor(d)?.valueOf() === accessor(original)?.valueOf();
|
|
54
|
+
});
|
|
55
|
+
}
|