@flux-ui/statistics 3.0.0-next.67 → 3.0.0-next.69

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 (165) hide show
  1. package/README.md +1 -1
  2. package/dist/component/FluxStatisticsAreaChart.vue.d.ts +11 -4
  3. package/dist/component/FluxStatisticsBarChart.vue.d.ts +11 -4
  4. package/dist/component/FluxStatisticsBase.vue.d.ts +1 -0
  5. package/dist/component/FluxStatisticsBoxPlotChart.vue.d.ts +15 -0
  6. package/dist/component/FluxStatisticsBubbleChart.vue.d.ts +14 -0
  7. package/dist/component/FluxStatisticsCandlestickChart.vue.d.ts +15 -0
  8. package/dist/component/FluxStatisticsChart.vue.d.ts +7 -5
  9. package/dist/component/FluxStatisticsChartPane.vue.d.ts +1 -0
  10. package/dist/component/FluxStatisticsComparison.vue.d.ts +16 -0
  11. package/dist/component/FluxStatisticsDonutChart.vue.d.ts +8 -4
  12. package/dist/component/FluxStatisticsEmpty.vue.d.ts +19 -0
  13. package/dist/component/FluxStatisticsHeatmapChart.vue.d.ts +15 -0
  14. package/dist/component/FluxStatisticsLegendItem.vue.d.ts +1 -0
  15. package/dist/component/FluxStatisticsLegendScope.vue.d.ts +13 -0
  16. package/dist/component/FluxStatisticsLineChart.vue.d.ts +11 -4
  17. package/dist/component/FluxStatisticsMixedChart.vue.d.ts +17 -0
  18. package/dist/component/FluxStatisticsPercentageBar.vue.d.ts +8 -0
  19. package/dist/component/FluxStatisticsPieChart.vue.d.ts +8 -4
  20. package/dist/component/FluxStatisticsPolarAreaChart.vue.d.ts +14 -0
  21. package/dist/component/FluxStatisticsRadarChart.vue.d.ts +12 -0
  22. package/dist/component/FluxStatisticsRadialBar.vue.d.ts +11 -0
  23. package/dist/component/FluxStatisticsScatterChart.vue.d.ts +14 -0
  24. package/dist/component/FluxStatisticsSparkline.vue.d.ts +13 -0
  25. package/dist/component/FluxStatisticsTreemapChart.vue.d.ts +11 -0
  26. package/dist/component/index.d.ts +15 -0
  27. package/dist/composable/index.d.ts +12 -0
  28. package/dist/composable/useChartBaseSetup.d.ts +8 -0
  29. package/dist/composable/useChartHoverSync.d.ts +9 -0
  30. package/dist/composable/useChartLegend.d.ts +14 -0
  31. package/dist/composable/useChartSeriesSetup.d.ts +23 -0
  32. package/dist/composable/useChartSlicesSetup.d.ts +14 -0
  33. package/dist/composable/useECharts.d.ts +9 -0
  34. package/dist/echarts.d.ts +1 -0
  35. package/dist/index.css +262 -34
  36. package/dist/index.d.ts +5 -2
  37. package/dist/index.js +9176 -6895
  38. package/dist/index.js.map +1 -1
  39. package/dist/util/colors.d.ts +4 -0
  40. package/dist/util/icons.d.ts +2 -0
  41. package/dist/util/index.d.ts +6 -0
  42. package/dist/util/options/buildBaseOptions.d.ts +2 -0
  43. package/dist/util/options/buildCartesianBaseOptions.d.ts +13 -0
  44. package/dist/util/options/buildCircularBaseOptions.d.ts +2 -0
  45. package/dist/util/options/cartesian/buildAreaChartOptions.d.ts +17 -0
  46. package/dist/util/options/cartesian/buildBarChartOptions.d.ts +17 -0
  47. package/dist/util/options/cartesian/buildBoxPlotChartOptions.d.ts +16 -0
  48. package/dist/util/options/cartesian/buildBubbleChartOptions.d.ts +15 -0
  49. package/dist/util/options/cartesian/buildCandlestickChartOptions.d.ts +17 -0
  50. package/dist/util/options/cartesian/buildHeatmapChartOptions.d.ts +15 -0
  51. package/dist/util/options/cartesian/buildLineChartOptions.d.ts +17 -0
  52. package/dist/util/options/cartesian/buildMixedChartOptions.d.ts +17 -0
  53. package/dist/util/options/cartesian/buildScatterChartOptions.d.ts +15 -0
  54. package/dist/util/options/cartesian/index.d.ts +18 -0
  55. package/dist/util/options/circular/buildDonutChartOptions.d.ts +15 -0
  56. package/dist/util/options/circular/buildGaugeChartOptions.d.ts +14 -0
  57. package/dist/util/options/circular/buildPieChartOptions.d.ts +15 -0
  58. package/dist/util/options/circular/buildPolarAreaChartOptions.d.ts +15 -0
  59. package/dist/util/options/circular/buildRadarChartOptions.d.ts +13 -0
  60. package/dist/util/options/circular/buildTreemapChartOptions.d.ts +12 -0
  61. package/dist/util/options/circular/index.d.ts +12 -0
  62. package/dist/util/options/index.d.ts +6 -0
  63. package/dist/util/series/chartColors.d.ts +3 -0
  64. package/dist/util/series/converters.d.ts +17 -0
  65. package/dist/util/series/defaults.d.ts +15 -0
  66. package/dist/util/series/index.d.ts +4 -0
  67. package/dist/util/series/labels.d.ts +5 -0
  68. package/dist/util/sparkline.d.ts +7 -0
  69. package/dist/util/tooltips/buildBoxPlotTooltip.d.ts +22 -0
  70. package/dist/util/tooltips/buildCartesianTooltip.d.ts +10 -0
  71. package/dist/util/tooltips/buildGaugeTooltip.d.ts +14 -0
  72. package/dist/util/tooltips/buildHeatmapTooltip.d.ts +17 -0
  73. package/dist/util/tooltips/buildRadarTooltip.d.ts +11 -0
  74. package/dist/util/tooltips/buildSharedItemTooltip.d.ts +10 -0
  75. package/dist/util/tooltips/buildTreemapTooltip.d.ts +12 -0
  76. package/dist/util/tooltips/index.d.ts +15 -0
  77. package/dist/util/tooltips/render.d.ts +4 -0
  78. package/dist/util/tooltips/types.d.ts +24 -0
  79. package/package.json +14 -15
  80. package/src/component/FluxStatisticsAreaChart.vue +36 -43
  81. package/src/component/FluxStatisticsBarChart.vue +36 -35
  82. package/src/component/FluxStatisticsBase.vue +14 -1
  83. package/src/component/FluxStatisticsBoxPlotChart.vue +49 -0
  84. package/src/component/FluxStatisticsBubbleChart.vue +46 -0
  85. package/src/component/FluxStatisticsCandlestickChart.vue +50 -0
  86. package/src/component/FluxStatisticsChart.vue +19 -169
  87. package/src/component/FluxStatisticsChartPane.vue +22 -11
  88. package/src/component/FluxStatisticsComparison.vue +113 -0
  89. package/src/component/FluxStatisticsDonutChart.vue +31 -19
  90. package/src/component/FluxStatisticsEmpty.vue +44 -0
  91. package/src/component/FluxStatisticsHeatmapChart.vue +47 -0
  92. package/src/component/FluxStatisticsLegend.vue +33 -1
  93. package/src/component/FluxStatisticsLegendItem.vue +3 -1
  94. package/src/component/FluxStatisticsLegendScope.vue +16 -0
  95. package/src/component/FluxStatisticsLineChart.vue +36 -43
  96. package/src/component/FluxStatisticsMixedChart.vue +52 -0
  97. package/src/component/FluxStatisticsPercentageBar.vue +90 -0
  98. package/src/component/FluxStatisticsPieChart.vue +31 -19
  99. package/src/component/FluxStatisticsPolarAreaChart.vue +44 -0
  100. package/src/component/FluxStatisticsRadarChart.vue +40 -0
  101. package/src/component/FluxStatisticsRadialBar.vue +39 -0
  102. package/src/component/FluxStatisticsScatterChart.vue +46 -0
  103. package/src/component/FluxStatisticsSparkline.vue +67 -0
  104. package/src/component/FluxStatisticsTreemapChart.vue +35 -0
  105. package/src/component/index.ts +15 -0
  106. package/src/composable/index.ts +12 -0
  107. package/src/composable/useChartBaseSetup.ts +16 -0
  108. package/src/composable/useChartHoverSync.ts +92 -0
  109. package/src/composable/useChartLegend.ts +23 -0
  110. package/src/composable/useChartSeriesSetup.ts +75 -0
  111. package/src/composable/useChartSlicesSetup.ts +58 -0
  112. package/src/composable/useECharts.ts +55 -0
  113. package/src/css/Base.module.scss +28 -1
  114. package/src/css/Chart.module.scss +59 -30
  115. package/src/css/ChartPane.module.scss +20 -12
  116. package/src/css/Comparison.module.scss +52 -0
  117. package/src/css/Empty.module.scss +39 -0
  118. package/src/css/Grid.module.scss +1 -0
  119. package/src/css/Legend.module.scss +22 -4
  120. package/src/css/Meter.module.scss +1 -0
  121. package/src/css/Metric.module.scss +6 -0
  122. package/src/css/PercentageBar.module.scss +36 -0
  123. package/src/css/Sparkline.module.scss +13 -0
  124. package/src/echarts.ts +47 -0
  125. package/src/index.ts +7 -3
  126. package/src/util/colors.ts +86 -0
  127. package/src/util/icons.ts +20 -0
  128. package/src/util/index.ts +6 -0
  129. package/src/util/options/buildBaseOptions.ts +31 -0
  130. package/src/util/options/buildCartesianBaseOptions.ts +67 -0
  131. package/src/util/options/buildCircularBaseOptions.ts +10 -0
  132. package/src/util/options/cartesian/buildAreaChartOptions.ts +44 -0
  133. package/src/util/options/cartesian/buildBarChartOptions.ts +44 -0
  134. package/src/util/options/cartesian/buildBoxPlotChartOptions.ts +63 -0
  135. package/src/util/options/cartesian/buildBubbleChartOptions.ts +48 -0
  136. package/src/util/options/cartesian/buildCandlestickChartOptions.ts +77 -0
  137. package/src/util/options/cartesian/buildHeatmapChartOptions.ts +72 -0
  138. package/src/util/options/cartesian/buildLineChartOptions.ts +44 -0
  139. package/src/util/options/cartesian/buildMixedChartOptions.ts +44 -0
  140. package/src/util/options/cartesian/buildScatterChartOptions.ts +48 -0
  141. package/src/util/options/cartesian/index.ts +18 -0
  142. package/src/util/options/circular/buildDonutChartOptions.ts +31 -0
  143. package/src/util/options/circular/buildGaugeChartOptions.ts +45 -0
  144. package/src/util/options/circular/buildPieChartOptions.ts +31 -0
  145. package/src/util/options/circular/buildPolarAreaChartOptions.ts +31 -0
  146. package/src/util/options/circular/buildRadarChartOptions.ts +52 -0
  147. package/src/util/options/circular/buildTreemapChartOptions.ts +28 -0
  148. package/src/util/options/circular/index.ts +12 -0
  149. package/src/util/options/index.ts +6 -0
  150. package/src/util/series/chartColors.ts +20 -0
  151. package/src/util/series/converters.ts +318 -0
  152. package/src/util/series/defaults.ts +210 -0
  153. package/src/util/series/index.ts +4 -0
  154. package/src/util/series/labels.ts +30 -0
  155. package/src/util/sparkline.ts +67 -0
  156. package/src/util/tooltips/buildBoxPlotTooltip.ts +66 -0
  157. package/src/util/tooltips/buildCartesianTooltip.ts +44 -0
  158. package/src/util/tooltips/buildGaugeTooltip.ts +49 -0
  159. package/src/util/tooltips/buildHeatmapTooltip.ts +57 -0
  160. package/src/util/tooltips/buildRadarTooltip.ts +53 -0
  161. package/src/util/tooltips/buildSharedItemTooltip.ts +38 -0
  162. package/src/util/tooltips/buildTreemapTooltip.ts +49 -0
  163. package/src/util/tooltips/index.ts +15 -0
  164. package/src/util/tooltips/render.ts +66 -0
  165. package/src/util/tooltips/types.ts +29 -0
