@reshape-biotech/design-system 0.0.45 → 0.0.48

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 (118) hide show
  1. package/dist/app.css +43 -31
  2. package/dist/components/activity/Activity.stories.svelte +100 -0
  3. package/dist/components/activity/Activity.stories.svelte.d.ts +19 -0
  4. package/dist/components/activity/Activity.svelte +80 -0
  5. package/dist/components/activity/Activity.svelte.d.ts +18 -0
  6. package/dist/components/activity/index.d.ts +1 -0
  7. package/dist/components/activity/index.js +1 -0
  8. package/dist/components/avatar/Avatar.svelte +3 -3
  9. package/dist/components/banner/Banner.svelte +2 -2
  10. package/dist/components/button/Button.svelte +94 -7
  11. package/dist/components/button/Button.svelte.d.ts +8 -5
  12. package/dist/components/collapsible/Collapsible.stories.svelte +40 -0
  13. package/dist/components/collapsible/Collapsible.stories.svelte.d.ts +19 -0
  14. package/dist/components/collapsible/components/collapsible-content.svelte +26 -0
  15. package/dist/components/collapsible/components/collapsible-content.svelte.d.ts +10 -0
  16. package/dist/components/collapsible/components/collapsible-trigger.svelte +36 -0
  17. package/dist/components/collapsible/components/collapsible-trigger.svelte.d.ts +4 -0
  18. package/dist/components/collapsible/index.d.ts +5 -0
  19. package/dist/components/collapsible/index.js +4 -0
  20. package/dist/components/collapsible/types.d.ts +9 -0
  21. package/dist/components/collapsible/types.js +1 -0
  22. package/dist/components/combobox/Combobox.stories.svelte +119 -0
  23. package/dist/components/combobox/Combobox.stories.svelte.d.ts +19 -0
  24. package/dist/components/combobox/components/combobox-add.svelte +30 -0
  25. package/dist/components/combobox/components/combobox-add.svelte.d.ts +8 -0
  26. package/dist/components/combobox/components/combobox-content.svelte +137 -0
  27. package/dist/components/combobox/components/combobox-content.svelte.d.ts +4 -0
  28. package/dist/components/combobox/components/combobox-indicator.svelte +5 -0
  29. package/dist/components/combobox/components/combobox-indicator.svelte.d.ts +18 -0
  30. package/dist/components/combobox/index.d.ts +14 -0
  31. package/dist/components/combobox/index.js +15 -0
  32. package/dist/components/combobox/types.d.ts +20 -0
  33. package/dist/components/combobox/types.js +1 -0
  34. package/dist/components/datepicker/DatePicker.svelte +158 -97
  35. package/dist/components/divider/Divider.svelte +1 -1
  36. package/dist/components/drawer/Drawer.svelte +1 -1
  37. package/dist/components/drawer/DrawerLabel.svelte +2 -2
  38. package/dist/components/dropdown/components/DropdownContent.svelte +4 -1
  39. package/dist/components/dropdown/components/DropdownMenu.svelte +1 -1
  40. package/dist/components/dropdown/components/DropdownTrigger.svelte +4 -2
  41. package/dist/components/dropdown/components/DropdownTrigger.svelte.d.ts +1 -0
  42. package/dist/components/dropdown/components/OutlinedButton.svelte +2 -2
  43. package/dist/components/empty-content/EmptyContent.svelte +19 -0
  44. package/dist/components/empty-content/EmptyContent.svelte.d.ts +8 -0
  45. package/dist/components/graphs/chart/Chart.stories.svelte +128 -0
  46. package/dist/components/graphs/chart/Chart.stories.svelte.d.ts +19 -0
  47. package/dist/components/graphs/chart/Chart.svelte +145 -0
  48. package/dist/components/graphs/chart/Chart.svelte.d.ts +17 -0
  49. package/dist/components/graphs/index.d.ts +4 -0
  50. package/dist/components/graphs/index.js +4 -0
  51. package/dist/components/graphs/line/LineChart.stories.svelte +73 -0
  52. package/dist/components/graphs/line/LineChart.stories.svelte.d.ts +19 -0
  53. package/dist/components/graphs/line/LineChart.svelte +102 -0
  54. package/dist/components/graphs/line/LineChart.svelte.d.ts +18 -0
  55. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +77 -0
  56. package/dist/components/graphs/multiline/MultiLineChart.stories.svelte.d.ts +19 -0
  57. package/dist/components/graphs/multiline/MultiLineChart.svelte +108 -0
  58. package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +22 -0
  59. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +78 -0
  60. package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte.d.ts +19 -0
  61. package/dist/components/graphs/scatterplot/Scatterplot.svelte +67 -0
  62. package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +16 -0
  63. package/dist/components/icon-button/IconButton.svelte +18 -5
  64. package/dist/components/icon-button/IconButton.svelte.d.ts +2 -2
  65. package/dist/components/icons/AnalysisIcon.stories.svelte +38 -0
  66. package/dist/components/icons/AnalysisIcon.stories.svelte.d.ts +27 -0
  67. package/dist/components/icons/AnalysisIcon.svelte +110 -0
  68. package/dist/components/icons/AnalysisIcon.svelte.d.ts +10 -0
  69. package/dist/components/icons/Icon.svelte +23 -0
  70. package/dist/components/icons/Icon.svelte.d.ts +4 -0
  71. package/dist/components/icons/custom/Halo.svelte +32 -0
  72. package/dist/components/icons/custom/Halo.svelte.d.ts +26 -0
  73. package/dist/components/icons/custom/Well.svelte +26 -0
  74. package/dist/components/icons/custom/Well.svelte.d.ts +26 -0
  75. package/dist/components/icons/index.d.ts +17 -0
  76. package/dist/components/icons/index.js +21 -0
  77. package/dist/components/icons/types.d.ts +0 -0
  78. package/dist/components/icons/types.js +1 -0
  79. package/dist/components/image/Image.svelte +5 -6
  80. package/dist/components/input/Input.svelte +63 -41
  81. package/dist/components/input/Input.svelte.d.ts +7 -4
  82. package/dist/components/list/List.svelte +4 -10
  83. package/dist/components/logo/Logo.svelte +8 -5
  84. package/dist/components/logo/Logo.svelte.d.ts +1 -0
  85. package/dist/components/modal/Modal.svelte +1 -1
  86. package/dist/components/notification-popup/NotificationPopup.stories.svelte +2 -2
  87. package/dist/components/notification-popup/NotificationPopup.svelte +4 -2
  88. package/dist/components/segmented-control-buttons/ControlButton.svelte +2 -4
  89. package/dist/components/select/Select.svelte +7 -4
  90. package/dist/components/skeleton-loader/StatcardSkeleton.svelte +2 -5
  91. package/dist/components/slider/Slider.svelte +32 -23
  92. package/dist/components/slider/Slider.svelte.d.ts +2 -0
  93. package/dist/components/stat-card/StatCard.svelte +6 -6
  94. package/dist/components/table/Table.svelte +1 -1
  95. package/dist/components/table/components/Th.svelte +1 -1
  96. package/dist/components/tag/Tag.svelte +3 -5
  97. package/dist/components/tag/Tag.svelte.d.ts +5 -4
  98. package/dist/components/toggle/Toggle.svelte.d.ts +3 -2
  99. package/dist/fonts/afAnotherSans-Medium.woff2 +0 -0
  100. package/dist/fonts/afAnotherSans-Regular.woff2 +0 -0
  101. package/dist/fonts/afAnotherSans-SemiBold.woff2 +0 -0
  102. package/dist/fonts/afAnotherSans.woff2 +0 -0
  103. package/dist/fonts/index.d.ts +1 -3
  104. package/dist/fonts/index.js +2 -6
  105. package/dist/index.d.ts +5 -0
  106. package/dist/index.js +5 -0
  107. package/dist/tailwind-safelist.js +1 -1
  108. package/dist/tailwind.preset.d.ts +19 -6
  109. package/dist/tailwind.preset.js +5 -4
  110. package/dist/tokens.d.ts +39 -11
  111. package/dist/tokens.js +34 -16
  112. package/package.json +18 -15
  113. package/dist/fonts/MDSystem-Medium.woff +0 -0
  114. package/dist/fonts/MDSystem-Medium.woff2 +0 -0
  115. package/dist/fonts/MDSystem-Regular.woff +0 -0
  116. package/dist/fonts/MDSystem-Regular.woff2 +0 -0
  117. package/dist/fonts/MDSystem-Semibold.woff +0 -0
  118. package/dist/fonts/MDSystem-Semibold.woff2 +0 -0
