|
1 | 1 | <script lang="ts">
|
2 |
| - import type { ComponentProps } from 'svelte'; |
| 2 | + import { type ComponentProps } from 'svelte'; |
3 | 3 | import { LineChart } from 'layerchart';
|
4 | 4 | import merge from 'lodash/merge';
|
5 | 5 |
|
6 | 6 | import { lineChartProps } from './common';
|
7 | 7 | import type { ITileSummarySeriesArgs } from '$src/lib/types/codegen';
|
8 | 8 | import { zip } from 'd3';
|
9 |
| - import { Int64 } from '@creditkarma/thrift-server-core'; |
10 | 9 | import { NULL_VALUE } from '$src/lib/constants/common';
|
11 | 10 |
|
12 | 11 | type LineChartProps = ComponentProps<typeof LineChart>;
|
|
18 | 17 | } & Omit<LineChartProps, 'data'>;
|
19 | 18 |
|
20 | 19 | let { data, onbrushend, ...restProps }: Props = $props();
|
21 |
| -</script> |
22 | 20 |
|
23 |
| -<LineChart |
24 |
| - x="date" |
25 |
| - y="value" |
26 |
| - series={[ |
| 21 | + // Using `$derived()` or defining inline causes performance issue (likely due to creating proxies for deep reactivity). |
| 22 | + const series = [ |
27 | 23 | { label: 'p95', color: '#2976E6', index: 2 },
|
28 | 24 | { label: 'p50', color: '#3DDC91', index: 1 },
|
29 | 25 | { label: 'p5', color: '#E5B72D', index: 0 }
|
|
33 | 29 |
|
34 | 30 | return {
|
35 | 31 | key: c.label,
|
36 |
| - data: zip<Int64 | number>( |
| 32 | + data: zip( |
37 | 33 | timestamps.map((ts) => Number(ts)),
|
38 | 34 | values
|
39 |
| - ).map(([ts, value]) => { |
| 35 | + ).map(([ts, value]: number[]) => { |
40 | 36 | return {
|
41 | 37 | date: new Date(ts as number),
|
42 | 38 | value: value === NULL_VALUE ? null : value
|
43 | 39 | };
|
44 | 40 | }),
|
45 | 41 | color: c.color
|
46 | 42 | };
|
47 |
| - })} |
| 43 | + }); |
| 44 | +</script> |
| 45 | + |
| 46 | +<LineChart |
| 47 | + x="date" |
| 48 | + y="value" |
| 49 | + {series} |
48 | 50 | padding={{ top: 4, left: 36, bottom: 20 }}
|
49 | 51 | brush={{ onbrushend }}
|
50 | 52 | {...merge(
|
|
0 commit comments