@@ -0,0 +1,210 @@
1
+ import type {
2
+ BarSeriesOption,
3
+ BoxplotSeriesOption,
4
+ CandlestickSeriesOption,
5
+ GaugeSeriesOption,
6
+ HeatmapSeriesOption,
7
+ LineSeriesOption,
8
+ PieSeriesOption,
9
+ RadarSeriesOption,
10
+ ScatterSeriesOption,
11
+ TreemapSeriesOption
12
+ } from 'echarts/charts';
13
+
14
+ const SOFT_EMPHASIS = { focus: 'none' } as const;
15
+ const PIE_EMPHASIS = { focus: 'none', scale: true, scaleSize: 6 } as const;
16
+ const NO_EMPHASIS = { disabled: true } as const;
17
+ const PIE_SLICE_BORDER = { borderColor: 'var(--surface)', borderWidth: 2 };
18
+
19
+ const stagger = (step: number) => (idx: number) => idx * step;
20
+
21
+ export const LINE_SERIES_DEFAULTS: Partial<LineSeriesOption> = {
22
+ type: 'line',
23
+ smooth: true,
24
+ showSymbol: false,
25
+ emphasis: SOFT_EMPHASIS
26
+ };
27
+
28
+ export const AREA_SERIES_DEFAULTS: Partial<LineSeriesOption> = {
29
+ type: 'line',
30
+ smooth: true,
31
+ showSymbol: false,
32
+ areaStyle: { opacity: 0.25 },
33
+ lineStyle: { width: 2 },
34
+ emphasis: SOFT_EMPHASIS
35
+ };
36
+
37
+ export const BAR_SERIES_DEFAULTS: Partial<BarSeriesOption> = {
38
+ type: 'bar',
39
+ itemStyle: { borderRadius: 6 },
40
+ barCategoryGap: '25%',
41
+ emphasis: SOFT_EMPHASIS,
42
+ animationDelay: stagger(40),
43
+ animationDelayUpdate: stagger(20)
44
+ };
45
+
46
+ export const PIE_SERIES_DEFAULTS: Partial<PieSeriesOption> = {
47
+ type: 'pie',
48
+ radius: '75%',
49
+ label: { show: false },
50
+ itemStyle: { ...PIE_SLICE_BORDER, borderRadius: 6 },
51
+ selectedMode: false,
52
+ emphasis: PIE_EMPHASIS
53
+ };
54
+
55
+ export const DONUT_SERIES_DEFAULTS: Partial<PieSeriesOption> = {
56
+ type: 'pie',
57
+ radius: ['55%', '75%'],
58
+ padAngle: 1,
59
+ label: { show: false },
60
+ itemStyle: { ...PIE_SLICE_BORDER, borderRadius: 6 },
61
+ selectedMode: false,
62
+ emphasis: PIE_EMPHASIS
63
+ };
64
+
65
+ export const POLAR_AREA_SERIES_DEFAULTS: Partial<PieSeriesOption> = {
66
+ type: 'pie',
67
+ roseType: 'area',
68
+ radius: ['10%', '75%'],
69
+ padAngle: 1,
70
+ label: { show: false },
71
+ itemStyle: { ...PIE_SLICE_BORDER, opacity: 0.85, borderRadius: 6 },
72
+ selectedMode: false,
73
+ emphasis: PIE_EMPHASIS
74
+ };
75
+
76
+ export const RADAR_SERIES_DEFAULTS: Partial<RadarSeriesOption> = {
77
+ type: 'radar',
78
+ areaStyle: { opacity: 0.25 },
79
+ lineStyle: { width: 2.5 },
80
+ symbolSize: 6,
81
+ emphasis: SOFT_EMPHASIS
82
+ };
83
+
84
+ export const HEATMAP_SERIES_DEFAULTS: Partial<HeatmapSeriesOption> = {
85
+ type: 'heatmap',
86
+ itemStyle: {
87
+ borderColor: 'var(--surface)',
88
+ borderWidth: 2,
89
+ borderRadius: 6
90
+ },
91
+ label: { show: false },
92
+ emphasis: SOFT_EMPHASIS,
93
+ animationDelay: stagger(8),
94
+ animationDelayUpdate: stagger(4)
95
+ };
96
+
97
+ export const SCATTER_SERIES_DEFAULTS: Partial<ScatterSeriesOption> = {
98
+ type: 'scatter',
99
+ symbolSize: 14,
100
+ itemStyle: {
101
+ borderColor: 'var(--surface)',
102
+ borderWidth: 2,
103
+ opacity: 0.9
104
+ },
105
+ emphasis: SOFT_EMPHASIS,
106
+ animationDelay: stagger(25),
107
+ animationDelayUpdate: stagger(15)
108
+ };
109
+
110
+ export const BUBBLE_SERIES_DEFAULTS: Partial<ScatterSeriesOption> = {
111
+ type: 'scatter',
112
+ itemStyle: {
113
+ borderColor: 'var(--surface)',
114
+ borderWidth: 2,
115
+ opacity: 0.65
116
+ },
117
+ emphasis: SOFT_EMPHASIS,
118
+ animationDelay: stagger(25),
119
+ animationDelayUpdate: stagger(15)
120
+ };
121
+
122
+ export const BOXPLOT_SERIES_DEFAULTS: Partial<BoxplotSeriesOption> = {
123
+ type: 'boxplot',
124
+ itemStyle: {
125
+ color: 'var(--chart-1)',
126
+ borderColor: 'var(--foreground-prominent)',
127
+ borderWidth: 1
128
+ },
129
+ emphasis: SOFT_EMPHASIS,
130
+ animationDelay: stagger(60),
131
+ animationDelayUpdate: stagger(30)
132
+ };
133
+
134
+ export const CANDLESTICK_SERIES_DEFAULTS: Partial<CandlestickSeriesOption> = {
135
+ type: 'candlestick',
136
+ itemStyle: {
137
+ color: 'var(--success-500)',
138
+ color0: 'var(--danger-500)',
139
+ borderColor: 'var(--success-500)',
140
+ borderColor0: 'var(--danger-500)'
141
+ },
142
+ emphasis: SOFT_EMPHASIS,
143
+ animationDelay: stagger(30),
144
+ animationDelayUpdate: stagger(15)
145
+ };
146
+
147
+ export const TREEMAP_SERIES_DEFAULTS: Partial<TreemapSeriesOption> = {
148
+ type: 'treemap',
149
+ roam: false,
150
+ nodeClick: false,
151
+ breadcrumb: { show: false },
152
+ itemStyle: {
153
+ borderColor: 'var(--surface)',
154
+ borderWidth: 3,
155
+ borderRadius: 6,
156
+ gapWidth: 0
157
+ },
158
+ label: {
159
+ show: true,
160
+ color: 'var(--white)',
161
+ fontSize: 13,
162
+ fontWeight: 600,
163
+ fontFamily: 'inherit'
164
+ },
165
+ emphasis: SOFT_EMPHASIS
166
+ };
167
+
168
+ export const GAUGE_SERIES_DEFAULTS: Partial<GaugeSeriesOption> = {
169
+ type: 'gauge',
170
+ startAngle: 225,
171
+ endAngle: -45,
172
+ min: 0,
173
+ max: 100,
174
+ radius: '90%',
175
+ emphasis: NO_EMPHASIS,
176
+ progress: {
177
+ show: true,
178
+ width: 14,
179
+ roundCap: true
180
+ },
181
+ axisLine: {
182
+ lineStyle: {
183
+ width: 14,
184
+ color: [[1, 'var(--gray-100)']]
185
+ },
186
+ roundCap: true
187
+ },
188
+ axisTick: { show: false },
189
+ splitLine: { show: false },
190
+ axisLabel: { show: false },
191
+ pointer: { show: false },
192
+ anchor: { show: false },
193
+ title: {
194
+ show: true,
195
+ color: 'var(--foreground-secondary)',
196
+ fontSize: 12,
197
+ fontWeight: 500,
198
+ fontFamily: 'inherit',
199
+ offsetCenter: [0, '-30%']
200
+ },
201
+ detail: {
202
+ show: true,
203
+ color: 'var(--foreground-prominent)',
204
+ fontSize: 28,
205
+ fontWeight: 800,
206
+ fontFamily: 'inherit',
207
+ offsetCenter: [0, '10%'],
208
+ formatter: '{value}%'
209
+ }
210
+ };
@@ -0,0 +1,4 @@
1
+ export { CHART_DEFAULT_COLORS, resolveChartColor } from './chartColors';
2
+ export * from './converters';
3
+ export * from './defaults';
4
+ export { cartesianFallbackLabels, extractLabels } from './labels';
@@ -0,0 +1,30 @@
1
+ import type { FluxStatisticsChartCartesianSeries, FluxStatisticsChartCategoryPoint } from '@flux-ui/types';
2
+
3
+ export function extractLabels(
4
+ series: readonly { readonly data: readonly (number | FluxStatisticsChartCategoryPoint)[] }[]
5
+ ): readonly string[] | undefined {
6
+ for (const s of series) {
7
+ const labels: string[] = [];
8
+ let hasAny = false;
9
+
10
+ for (const point of s.data) {
11
+ if (typeof point === 'object' && point !== null && typeof point.label === 'string') {
12
+ labels.push(point.label);
13
+ hasAny = true;
14
+ } else {
15
+ labels.push('');
16
+ }
17
+ }
18
+
19
+ if (hasAny) {
20
+ return labels;
21
+ }
22
+ }
23
+
24
+ return undefined;
25
+ }
26
+
27
+ export function cartesianFallbackLabels(series: readonly FluxStatisticsChartCartesianSeries[]): string[] {
28
+ const longest = series.reduce((max, s) => Math.max(max, s.data.length), 0);
29
+ return Array.from({ length: longest }, (_, i) => String(i + 1));
30
+ }
@@ -0,0 +1,67 @@
1
+ import type { EChartsOption } from '~flux/statistics/composable';
2
+
3
+ export type SparklineVariant = 'line' | 'bar' | 'area';
4
+
5
+ export interface SparklineSeriesItem {
6
+ readonly name?: string;
7
+ readonly data: (number | string | null)[];
8
+ }
9
+
10
+ export function buildSparklineOptions(
11
+ variant: SparklineVariant,
12
+ color: string,
13
+ series: readonly SparklineSeriesItem[]
14
+ ): EChartsOption {
15
+ const data = series[0]?.data ?? [];
16
+
17
+ const base: EChartsOption = {
18
+ animation: false,
19
+ grid: {
20
+ left: 0,
21
+ right: 0,
22
+ top: 0,
23
+ bottom: 0,
24
+ containLabel: false
25
+ },
26
+ tooltip: { show: false },
27
+ xAxis: {
28
+ type: 'category',
29
+ show: false,
30
+ boundaryGap: variant === 'bar'
31
+ },
32
+ yAxis: {
33
+ type: 'value',
34
+ show: false,
35
+ scale: true
36
+ },
37
+ color: [color]
38
+ };
39
+
40
+ if (variant === 'bar') {
41
+ return {
42
+ ...base,
43
+ series: [{
44
+ type: 'bar',
45
+ data: data as never,
46
+ itemStyle: { borderRadius: 2 },
47
+ barCategoryGap: '40%',
48
+ emphasis: { disabled: true },
49
+ silent: true
50
+ }]
51
+ };
52
+ }
53
+
54
+ return {
55
+ ...base,
56
+ series: [{
57
+ type: 'line',
58
+ data: data as never,
59
+ smooth: true,
60
+ showSymbol: false,
61
+ lineStyle: { width: 2 },
62
+ areaStyle: variant === 'area' ? { opacity: 0.25 } : undefined,
63
+ emphasis: { disabled: true },
64
+ silent: true
65
+ }]
66
+ };
67
+ }
@@ -0,0 +1,66 @@
1
+ import type { FluxIconName } from '@flux-ui/types';
2
+ import type { EChartsOption } from '~flux/statistics/composable';
3
+ import { renderTooltip } from './render';
4
+ import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
5
+
6
+ export interface BoxPlotTooltipPoint {
7
+ readonly label?: string;
8
+ readonly min: number;
9
+ readonly q1: number;
10
+ readonly median: number;
11
+ readonly q3: number;
12
+ readonly max: number;
13
+ }
14
+
15
+ export interface BoxPlotTooltipInput {
16
+ readonly t: Translator;
17
+ readonly styles: TooltipStyleClasses;
18
+ readonly getSeries: () => readonly { readonly name?: string; readonly icon?: FluxIconName; readonly data: readonly BoxPlotTooltipPoint[] }[];
19
+ readonly getPalette: () => readonly string[];
20
+ }
21
+
22
+ export function buildBoxPlotTooltip(input: BoxPlotTooltipInput): EChartsOption {
23
+ const { t, styles, getSeries, getPalette } = input;
24
+
25
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
26
+ const param = Array.isArray(params) ? params[0] : params;
27
+
28
+ if (!param) {
29
+ return '';
30
+ }
31
+
32
+ const series = getSeries();
33
+ const palette = getPalette();
34
+ const seriesIndex = param.seriesIndex ?? 0;
35
+ const dataIndex = param.dataIndex ?? 0;
36
+ const s = series[seriesIndex];
37
+ const point = s?.data[dataIndex];
38
+
39
+ if (!s || !point) {
40
+ return '';
41
+ }
42
+
43
+ const color = palette[seriesIndex % palette.length];
44
+ const seriesName = s.name ? t(String(s.name)) : '';
45
+ const pointLabel = point.label ? t(String(point.label)) : '';
46
+ const title = [seriesName, pointLabel].filter(Boolean).join(' — ');
47
+
48
+ const items: SharedTooltipItem[] = [
49
+ { name: 'Min', value: point.min, color },
50
+ { name: 'Q1', value: point.q1, color },
51
+ { name: 'Median', value: point.median, color },
52
+ { name: 'Q3', value: point.q3, color },
53
+ { name: 'Max', value: point.max, color }
54
+ ];
55
+
56
+ return renderTooltip(t, styles, title, items);
57
+ };
58
+
59
+ return {
60
+ tooltip: {
61
+ show: true,
62
+ trigger: 'item',
63
+ formatter: formatter as never
64
+ }
65
+ };
66
+ }
@@ -0,0 +1,44 @@
1
+ import type { FluxIconName } from '@flux-ui/types';
2
+ import type { EChartsOption } from '~flux/statistics/composable';
3
+ import { extractValue, renderTooltip } from './render';
4
+ import type { ChartTooltipValueFormatter, TooltipParam, TooltipStyleClasses, Translator } from './types';
5
+
6
+ export interface CartesianTooltipInput {
7
+ readonly t: Translator;
8
+ readonly styles: TooltipStyleClasses;
9
+ readonly getSeriesIcons: () => readonly (FluxIconName | undefined)[];
10
+ readonly valueFormatter?: ChartTooltipValueFormatter;
11
+ }
12
+
13
+ export function buildCartesianTooltip(input: CartesianTooltipInput): EChartsOption {
14
+ const { t, styles, getSeriesIcons, valueFormatter } = input;
15
+
16
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
17
+ const items = Array.isArray(params) ? params : [params];
18
+
19
+ if (items.length === 0) {
20
+ return '';
21
+ }
22
+
23
+ const rawTitle = items[0].axisValueLabel ?? items[0].axisValue ?? items[0].name ?? '';
24
+ const title = rawTitle ? t(String(rawTitle)) : '';
25
+ const icons = getSeriesIcons();
26
+
27
+ return renderTooltip(t, styles, title, items.map(param => ({
28
+ name: param.seriesName ?? '',
29
+ value: extractValue(param.value),
30
+ color: param.color,
31
+ icon: icons[param.seriesIndex],
32
+ seriesIndex: param.seriesIndex,
33
+ dataIndex: param.dataIndex
34
+ })), -1, valueFormatter);
35
+ };
36
+
37
+ return {
38
+ tooltip: {
39
+ show: true,
40
+ trigger: 'axis',
41
+ formatter: formatter as never
42
+ }
43
+ };
44
+ }
@@ -0,0 +1,49 @@
1
+ import type { FluxIconName } from '@flux-ui/types';
2
+ import type { EChartsOption } from '~flux/statistics/composable';
3
+ import { renderTooltip } from './render';
4
+ import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
5
+
6
+ export interface GaugeTooltipInput {
7
+ readonly t: Translator;
8
+ readonly styles: TooltipStyleClasses;
9
+ readonly getSeries: () => readonly { readonly name?: string; readonly value: number; readonly icon?: FluxIconName }[];
10
+ readonly getPalette: () => readonly string[];
11
+ }
12
+
13
+ export function buildGaugeTooltip(input: GaugeTooltipInput): EChartsOption {
14
+ const { t, styles, getSeries, getPalette } = input;
15
+
16
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
17
+ const param = Array.isArray(params) ? params[0] : params;
18
+
19
+ if (!param) {
20
+ return '';
21
+ }
22
+
23
+ const series = getSeries();
24
+ const palette = getPalette();
25
+ const seriesIndex = param.seriesIndex ?? 0;
26
+ const s = series[seriesIndex];
27
+
28
+ if (!s) {
29
+ return '';
30
+ }
31
+
32
+ const color = palette[seriesIndex % palette.length];
33
+ const title = s.name ? t(String(s.name)) : '';
34
+
35
+ const items: SharedTooltipItem[] = [
36
+ { name: '', value: s.value, color, icon: s.icon }
37
+ ];
38
+
39
+ return renderTooltip(t, styles, title, items);
40
+ };
41
+
42
+ return {
43
+ tooltip: {
44
+ show: true,
45
+ trigger: 'item',
46
+ formatter: formatter as never
47
+ }
48
+ };
49
+ }
@@ -0,0 +1,57 @@
1
+ import type { EChartsOption } from '~flux/statistics/composable';
2
+ import { renderTooltip } from './render';
3
+ import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
4
+
5
+ export interface HeatmapTooltipPoint {
6
+ readonly x: string | number;
7
+ readonly y: string | number;
8
+ readonly value: number;
9
+ readonly formatted?: string;
10
+ }
11
+
12
+ export interface HeatmapTooltipInput {
13
+ readonly t: Translator;
14
+ readonly styles: TooltipStyleClasses;
15
+ readonly getSeries: () => readonly { readonly name?: string; readonly data: readonly HeatmapTooltipPoint[] }[];
16
+ }
17
+
18
+ export function buildHeatmapTooltip(input: HeatmapTooltipInput): EChartsOption {
19
+ const { t, styles, getSeries } = input;
20
+
21
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
22
+ const param = Array.isArray(params) ? params[0] : params;
23
+
24
+ if (!param) {
25
+ return '';
26
+ }
27
+
28
+ const series = getSeries();
29
+ const seriesIndex = param.seriesIndex ?? 0;
30
+ const dataIndex = param.dataIndex ?? 0;
31
+ const s = series[seriesIndex];
32
+ const point = s?.data[dataIndex];
33
+
34
+ if (!s || !point) {
35
+ return '';
36
+ }
37
+
38
+ const seriesName = s.name ? t(String(s.name)) : '';
39
+ const xLabel = t(String(point.x));
40
+ const yLabel = t(String(point.y));
41
+ const title = [seriesName, `${xLabel} · ${yLabel}`].filter(Boolean).join(' — ');
42
+
43
+ const items: SharedTooltipItem[] = [
44
+ { name: '', value: point.formatted ?? point.value, color: 'var(--primary-600)' }
45
+ ];
46
+
47
+ return renderTooltip(t, styles, title, items);
48
+ };
49
+
50
+ return {
51
+ tooltip: {
52
+ show: true,
53
+ trigger: 'item',
54
+ formatter: formatter as never
55
+ }
56
+ };
57
+ }
@@ -0,0 +1,53 @@
1
+ import type { FluxStatisticsChartRadarIndicator, FluxStatisticsChartRadarSeries } from '@flux-ui/types';
2
+ import type { EChartsOption } from '~flux/statistics/composable';
3
+ import { renderTooltip } from './render';
4
+ import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
5
+
6
+ export interface RadarTooltipInput {
7
+ readonly t: Translator;
8
+ readonly styles: TooltipStyleClasses;
9
+ readonly getSeries: () => readonly FluxStatisticsChartRadarSeries[];
10
+ readonly getIndicators: () => readonly FluxStatisticsChartRadarIndicator[];
11
+ readonly getPalette: () => readonly string[];
12
+ }
13
+
14
+ export function buildRadarTooltip(input: RadarTooltipInput): EChartsOption {
15
+ const { t, styles, getSeries, getIndicators, getPalette } = input;
16
+
17
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
18
+ const param = Array.isArray(params) ? params[0] : params;
19
+
20
+ if (!param) {
21
+ return '';
22
+ }
23
+
24
+ const series = getSeries();
25
+ const indicators = getIndicators();
26
+ const palette = getPalette();
27
+ const ringIndex = param.dataIndex ?? 0;
28
+ const ring = series[ringIndex];
29
+
30
+ if (!ring) {
31
+ return '';
32
+ }
33
+
34
+ const color = palette[ringIndex % palette.length];
35
+ const title = ring.name ? t(String(ring.name)) : '';
36
+
37
+ const items: SharedTooltipItem[] = indicators.map((indicator, idx) => ({
38
+ name: indicator.name,
39
+ value: ring.values[idx] ?? '',
40
+ color
41
+ }));
42
+
43
+ return renderTooltip(t, styles, title, items);
44
+ };
45
+
46
+ return {
47
+ tooltip: {
48
+ show: true,
49
+ trigger: 'item',
50
+ formatter: formatter as never
51
+ }
52
+ };
53
+ }
@@ -0,0 +1,38 @@
1
+ import type { EChartsOption } from '~flux/statistics/composable';
2
+ import { renderTooltip } from './render';
3
+ import type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
4
+
5
+ export interface SharedItemTooltipInput {
6
+ readonly t: Translator;
7
+ readonly styles: TooltipStyleClasses;
8
+ readonly getItems: () => readonly SharedTooltipItem[];
9
+ readonly getTitle?: () => string | undefined;
10
+ readonly valueFormatter?: ChartTooltipValueFormatter;
11
+ }
12
+
13
+ export function buildSharedItemTooltip(input: SharedItemTooltipInput): EChartsOption {
14
+ const { t, styles, getItems, getTitle, valueFormatter } = input;
15
+
16
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
17
+ const param = Array.isArray(params) ? params[0] : params;
18
+
19
+ if (!param) {
20
+ return '';
21
+ }
22
+
23
+ const items = getItems();
24
+ const activeIndex = param.dataIndex ?? -1;
25
+ const rawTitle = getTitle?.() ?? '';
26
+ const title = rawTitle ? t(String(rawTitle)) : '';
27
+
28
+ return renderTooltip(t, styles, title, items, activeIndex, valueFormatter);
29
+ };
30
+
31
+ return {
32
+ tooltip: {
33
+ show: true,
34
+ trigger: 'item',
35
+ formatter: formatter as never
36
+ }
37
+ };
38
+ }
@@ -0,0 +1,49 @@
1
+ import type { EChartsOption } from '~flux/statistics/composable';
2
+ import { renderTooltip } from './render';
3
+ import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
4
+
5
+ export interface TreemapTooltipNode {
6
+ readonly name: string;
7
+ readonly value?: number;
8
+ readonly color?: string;
9
+ }
10
+
11
+ export interface TreemapTooltipInput {
12
+ readonly t: Translator;
13
+ readonly styles: TooltipStyleClasses;
14
+ }
15
+
16
+ export function buildTreemapTooltip(input: TreemapTooltipInput): EChartsOption {
17
+ const { t, styles } = input;
18
+
19
+ const formatter = (params: TooltipParam | TooltipParam[]): string => {
20
+ const param = Array.isArray(params) ? params[0] : params;
21
+
22
+ if (!param) {
23
+ return '';
24
+ }
25
+
26
+ const data = param.data as TreemapTooltipNode | undefined;
27
+
28
+ if (!data) {
29
+ return '';
30
+ }
31
+
32
+ const color = data.color ?? 'var(--primary-600)';
33
+ const title = data.name ? t(String(data.name)) : '';
34
+
35
+ const items: SharedTooltipItem[] = [
36
+ { name: '', value: data.value ?? '', color }
37
+ ];
38
+
39
+ return renderTooltip(t, styles, title, items);
40
+ };
41
+
42
+ return {
43
+ tooltip: {
44
+ show: true,
45
+ trigger: 'item',
46
+ formatter: formatter as never
47
+ }
48
+ };
49
+ }
@@ -0,0 +1,15 @@
1
+ export type { BoxPlotTooltipInput, BoxPlotTooltipPoint } from './buildBoxPlotTooltip';
2
+ export { buildBoxPlotTooltip } from './buildBoxPlotTooltip';
3
+ export type { CartesianTooltipInput } from './buildCartesianTooltip';
4
+ export { buildCartesianTooltip } from './buildCartesianTooltip';
5
+ export type { GaugeTooltipInput } from './buildGaugeTooltip';
6
+ export { buildGaugeTooltip } from './buildGaugeTooltip';
7
+ export type { HeatmapTooltipInput, HeatmapTooltipPoint } from './buildHeatmapTooltip';
8
+ export { buildHeatmapTooltip } from './buildHeatmapTooltip';
9
+ export type { RadarTooltipInput } from './buildRadarTooltip';
10
+ export { buildRadarTooltip } from './buildRadarTooltip';
11
+ export type { SharedItemTooltipInput } from './buildSharedItemTooltip';
12
+ export { buildSharedItemTooltip } from './buildSharedItemTooltip';
13
+ export type { TreemapTooltipInput, TreemapTooltipNode } from './buildTreemapTooltip';
14
+ export { buildTreemapTooltip } from './buildTreemapTooltip';
15
+ export type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';