@@ -0,0 +1,145 @@
1
+ <script lang="ts">
2
+ import * as echarts from 'echarts';
3
+ import type { ECElementEvent } from 'echarts';
4
+ import { onMount } from 'svelte';
5
+ import { colors, textColor } from '../../../tokens';
6
+ type Props = {
7
+ options: echarts.EChartsOption;
8
+ theme?: string | object;
9
+ renderer?: 'canvas' | 'svg';
10
+ height?: string;
11
+ width?: string;
12
+ // Common event handlers
13
+ onitemclick?: (params: ECElementEvent) => void;
14
+ onmouseover?: (params: ECElementEvent) => void;
15
+ onmouseout?: () => void;
16
+ // Additional options
17
+ autoResize?: boolean;
18
+ loading?: boolean;
19
+ };
20
+
21
+ const {
22
+ options,
23
+ theme,
24
+ renderer = 'svg',
25
+ height = '100%',
26
+ width = '100%',
27
+ onitemclick,
28
+ onmouseover,
29
+ onmouseout,
30
+ autoResize = true,
31
+ loading = false
32
+ }: Props = $props();
33
+
34
+ let chart = $state<echarts.ECharts | null>(null);
35
+ let container: HTMLElement;
36
+
37
+ function deepMerge(target: any, source: any) {
38
+ for (const key in source) {
39
+ if (source[key] instanceof Object && key in target) {
40
+ deepMerge(target[key], source[key]);
41
+ } else {
42
+ target[key] = source[key];
43
+ }
44
+ }
45
+ return target;
46
+ }
47
+
48
+ const defaultOptions = {
49
+ grid: {
50
+ left: '48px',
51
+ right: '16px',
52
+ top: '16px',
53
+ bottom: '48px'
54
+ },
55
+ xAxis: {
56
+ nameLocation: 'middle',
57
+ nameGap: 32,
58
+ axisLabel: {
59
+ fontSize: 10,
60
+ lineHeight: 14,
61
+ align: 'center',
62
+ fontWeight: 450,
63
+ color: textColor.secondary,
64
+ margin: 16,
65
+ fontFamily: 'monospace'
66
+ },
67
+ axisLine: {
68
+ lineStyle: {
69
+ color: colors.gray[2]
70
+ }
71
+ },
72
+ nameTextStyle: {
73
+ fontSize: 12,
74
+ color: textColor.secondary
75
+ }
76
+ },
77
+ yAxis: {
78
+ nameLocation: 'middle',
79
+ nameGap: 32,
80
+ nameRotate: 90,
81
+ axisLabel: {
82
+ fontSize: 10,
83
+ lineHeight: 14,
84
+ align: 'center',
85
+ fontWeight: 450,
86
+ color: textColor.secondary,
87
+ margin: 16,
88
+ fontFamily: 'monospace'
89
+ },
90
+ axisLine: {
91
+ lineStyle: {
92
+ color: colors.gray[2]
93
+ }
94
+ },
95
+ nameTextStyle: {
96
+ fontSize: 12,
97
+ color: textColor.secondary
98
+ }
99
+ }
100
+ } as const;
101
+
102
+ const finalOptions = deepMerge(structuredClone(defaultOptions), options);
103
+
104
+ function initChart() {
105
+ if (container) {
106
+ chart = echarts.init(container, theme, { renderer });
107
+ chart.setOption(finalOptions);
108
+
109
+ if (onitemclick) chart.on('click', onitemclick);
110
+ if (onmouseover) chart.on('mouseover', onmouseover);
111
+ if (onmouseout) chart.on('mouseout', onmouseout);
112
+
113
+ if (loading) chart.showLoading();
114
+ }
115
+ }
116
+
117
+ $effect(() => {
118
+ if (loading) {
119
+ chart?.showLoading();
120
+ } else {
121
+ chart?.hideLoading();
122
+ }
123
+ });
124
+
125
+ onMount(() => {
126
+ initChart();
127
+
128
+ if (autoResize) {
129
+ const resizeObserver = new ResizeObserver(() => chart?.resize());
130
+ resizeObserver.observe(container);
131
+ return () => {
132
+ resizeObserver.disconnect();
133
+ chart?.dispose();
134
+ };
135
+ }
136
+ });
137
+ </script>
138
+
139
+ <div bind:this={container} style="width: {width}; height: {height};" class="chart-container"></div>
140
+
141
+ <style>
142
+ .chart-container {
143
+ position: relative;
144
+ }
145
+ </style>
@@ -0,0 +1,17 @@
1
+ import * as echarts from 'echarts';
2
+ import type { ECElementEvent } from 'echarts';
3
+ type Props = {
4
+ options: echarts.EChartsOption;
5
+ theme?: string | object;
6
+ renderer?: 'canvas' | 'svg';
7
+ height?: string;
8
+ width?: string;
9
+ onitemclick?: (params: ECElementEvent) => void;
10
+ onmouseover?: (params: ECElementEvent) => void;
11
+ onmouseout?: () => void;
12
+ autoResize?: boolean;
13
+ loading?: boolean;
14
+ };
15
+ declare const Chart: import("svelte").Component<Props, {}, "">;
16
+ type Chart = ReturnType<typeof Chart>;
17
+ export default Chart;
@@ -0,0 +1,4 @@
1
+ export { default as Scatterplot } from './scatterplot/Scatterplot.svelte';
2
+ export { default as Chart } from './chart/Chart.svelte';
3
+ export { default as LineChart } from './line/LineChart.svelte';
4
+ export { default as MultiLineChart } from './multiline/MultiLineChart.svelte';
@@ -0,0 +1,4 @@
1
+ export { default as Scatterplot } from './scatterplot/Scatterplot.svelte';
2
+ export { default as Chart } from './chart/Chart.svelte';
3
+ export { default as LineChart } from './line/LineChart.svelte';
4
+ export { default as MultiLineChart } from './multiline/MultiLineChart.svelte';
@@ -0,0 +1,73 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+
4
+ import LineChart from './LineChart.svelte';
5
+
6
+ const { Story } = defineMeta({
7
+ component: LineChart,
8
+ title: 'Design System/Graphs/LineChart',
9
+ tags: ['autodocs']
10
+ });
11
+
12
+ const xAxis = '€€€';
13
+ const yAxis = '$$$';
14
+
15
+ const data = [
16
+ 10.0, 8.04, 8.07, 6.95, 13.0, 7.58, 9.05, 8.81, 11.0, 8.33, 14.0, 7.66, 13.4, 6.81, 10.0, 6.33,
17
+ 14.0, 8.96, 12.5, 6.82, 9.15, 7.2, 11.5, 7.2, 3.03, 4.23, 12.2, 7.83, 2.02, 4.47, 1.05, 3.33,
18
+ 4.05, 4.96, 6.03, 7.24, 12.0, 6.26, 12.0, 8.84, 7.08, 5.82, 5.02, 5.6
19
+ ];
20
+
21
+ const bigData = Array.from({ length: 1000 }, (_, i) => i);
22
+
23
+ function handleItemClick(params: echarts.ECElementEvent) {
24
+ console.log(params);
25
+ }
26
+
27
+ function handleMouseOver(params: echarts.ECElementEvent) {
28
+ console.log(params);
29
+ }
30
+
31
+ function handleMouseOut() {
32
+ console.log('mouse out');
33
+ }
34
+ </script>
35
+
36
+ <Story name="Base">
37
+ <div class="h-[400px] w-full">
38
+ <LineChart
39
+ {xAxis}
40
+ {yAxis}
41
+ {data}
42
+ onitemclick={handleItemClick}
43
+ onmouseover={handleMouseOver}
44
+ onmouseout={handleMouseOut}
45
+ />
46
+ </div>
47
+ </Story>
48
+ <Story name="Loading">
49
+ <div class="h-[400px] w-full">
50
+ <LineChart
51
+ {xAxis}
52
+ {yAxis}
53
+ {data}
54
+ loading
55
+ onitemclick={handleItemClick}
56
+ onmouseover={handleMouseOver}
57
+ onmouseout={handleMouseOut}
58
+ />
59
+ </div>
60
+ </Story>
61
+ <Story name="Large datasets with capture intervals">
62
+ <div class="h-[400px] w-full">
63
+ <LineChart
64
+ {xAxis}
65
+ {yAxis}
66
+ data={bigData}
67
+ captureInterval={1000}
68
+ onitemclick={handleItemClick}
69
+ onmouseover={handleMouseOver}
70
+ onmouseout={handleMouseOut}
71
+ />
72
+ </div>
73
+ </Story>
@@ -0,0 +1,19 @@
1
+ import LineChart from './LineChart.svelte';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const LineChart: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, string>;
18
+ type LineChart = InstanceType<typeof LineChart>;
19
+ export default LineChart;
@@ -0,0 +1,102 @@
1
+ <script lang="ts">
2
+ import { textColor, backgroundColor } from '../../../tokens';
3
+ import Chart from '../chart/Chart.svelte';
4
+ import type { EChartsOption } from 'echarts';
5
+ import { Duration } from 'luxon';
6
+
7
+ interface Props {
8
+ data: (number | null)[];
9
+ captureInterval?: number;
10
+ loading?: boolean;
11
+ xAxis?: string;
12
+ yAxis?: string;
13
+ height?: string;
14
+ width?: string;
15
+ xAxisOptions?: EChartsOption['xAxis'];
16
+ yAxisOptions?: EChartsOption['yAxis'];
17
+ onitemclick?: (params: echarts.ECElementEvent) => void;
18
+ onmouseover?: (params: echarts.ECElementEvent) => void;
19
+ onmouseout?: () => void;
20
+ }
21
+
22
+ const toFixedLocaleString = (
23
+ value?: number | undefined,
24
+ fractionDigits: number | undefined = 0,
25
+ locale: string | undefined = undefined
26
+ ): string =>
27
+ value?.toLocaleString(locale, {
28
+ minimumFractionDigits: fractionDigits,
29
+ maximumFractionDigits: fractionDigits
30
+ }) ?? '';
31
+
32
+ let { data, xAxis, xAxisOptions, yAxis, yAxisOptions, captureInterval, ...props }: Props =
33
+ $props();
34
+
35
+ const captureIntervals = captureInterval
36
+ ? Array(data.length)
37
+ .fill(null)
38
+ .map((_, timeIndex) => {
39
+ const seconds = timeIndex * captureInterval;
40
+ const duration = Duration.fromObject({ seconds }).shiftTo('days', 'hours', 'minutes');
41
+ return duration.days >= 1 ? duration.toFormat('dd:hh:mm') : duration.toFormat('hh:mm');
42
+ })
43
+ : undefined;
44
+
45
+ $effect(() => {
46
+ console.log(captureIntervals);
47
+ });
48
+
49
+ let options: EChartsOption = {
50
+ color: ['#5750EE', '#FF7100', '#50EEA6', '#E7EE50', '#EE5098'],
51
+ grid: {
52
+ top: 10,
53
+ bottom: 10,
54
+ left: 10,
55
+ right: 10,
56
+ containLabel: true
57
+ },
58
+ textStyle: {
59
+ color: textColor['secondary']
60
+ },
61
+ xAxis: {
62
+ type: 'category',
63
+ boundaryGap: false,
64
+ axisLine: {
65
+ onZero: false
66
+ },
67
+ name: xAxis,
68
+ data: captureIntervals,
69
+ ...xAxisOptions
70
+ },
71
+ yAxis: {
72
+ type: 'value',
73
+ alignTicks: true,
74
+ axisLabel: {
75
+ formatter: (value: any) => value.toLocaleString()
76
+ } as any,
77
+ axisPointer: {
78
+ label: {
79
+ formatter: (value: any) => toFixedLocaleString(value.value, 2)
80
+ }
81
+ },
82
+ name: yAxis,
83
+ ...yAxisOptions
84
+ },
85
+ selectedMode: 'multiple',
86
+ series: {
87
+ animation: false,
88
+ seriesLayoutBy: 'row',
89
+ emphasis: {
90
+ focus: 'series'
91
+ },
92
+ tooltip: {
93
+ show: false
94
+ },
95
+ type: 'line',
96
+ symbol: data.length > 1 ? 'none' : 'circle',
97
+ data
98
+ }
99
+ };
100
+ </script>
101
+
102
+ <Chart {options} {...props} />
@@ -0,0 +1,18 @@
1
+ import type { EChartsOption } from 'echarts';
2
+ interface Props {
3
+ data: (number | null)[];
4
+ captureInterval?: number;
5
+ loading?: boolean;
6
+ xAxis?: string;
7
+ yAxis?: string;
8
+ height?: string;
9
+ width?: string;
10
+ xAxisOptions?: EChartsOption['xAxis'];
11
+ yAxisOptions?: EChartsOption['yAxis'];
12
+ onitemclick?: (params: echarts.ECElementEvent) => void;
13
+ onmouseover?: (params: echarts.ECElementEvent) => void;
14
+ onmouseout?: () => void;
15
+ }
16
+ declare const LineChart: import("svelte").Component<Props, {}, "">;
17
+ type LineChart = ReturnType<typeof LineChart>;
18
+ export default LineChart;
@@ -0,0 +1,77 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+
4
+ import MultiLineChart from './MultiLineChart.svelte';
5
+
6
+ const { Story } = defineMeta({
7
+ component: MultiLineChart,
8
+ title: 'Design System/Graphs/MultiLineChart',
9
+ tags: ['autodocs']
10
+ });
11
+
12
+ const xAxis = '€€€';
13
+ const yAxis = '$$$';
14
+
15
+ const smooth = (data: number[]) =>
16
+ data.map((_, i, arr) => {
17
+ const windowSize = 2;
18
+ const start = Math.max(i - windowSize, 0);
19
+ const end = Math.min(i + windowSize, arr.length - 1);
20
+ const subset = arr.slice(start, end + 1);
21
+ return subset.reduce((sum, v) => sum + v, 0) / subset.length;
22
+ });
23
+
24
+ const data = [
25
+ {
26
+ key: 'Group 1',
27
+ series: smooth(Array.from({ length: 25 }, () => Math.random() * 80))
28
+ },
29
+ {
30
+ key: 'Group 2',
31
+ series: smooth(Array.from({ length: 20 }, () => Math.random() * 60))
32
+ },
33
+ {
34
+ key: 'Group 3',
35
+ series: smooth(Array.from({ length: 35 }, () => Math.random() * 100))
36
+ }
37
+ ];
38
+
39
+ function handleItemClick(params: echarts.ECElementEvent) {
40
+ console.log(params);
41
+ }
42
+
43
+ function handleMouseOver(params: echarts.ECElementEvent) {
44
+ console.log(params);
45
+ }
46
+
47
+ function handleMouseOut() {
48
+ console.log('mouse out');
49
+ }
50
+ </script>
51
+
52
+ <Story name="Base">
53
+ <div class="h-[400px] w-full">
54
+ <MultiLineChart
55
+ {xAxis}
56
+ {yAxis}
57
+ {data}
58
+ onitemclick={handleItemClick}
59
+ onmouseover={handleMouseOver}
60
+ onmouseout={handleMouseOut}
61
+ />
62
+ </div>
63
+ </Story>
64
+
65
+ <Story name="Loading">
66
+ <div class="h-[400px] w-full">
67
+ <MultiLineChart
68
+ {xAxis}
69
+ {yAxis}
70
+ {data}
71
+ loading
72
+ onitemclick={handleItemClick}
73
+ onmouseover={handleMouseOver}
74
+ onmouseout={handleMouseOut}
75
+ />
76
+ </div>
77
+ </Story>
@@ -0,0 +1,19 @@
1
+ import MultiLineChart from './MultiLineChart.svelte';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const MultiLineChart: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, string>;
18
+ type MultiLineChart = InstanceType<typeof MultiLineChart>;
19
+ export default MultiLineChart;
@@ -0,0 +1,108 @@
1
+ <script lang="ts">
2
+ import { textColor, backgroundColor } from '../../../tokens';
3
+ import Chart from '../chart/Chart.svelte';
4
+ import type { EChartsOption } from 'echarts';
5
+ import { Duration } from 'luxon';
6
+
7
+ interface Groups {
8
+ key: string;
9
+ series: (number | null)[];
10
+ }
11
+
12
+ interface Props {
13
+ data: Groups[];
14
+ captureInterval?: number;
15
+ loading?: boolean;
16
+ xAxis?: string;
17
+ yAxis?: string;
18
+ height?: string;
19
+ width?: string;
20
+ xAxisOptions?: EChartsOption['xAxis'];
21
+ yAxisOptions?: EChartsOption['yAxis'];
22
+ onitemclick?: (params: echarts.ECElementEvent) => void;
23
+ onmouseover?: (params: echarts.ECElementEvent) => void;
24
+ onmouseout?: () => void;
25
+ }
26
+
27
+ const toFixedLocaleString = (
28
+ value?: number | undefined,
29
+ fractionDigits: number | undefined = 0,
30
+ locale: string | undefined = undefined
31
+ ): string =>
32
+ value?.toLocaleString(locale, {
33
+ minimumFractionDigits: fractionDigits,
34
+ maximumFractionDigits: fractionDigits
35
+ }) ?? '';
36
+
37
+ let { data, xAxis, xAxisOptions, yAxis, yAxisOptions, captureInterval, ...props }: Props =
38
+ $props();
39
+
40
+ const longestSeries = data.reduce(
41
+ (acc: (number | null)[], group) => (group.series.length > acc.length ? group.series : acc),
42
+ []
43
+ ).length;
44
+
45
+ const captureIntervals = captureInterval
46
+ ? Array(longestSeries)
47
+ .fill(null)
48
+ .map((_, timeIndex) => {
49
+ const seconds = timeIndex * captureInterval;
50
+ const duration = Duration.fromObject({ seconds }).shiftTo('days', 'hours', 'minutes');
51
+ return duration.days >= 1 ? duration.toFormat('dd:hh:mm') : duration.toFormat('hh:mm');
52
+ })
53
+ : undefined;
54
+
55
+ let options: EChartsOption = {
56
+ color: ['#5750EE', '#FF7100', '#50EEA6', '#E7EE50', '#EE5098'],
57
+ grid: {
58
+ top: 10,
59
+ bottom: 10,
60
+ left: 10,
61
+ right: 10,
62
+ containLabel: true
63
+ },
64
+ textStyle: {
65
+ color: textColor['secondary']
66
+ },
67
+ xAxis: {
68
+ type: 'category',
69
+ boundaryGap: false,
70
+ axisLine: {
71
+ onZero: false
72
+ },
73
+ name: xAxis,
74
+ data: captureIntervals,
75
+ ...xAxisOptions
76
+ },
77
+ yAxis: {
78
+ type: 'value',
79
+ alignTicks: true,
80
+ axisLabel: {
81
+ formatter: (value: any) => value.toLocaleString()
82
+ } as any,
83
+ axisPointer: {
84
+ label: {
85
+ formatter: (value: any) => toFixedLocaleString(value.value, 2)
86
+ }
87
+ },
88
+ name: yAxis,
89
+ ...yAxisOptions
90
+ },
91
+ selectedMode: 'multiple',
92
+ series: data.map((group) => ({
93
+ animation: false,
94
+ seriesLayoutBy: 'row',
95
+ emphasis: {
96
+ focus: 'series'
97
+ },
98
+ tooltip: {
99
+ show: false
100
+ },
101
+ type: 'line',
102
+ symbol: group.series.length > 1 ? 'none' : 'circle',
103
+ data: group.series
104
+ }))
105
+ };
106
+ </script>
107
+
108
+ <Chart {options} {...props} />
@@ -0,0 +1,22 @@
1
+ import type { EChartsOption } from 'echarts';
2
+ interface Groups {
3
+ key: string;
4
+ series: (number | null)[];
5
+ }
6
+ interface Props {
7
+ data: Groups[];
8
+ captureInterval?: number;
9
+ loading?: boolean;
10
+ xAxis?: string;
11
+ yAxis?: string;
12
+ height?: string;
13
+ width?: string;
14
+ xAxisOptions?: EChartsOption['xAxis'];
15
+ yAxisOptions?: EChartsOption['yAxis'];
16
+ onitemclick?: (params: echarts.ECElementEvent) => void;
17
+ onmouseover?: (params: echarts.ECElementEvent) => void;
18
+ onmouseout?: () => void;
19
+ }
20
+ declare const MultiLineChart: import("svelte").Component<Props, {}, "">;
21
+ type MultiLineChart = ReturnType<typeof MultiLineChart>;
22
+ export default MultiLineChart;
@@ -0,0 +1,78 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+
4
+ import Scatterplot from './Scatterplot.svelte';
5
+
6
+ const { Story } = defineMeta({
7
+ component: Scatterplot,
8
+ title: 'Design System/Graphs/Scatterplot',
9
+ tags: ['autodocs']
10
+ });
11
+
12
+ const data = [
13
+ [10.0, 8.04],
14
+ [8.07, 6.95],
15
+ [13.0, 7.58],
16
+ [9.05, 8.81],
17
+ [11.0, 8.33],
18
+ [14.0, 7.66],
19
+ [13.4, 6.81],
20
+ [10.0, 6.33],
21
+ [14.0, 8.96],
22
+ [12.5, 6.82],
23
+ [9.15, 7.2],
24
+ [11.5, 7.2],
25
+ [3.03, 4.23],
26
+ [12.2, 7.83],
27
+ [2.02, 4.47],
28
+ [1.05, 3.33],
29
+ [4.05, 4.96],
30
+ [6.03, 7.24],
31
+ [12.0, 6.26],
32
+ [12.0, 8.84],
33
+ [7.08, 5.82],
34
+ [5.02, 5.68]
35
+ ];
36
+
37
+ const lineData = [0, 2, 4, 6, 8, 10, 12, 14];
38
+
39
+ function handleItemClick(params: echarts.ECElementEvent) {
40
+ console.log(params);
41
+ }
42
+
43
+ function handleMouseOver(params: echarts.ECElementEvent) {
44
+ console.log(params);
45
+ }
46
+
47
+ function handleMouseOut() {
48
+ console.log('mouse out');
49
+ }
50
+ </script>
51
+
52
+ <Story name="Base">
53
+ <div class="h-[400px] w-full">
54
+ <Scatterplot
55
+ {data}
56
+ {lineData}
57
+ xAxis="Manual count"
58
+ yAxis="Analysis count"
59
+ onitemclick={handleItemClick}
60
+ onmouseover={handleMouseOver}
61
+ onmouseout={handleMouseOut}
62
+ />
63
+ </div>
64
+ </Story>
65
+ <Story name="Loading">
66
+ <div class="h-[400px] w-full">
67
+ <Scatterplot
68
+ {data}
69
+ {lineData}
70
+ xAxis="Manual count"
71
+ yAxis="Analysis count"
72
+ loading
73
+ onitemclick={handleItemClick}
74
+ onmouseover={handleMouseOver}
75
+ onmouseout={handleMouseOut}
76
+ />
77
+ </div>
78
+ </Story>