@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.
- package/README.md +1 -1
- package/dist/component/FluxStatisticsAreaChart.vue.d.ts +11 -4
- package/dist/component/FluxStatisticsBarChart.vue.d.ts +11 -4
- package/dist/component/FluxStatisticsBase.vue.d.ts +1 -0
- package/dist/component/FluxStatisticsBoxPlotChart.vue.d.ts +15 -0
- package/dist/component/FluxStatisticsBubbleChart.vue.d.ts +14 -0
- package/dist/component/FluxStatisticsCandlestickChart.vue.d.ts +15 -0
- package/dist/component/FluxStatisticsChart.vue.d.ts +7 -5
- package/dist/component/FluxStatisticsChartPane.vue.d.ts +1 -0
- package/dist/component/FluxStatisticsComparison.vue.d.ts +16 -0
- package/dist/component/FluxStatisticsDonutChart.vue.d.ts +8 -4
- package/dist/component/FluxStatisticsEmpty.vue.d.ts +19 -0
- package/dist/component/FluxStatisticsHeatmapChart.vue.d.ts +15 -0
- package/dist/component/FluxStatisticsLegendItem.vue.d.ts +1 -0
- package/dist/component/FluxStatisticsLegendScope.vue.d.ts +13 -0
- package/dist/component/FluxStatisticsLineChart.vue.d.ts +11 -4
- package/dist/component/FluxStatisticsMixedChart.vue.d.ts +17 -0
- package/dist/component/FluxStatisticsPercentageBar.vue.d.ts +8 -0
- package/dist/component/FluxStatisticsPieChart.vue.d.ts +8 -4
- package/dist/component/FluxStatisticsPolarAreaChart.vue.d.ts +14 -0
- package/dist/component/FluxStatisticsRadarChart.vue.d.ts +12 -0
- package/dist/component/FluxStatisticsRadialBar.vue.d.ts +11 -0
- package/dist/component/FluxStatisticsScatterChart.vue.d.ts +14 -0
- package/dist/component/FluxStatisticsSparkline.vue.d.ts +13 -0
- package/dist/component/FluxStatisticsTreemapChart.vue.d.ts +11 -0
- package/dist/component/index.d.ts +15 -0
- package/dist/composable/index.d.ts +12 -0
- package/dist/composable/useChartBaseSetup.d.ts +8 -0
- package/dist/composable/useChartHoverSync.d.ts +9 -0
- package/dist/composable/useChartLegend.d.ts +14 -0
- package/dist/composable/useChartSeriesSetup.d.ts +23 -0
- package/dist/composable/useChartSlicesSetup.d.ts +14 -0
- package/dist/composable/useECharts.d.ts +9 -0
- package/dist/echarts.d.ts +1 -0
- package/dist/index.css +262 -34
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9176 -6895
- package/dist/index.js.map +1 -1
- package/dist/util/colors.d.ts +4 -0
- package/dist/util/icons.d.ts +2 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/options/buildBaseOptions.d.ts +2 -0
- package/dist/util/options/buildCartesianBaseOptions.d.ts +13 -0
- package/dist/util/options/buildCircularBaseOptions.d.ts +2 -0
- package/dist/util/options/cartesian/buildAreaChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildBarChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildBoxPlotChartOptions.d.ts +16 -0
- package/dist/util/options/cartesian/buildBubbleChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/buildCandlestickChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildHeatmapChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/buildLineChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildMixedChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildScatterChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/index.d.ts +18 -0
- package/dist/util/options/circular/buildDonutChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildGaugeChartOptions.d.ts +14 -0
- package/dist/util/options/circular/buildPieChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildPolarAreaChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildRadarChartOptions.d.ts +13 -0
- package/dist/util/options/circular/buildTreemapChartOptions.d.ts +12 -0
- package/dist/util/options/circular/index.d.ts +12 -0
- package/dist/util/options/index.d.ts +6 -0
- package/dist/util/series/chartColors.d.ts +3 -0
- package/dist/util/series/converters.d.ts +17 -0
- package/dist/util/series/defaults.d.ts +15 -0
- package/dist/util/series/index.d.ts +4 -0
- package/dist/util/series/labels.d.ts +5 -0
- package/dist/util/sparkline.d.ts +7 -0
- package/dist/util/tooltips/buildBoxPlotTooltip.d.ts +22 -0
- package/dist/util/tooltips/buildCartesianTooltip.d.ts +10 -0
- package/dist/util/tooltips/buildGaugeTooltip.d.ts +14 -0
- package/dist/util/tooltips/buildHeatmapTooltip.d.ts +17 -0
- package/dist/util/tooltips/buildRadarTooltip.d.ts +11 -0
- package/dist/util/tooltips/buildSharedItemTooltip.d.ts +10 -0
- package/dist/util/tooltips/buildTreemapTooltip.d.ts +12 -0
- package/dist/util/tooltips/index.d.ts +15 -0
- package/dist/util/tooltips/render.d.ts +4 -0
- package/dist/util/tooltips/types.d.ts +24 -0
- package/package.json +14 -15
- package/src/component/FluxStatisticsAreaChart.vue +36 -43
- package/src/component/FluxStatisticsBarChart.vue +36 -35
- package/src/component/FluxStatisticsBase.vue +14 -1
- package/src/component/FluxStatisticsBoxPlotChart.vue +49 -0
- package/src/component/FluxStatisticsBubbleChart.vue +46 -0
- package/src/component/FluxStatisticsCandlestickChart.vue +50 -0
- package/src/component/FluxStatisticsChart.vue +19 -169
- package/src/component/FluxStatisticsChartPane.vue +22 -11
- package/src/component/FluxStatisticsComparison.vue +113 -0
- package/src/component/FluxStatisticsDonutChart.vue +31 -19
- package/src/component/FluxStatisticsEmpty.vue +44 -0
- package/src/component/FluxStatisticsHeatmapChart.vue +47 -0
- package/src/component/FluxStatisticsLegend.vue +33 -1
- package/src/component/FluxStatisticsLegendItem.vue +3 -1
- package/src/component/FluxStatisticsLegendScope.vue +16 -0
- package/src/component/FluxStatisticsLineChart.vue +36 -43
- package/src/component/FluxStatisticsMixedChart.vue +52 -0
- package/src/component/FluxStatisticsPercentageBar.vue +90 -0
- package/src/component/FluxStatisticsPieChart.vue +31 -19
- package/src/component/FluxStatisticsPolarAreaChart.vue +44 -0
- package/src/component/FluxStatisticsRadarChart.vue +40 -0
- package/src/component/FluxStatisticsRadialBar.vue +39 -0
- package/src/component/FluxStatisticsScatterChart.vue +46 -0
- package/src/component/FluxStatisticsSparkline.vue +67 -0
- package/src/component/FluxStatisticsTreemapChart.vue +35 -0
- package/src/component/index.ts +15 -0
- package/src/composable/index.ts +12 -0
- package/src/composable/useChartBaseSetup.ts +16 -0
- package/src/composable/useChartHoverSync.ts +92 -0
- package/src/composable/useChartLegend.ts +23 -0
- package/src/composable/useChartSeriesSetup.ts +75 -0
- package/src/composable/useChartSlicesSetup.ts +58 -0
- package/src/composable/useECharts.ts +55 -0
- package/src/css/Base.module.scss +28 -1
- package/src/css/Chart.module.scss +59 -30
- package/src/css/ChartPane.module.scss +20 -12
- package/src/css/Comparison.module.scss +52 -0
- package/src/css/Empty.module.scss +39 -0
- package/src/css/Grid.module.scss +1 -0
- package/src/css/Legend.module.scss +22 -4
- package/src/css/Meter.module.scss +1 -0
- package/src/css/Metric.module.scss +6 -0
- package/src/css/PercentageBar.module.scss +36 -0
- package/src/css/Sparkline.module.scss +13 -0
- package/src/echarts.ts +47 -0
- package/src/index.ts +7 -3
- package/src/util/colors.ts +86 -0
- package/src/util/icons.ts +20 -0
- package/src/util/index.ts +6 -0
- package/src/util/options/buildBaseOptions.ts +31 -0
- package/src/util/options/buildCartesianBaseOptions.ts +67 -0
- package/src/util/options/buildCircularBaseOptions.ts +10 -0
- package/src/util/options/cartesian/buildAreaChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildBarChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildBoxPlotChartOptions.ts +63 -0
- package/src/util/options/cartesian/buildBubbleChartOptions.ts +48 -0
- package/src/util/options/cartesian/buildCandlestickChartOptions.ts +77 -0
- package/src/util/options/cartesian/buildHeatmapChartOptions.ts +72 -0
- package/src/util/options/cartesian/buildLineChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildMixedChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildScatterChartOptions.ts +48 -0
- package/src/util/options/cartesian/index.ts +18 -0
- package/src/util/options/circular/buildDonutChartOptions.ts +31 -0
- package/src/util/options/circular/buildGaugeChartOptions.ts +45 -0
- package/src/util/options/circular/buildPieChartOptions.ts +31 -0
- package/src/util/options/circular/buildPolarAreaChartOptions.ts +31 -0
- package/src/util/options/circular/buildRadarChartOptions.ts +52 -0
- package/src/util/options/circular/buildTreemapChartOptions.ts +28 -0
- package/src/util/options/circular/index.ts +12 -0
- package/src/util/options/index.ts +6 -0
- package/src/util/series/chartColors.ts +20 -0
- package/src/util/series/converters.ts +318 -0
- package/src/util/series/defaults.ts +210 -0
- package/src/util/series/index.ts +4 -0
- package/src/util/series/labels.ts +30 -0
- package/src/util/sparkline.ts +67 -0
- package/src/util/tooltips/buildBoxPlotTooltip.ts +66 -0
- package/src/util/tooltips/buildCartesianTooltip.ts +44 -0
- package/src/util/tooltips/buildGaugeTooltip.ts +49 -0
- package/src/util/tooltips/buildHeatmapTooltip.ts +57 -0
- package/src/util/tooltips/buildRadarTooltip.ts +53 -0
- package/src/util/tooltips/buildSharedItemTooltip.ts +38 -0
- package/src/util/tooltips/buildTreemapTooltip.ts +49 -0
- package/src/util/tooltips/index.ts +15 -0
- package/src/util/tooltips/render.ts +66 -0
- package/src/util/tooltips/types.ts +29 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { formatNumber } from '@basmilius/utils';
|
|
2
|
+
import { renderIconSvg } from '../icons';
|
|
3
|
+
import type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
4
|
+
|
|
5
|
+
export function renderTooltip(
|
|
6
|
+
t: Translator,
|
|
7
|
+
styles: TooltipStyleClasses,
|
|
8
|
+
title: string,
|
|
9
|
+
items: readonly SharedTooltipItem[],
|
|
10
|
+
activeIndex: number = -1,
|
|
11
|
+
valueFormatter?: ChartTooltipValueFormatter
|
|
12
|
+
): string {
|
|
13
|
+
if (items.length === 0) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const titleHtml = title
|
|
18
|
+
? `<div class="${styles.statisticsChartTooltipTitle}">${title}</div>`
|
|
19
|
+
: '';
|
|
20
|
+
|
|
21
|
+
const hasActive = activeIndex !== -1;
|
|
22
|
+
|
|
23
|
+
const body = items.map((item, idx) => {
|
|
24
|
+
const isActive = !hasActive || idx === activeIndex;
|
|
25
|
+
const activeClass = isActive ? ` ${styles.isActive}` : '';
|
|
26
|
+
const translatedName = item.name ? t(String(item.name)) : '';
|
|
27
|
+
|
|
28
|
+
const marker = item.icon
|
|
29
|
+
? `<div class="${styles.statisticsChartTooltipSeriesIcon}${activeClass}" style="color: ${item.color}">${renderIconSvg(item.icon, item.color, 14)}</div>`
|
|
30
|
+
: `<div class="${styles.statisticsChartTooltipSeriesColor}${activeClass}" style="background: ${item.color}"></div>`;
|
|
31
|
+
|
|
32
|
+
const display = valueFormatter ? valueFormatter(item.value, item) : formatValue(item.value);
|
|
33
|
+
|
|
34
|
+
return `
|
|
35
|
+
${marker}
|
|
36
|
+
<div class="${styles.statisticsChartTooltipSeriesName}${activeClass}">${translatedName}</div>
|
|
37
|
+
<div class="${styles.statisticsChartTooltipSeriesValue}${activeClass}">${display}</div>
|
|
38
|
+
`;
|
|
39
|
+
}).join('');
|
|
40
|
+
|
|
41
|
+
return `<div class="${styles.statisticsChartTooltip}">${titleHtml}<div class="${styles.statisticsChartTooltipBody}">${body}</div></div>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function extractValue(value: TooltipParam['value']): number | string {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
const last = value[value.length - 1];
|
|
47
|
+
return typeof last === 'number' || typeof last === 'string' ? last : '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return value ?? '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function formatValue(value: TooltipParam['value']): string {
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
const last = value[value.length - 1];
|
|
56
|
+
return formatValue(last);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof value === 'number') {
|
|
60
|
+
return Number.isInteger(value)
|
|
61
|
+
? formatNumber(value)
|
|
62
|
+
: value.toString();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return String(value ?? '');
|
|
66
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
2
|
+
|
|
3
|
+
export interface TooltipParam {
|
|
4
|
+
readonly seriesName?: string;
|
|
5
|
+
readonly seriesIndex: number;
|
|
6
|
+
readonly color: string;
|
|
7
|
+
readonly value: number | string | (number | string)[];
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly dataIndex?: number;
|
|
10
|
+
readonly axisValue?: string;
|
|
11
|
+
readonly axisValueLabel?: string;
|
|
12
|
+
readonly data?: unknown;
|
|
13
|
+
readonly marker?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TooltipStyleClasses = Readonly<Record<string, string>>;
|
|
17
|
+
|
|
18
|
+
export type Translator = (key: string) => string;
|
|
19
|
+
|
|
20
|
+
export interface SharedTooltipItem {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly value: number | string;
|
|
23
|
+
readonly color: string;
|
|
24
|
+
readonly icon?: FluxIconName;
|
|
25
|
+
readonly seriesIndex?: number;
|
|
26
|
+
readonly dataIndex?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ChartTooltipValueFormatter = (value: number | string, item: SharedTooltipItem) => string;
|