@flux-ui/statistics 3.0.0-next.67 → 3.0.0-next.68
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/FluxStatisticsLineChart.vue.d.ts +11 -4
- package/dist/component/FluxStatisticsMixedChart.vue.d.ts +17 -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 +13 -0
- package/dist/composable/index.d.ts +10 -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/useECharts.d.ts +9 -0
- package/dist/composable/usePieSlicesSetup.d.ts +14 -0
- package/dist/echarts.d.ts +1 -0
- package/dist/index.css +230 -37
- package/dist/index.d.ts +5 -2
- package/dist/index.js +10919 -9041
- package/dist/index.js.map +1 -1
- package/dist/util/baseOptions.d.ts +15 -0
- package/dist/util/colors.d.ts +4 -0
- package/dist/util/convert.d.ts +22 -0
- package/dist/util/defaultOptions.d.ts +76 -0
- package/dist/util/iconSvg.d.ts +2 -0
- package/dist/util/index.d.ts +7 -0
- package/dist/util/seriesDefaults.d.ts +15 -0
- package/dist/util/sparklineOptions.d.ts +7 -0
- package/package.json +14 -15
- package/src/component/FluxStatisticsAreaChart.vue +38 -41
- package/src/component/FluxStatisticsBarChart.vue +38 -33
- package/src/component/FluxStatisticsBase.vue +14 -1
- package/src/component/FluxStatisticsBoxPlotChart.vue +69 -0
- package/src/component/FluxStatisticsBubbleChart.vue +56 -0
- package/src/component/FluxStatisticsCandlestickChart.vue +81 -0
- package/src/component/FluxStatisticsChart.vue +19 -169
- package/src/component/FluxStatisticsChartPane.vue +23 -11
- package/src/component/FluxStatisticsComparison.vue +113 -0
- package/src/component/FluxStatisticsDonutChart.vue +39 -18
- package/src/component/FluxStatisticsEmpty.vue +44 -0
- package/src/component/FluxStatisticsHeatmapChart.vue +80 -0
- package/src/component/FluxStatisticsLegend.vue +33 -1
- package/src/component/FluxStatisticsLegendItem.vue +3 -1
- package/src/component/FluxStatisticsLineChart.vue +38 -41
- package/src/component/FluxStatisticsMixedChart.vue +55 -0
- package/src/component/FluxStatisticsPieChart.vue +39 -18
- package/src/component/FluxStatisticsPolarAreaChart.vue +53 -0
- package/src/component/FluxStatisticsRadarChart.vue +108 -0
- package/src/component/FluxStatisticsRadialBar.vue +48 -0
- package/src/component/FluxStatisticsScatterChart.vue +56 -0
- package/src/component/FluxStatisticsSparkline.vue +67 -0
- package/src/component/FluxStatisticsTreemapChart.vue +39 -0
- package/src/component/index.ts +13 -0
- package/src/composable/index.ts +10 -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/useECharts.ts +55 -0
- package/src/composable/usePieSlicesSetup.ts +58 -0
- package/src/css/Base.module.scss +28 -1
- package/src/css/Chart.module.scss +66 -32
- package/src/css/ChartPane.module.scss +24 -9
- 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 +11 -1
- package/src/css/Metric.module.scss +6 -0
- package/src/css/Sparkline.module.scss +13 -0
- package/src/echarts.ts +47 -0
- package/src/index.ts +7 -3
- package/src/util/baseOptions.ts +74 -0
- package/src/util/colors.ts +86 -0
- package/src/util/convert.ts +360 -0
- package/src/util/defaultOptions.ts +398 -0
- package/src/util/iconSvg.ts +20 -0
- package/src/util/index.ts +7 -0
- package/src/util/seriesDefaults.ts +210 -0
- package/src/util/sparklineOptions.ts +67 -0
|
@@ -1,59 +1,56 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Chart
|
|
3
|
-
|
|
4
|
-
:options="
|
|
5
|
-
chart: {
|
|
6
|
-
type: 'line',
|
|
7
|
-
sparkline: {
|
|
8
|
-
enabled: true
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
fill: {
|
|
12
|
-
gradient: {
|
|
13
|
-
enabled: true,
|
|
14
|
-
opacityFrom: 0.5,
|
|
15
|
-
opacityTo: 0
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
grid: {
|
|
19
|
-
show: true,
|
|
20
|
-
clipMarkers: false
|
|
21
|
-
},
|
|
22
|
-
legend: {
|
|
23
|
-
show: false
|
|
24
|
-
},
|
|
25
|
-
stroke: {
|
|
26
|
-
curve: 'smooth',
|
|
27
|
-
width: 2
|
|
28
|
-
}
|
|
29
|
-
}, options)"
|
|
30
|
-
:series="translatedSeries"/>
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
31
5
|
</template>
|
|
32
6
|
|
|
33
7
|
<script
|
|
34
8
|
lang="ts"
|
|
35
9
|
setup>
|
|
36
|
-
import type {
|
|
10
|
+
import type { FluxStatisticsChartLineSeries } from '@flux-ui/types';
|
|
37
11
|
import { merge } from 'lodash-es';
|
|
38
12
|
import { computed } from 'vue';
|
|
39
|
-
import {
|
|
13
|
+
import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toLineSeries } from '~flux/statistics/util';
|
|
40
15
|
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
41
17
|
|
|
42
18
|
const {
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
labels,
|
|
21
|
+
series,
|
|
22
|
+
splitLines = false,
|
|
23
|
+
tooltip = false,
|
|
24
|
+
tooltipValueFormatter,
|
|
25
|
+
xAxisLabels = false,
|
|
26
|
+
yAxisLabels = false
|
|
45
27
|
} = defineProps<{
|
|
46
|
-
readonly
|
|
47
|
-
readonly
|
|
48
|
-
readonly series:
|
|
28
|
+
readonly advancedOptions?: EChartsOption;
|
|
29
|
+
readonly labels?: readonly string[];
|
|
30
|
+
readonly series: readonly FluxStatisticsChartLineSeries[];
|
|
31
|
+
readonly splitLines?: boolean;
|
|
32
|
+
readonly tooltip?: boolean;
|
|
33
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
34
|
+
readonly xAxisLabels?: boolean;
|
|
35
|
+
readonly yAxisLabels?: boolean;
|
|
49
36
|
}>();
|
|
50
37
|
|
|
51
|
-
const {t} =
|
|
38
|
+
const { t, palette } = useChartSeriesSetup(() => series);
|
|
52
39
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
const xLabels = computed<readonly string[]>(() => labels ?? extractLabels(series) ?? cartesianFallbackLabels(series));
|
|
41
|
+
|
|
42
|
+
const echartsSeries = computed(() => series.map((s, i) =>
|
|
43
|
+
toLineSeries({ ...s, name: s.name ? t(String(s.name)) : undefined }, palette.value[i])
|
|
44
|
+
));
|
|
45
|
+
|
|
46
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
47
|
+
const base = buildCartesianBaseOptions({ xAxisLabels, yAxisLabels, splitLines });
|
|
48
|
+
const xAxisOverride: EChartsOption = { xAxis: { type: 'category', data: xLabels.value as string[], boundaryGap: false } };
|
|
49
|
+
|
|
50
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
51
|
+
? buildCartesianTooltipOptions(t, $style as never, () => series.map(s => s.icon), tooltipValueFormatter)
|
|
52
|
+
: { tooltip: { show: false } };
|
|
53
|
+
|
|
54
|
+
return merge({}, base, xAxisOverride, tooltipOptions, advancedOptions, { series: echartsSeries.value, color: palette.value });
|
|
58
55
|
});
|
|
59
56
|
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
lang="ts"
|
|
9
|
+
setup>
|
|
10
|
+
import type { FluxStatisticsChartMixedSeries } from '@flux-ui/types';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toMixedSeries } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
labels,
|
|
21
|
+
series,
|
|
22
|
+
splitLines = false,
|
|
23
|
+
tooltip = false,
|
|
24
|
+
tooltipValueFormatter,
|
|
25
|
+
xAxisLabels = false,
|
|
26
|
+
yAxisLabels = false
|
|
27
|
+
} = defineProps<{
|
|
28
|
+
readonly advancedOptions?: EChartsOption;
|
|
29
|
+
readonly labels?: readonly string[];
|
|
30
|
+
readonly series: readonly FluxStatisticsChartMixedSeries[];
|
|
31
|
+
readonly splitLines?: boolean;
|
|
32
|
+
readonly tooltip?: boolean;
|
|
33
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
34
|
+
readonly xAxisLabels?: boolean;
|
|
35
|
+
readonly yAxisLabels?: boolean;
|
|
36
|
+
}>();
|
|
37
|
+
|
|
38
|
+
const { t, palette } = useChartSeriesSetup(() => series);
|
|
39
|
+
|
|
40
|
+
const xLabels = computed<readonly string[]>(() => labels ?? extractLabels(series) ?? cartesianFallbackLabels(series));
|
|
41
|
+
|
|
42
|
+
const echartsSeries = computed(() => series.map((s, i) =>
|
|
43
|
+
toMixedSeries({ ...s, name: s.name ? t(String(s.name)) : undefined }, palette.value[i])
|
|
44
|
+
));
|
|
45
|
+
|
|
46
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
47
|
+
const base = buildCartesianBaseOptions({ tooltipTrigger: 'axis', xAxisLabels, yAxisLabels, splitLines });
|
|
48
|
+
const xAxisOverride: EChartsOption = { xAxis: { type: 'category', data: xLabels.value as string[] } };
|
|
49
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
50
|
+
? buildCartesianTooltipOptions(t, $style as never, () => series.map(s => s.icon), tooltipValueFormatter)
|
|
51
|
+
: { tooltip: { show: false } };
|
|
52
|
+
|
|
53
|
+
return merge({}, base, xAxisOverride, tooltipOptions, advancedOptions, { series: echartsSeries.value, color: palette.value });
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Chart
|
|
3
|
-
|
|
4
|
-
:options="
|
|
5
|
-
chart: {
|
|
6
|
-
type: 'pie'
|
|
7
|
-
},
|
|
8
|
-
legend: {
|
|
9
|
-
show: false
|
|
10
|
-
},
|
|
11
|
-
tooltip: {
|
|
12
|
-
enabled: false
|
|
13
|
-
}
|
|
14
|
-
}, options)"
|
|
15
|
-
:series="series"/>
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
16
5
|
</template>
|
|
17
6
|
|
|
18
7
|
<script
|
|
19
8
|
lang="ts"
|
|
20
9
|
setup>
|
|
21
|
-
import type {
|
|
10
|
+
import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
|
|
22
11
|
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { usePieSlicesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildSharedItemTooltipFormatter, type ChartTooltipValueFormatter, POLAR_BASE_OPTIONS, toPieSeries } from '~flux/statistics/util';
|
|
23
15
|
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
24
17
|
|
|
25
18
|
const {
|
|
26
|
-
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
slices,
|
|
21
|
+
title,
|
|
22
|
+
tooltip = false,
|
|
23
|
+
tooltipValueFormatter
|
|
27
24
|
} = defineProps<{
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly
|
|
25
|
+
readonly advancedOptions?: EChartsOption;
|
|
26
|
+
readonly slices: readonly FluxStatisticsChartPieSlice[];
|
|
27
|
+
readonly title?: string;
|
|
28
|
+
readonly tooltip?: boolean;
|
|
29
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
31
30
|
}>();
|
|
31
|
+
|
|
32
|
+
const { t, palette, tooltipItems } = usePieSlicesSetup(() => slices);
|
|
33
|
+
|
|
34
|
+
const echartsSeries = computed(() => [toPieSeries(slices, palette.value)]);
|
|
35
|
+
|
|
36
|
+
const tooltipOptions = computed<EChartsOption>(() => {
|
|
37
|
+
if (!tooltip) {
|
|
38
|
+
return { tooltip: { show: false } };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
tooltip: {
|
|
43
|
+
show: true,
|
|
44
|
+
trigger: 'item',
|
|
45
|
+
formatter: buildSharedItemTooltipFormatter(t, $style as never, () => tooltipItems.value, () => title, tooltipValueFormatter) as never
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const mergedOptions = computed<EChartsOption>(() =>
|
|
51
|
+
merge({}, POLAR_BASE_OPTIONS, tooltipOptions.value, advancedOptions, { series: echartsSeries.value, color: palette.value })
|
|
52
|
+
);
|
|
32
53
|
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
lang="ts"
|
|
9
|
+
setup>
|
|
10
|
+
import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { usePieSlicesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildSharedItemTooltipFormatter, type ChartTooltipValueFormatter, POLAR_BASE_OPTIONS, toPolarAreaSeries } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
slices,
|
|
21
|
+
title,
|
|
22
|
+
tooltip = false,
|
|
23
|
+
tooltipValueFormatter
|
|
24
|
+
} = defineProps<{
|
|
25
|
+
readonly advancedOptions?: EChartsOption;
|
|
26
|
+
readonly slices: readonly FluxStatisticsChartPieSlice[];
|
|
27
|
+
readonly title?: string;
|
|
28
|
+
readonly tooltip?: boolean;
|
|
29
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
30
|
+
}>();
|
|
31
|
+
|
|
32
|
+
const { t, palette, tooltipItems } = usePieSlicesSetup(() => slices);
|
|
33
|
+
|
|
34
|
+
const echartsSeries = computed(() => [toPolarAreaSeries(slices, palette.value)]);
|
|
35
|
+
|
|
36
|
+
const tooltipOptions = computed<EChartsOption>(() => {
|
|
37
|
+
if (!tooltip) {
|
|
38
|
+
return { tooltip: { show: false } };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
tooltip: {
|
|
43
|
+
show: true,
|
|
44
|
+
trigger: 'item',
|
|
45
|
+
formatter: buildSharedItemTooltipFormatter(t, $style as never, () => tooltipItems.value, () => title, tooltipValueFormatter) as never
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const mergedOptions = computed<EChartsOption>(() =>
|
|
51
|
+
merge({}, POLAR_BASE_OPTIONS, tooltipOptions.value, advancedOptions, { series: echartsSeries.value, color: palette.value })
|
|
52
|
+
);
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
lang="ts"
|
|
9
|
+
setup>
|
|
10
|
+
import type { FluxStatisticsChartRadarIndicator, FluxStatisticsChartRadarSeries } from '@flux-ui/types';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { POLAR_BASE_OPTIONS, type SharedTooltipItem, toRadarSeries, type TooltipParam, type TooltipStyleClasses } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
indicators,
|
|
21
|
+
series,
|
|
22
|
+
tooltip = false
|
|
23
|
+
} = defineProps<{
|
|
24
|
+
readonly advancedOptions?: EChartsOption;
|
|
25
|
+
readonly indicators: readonly FluxStatisticsChartRadarIndicator[];
|
|
26
|
+
readonly series: readonly FluxStatisticsChartRadarSeries[];
|
|
27
|
+
readonly tooltip?: boolean;
|
|
28
|
+
}>();
|
|
29
|
+
|
|
30
|
+
const { t, palette } = useChartSeriesSetup(() => series, { mode: 'data' });
|
|
31
|
+
|
|
32
|
+
const echartsSeries = computed(() => [toRadarSeries(
|
|
33
|
+
series.map(s => ({ ...s, name: s.name ? t(String(s.name)) : undefined })),
|
|
34
|
+
palette.value
|
|
35
|
+
)]);
|
|
36
|
+
|
|
37
|
+
const radarConfig = computed(() => ({
|
|
38
|
+
radar: {
|
|
39
|
+
indicator: indicators.map(i => ({ name: t(String(i.name)), max: i.max })),
|
|
40
|
+
splitLine: { lineStyle: { color: 'var(--gray-200)' } },
|
|
41
|
+
splitArea: { show: false },
|
|
42
|
+
axisLine: { lineStyle: { color: 'var(--gray-200)' } },
|
|
43
|
+
axisName: {
|
|
44
|
+
color: 'var(--foreground-secondary)',
|
|
45
|
+
fontSize: 12,
|
|
46
|
+
fontWeight: 500
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} as EChartsOption));
|
|
50
|
+
|
|
51
|
+
const tooltipFormatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
52
|
+
const param = Array.isArray(params) ? params[0] : params;
|
|
53
|
+
|
|
54
|
+
if (!param) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ringIndex = param.dataIndex ?? 0;
|
|
59
|
+
const ring = series[ringIndex];
|
|
60
|
+
|
|
61
|
+
if (!ring) {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const styles = $style as unknown as TooltipStyleClasses;
|
|
66
|
+
const color = palette.value[ringIndex % palette.value.length];
|
|
67
|
+
const title = ring.name ? t(String(ring.name)) : '';
|
|
68
|
+
|
|
69
|
+
const tooltipItems: SharedTooltipItem[] = indicators.map((indicator, idx) => ({
|
|
70
|
+
name: indicator.name,
|
|
71
|
+
value: ring.values[idx] ?? '',
|
|
72
|
+
color
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const titleHtml = title
|
|
76
|
+
? `<div class="${styles.statisticsChartTooltipTitle}">${title}</div>`
|
|
77
|
+
: '';
|
|
78
|
+
|
|
79
|
+
const body = tooltipItems.map(item => {
|
|
80
|
+
const translatedName = item.name ? t(String(item.name)) : '';
|
|
81
|
+
return `
|
|
82
|
+
<div class="${styles.statisticsChartTooltipSeriesColor} ${styles.isActive}" style="background: ${item.color}"></div>
|
|
83
|
+
<div class="${styles.statisticsChartTooltipSeriesName} ${styles.isActive}">${translatedName}</div>
|
|
84
|
+
<div class="${styles.statisticsChartTooltipSeriesValue} ${styles.isActive}">${item.value}</div>
|
|
85
|
+
`;
|
|
86
|
+
}).join('');
|
|
87
|
+
|
|
88
|
+
return `${titleHtml}<div class="${styles.statisticsChartTooltipBody}">${body}</div>`;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const tooltipOptions = computed<EChartsOption>(() => {
|
|
92
|
+
if (!tooltip) {
|
|
93
|
+
return { tooltip: { show: false } };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
tooltip: {
|
|
98
|
+
show: true,
|
|
99
|
+
trigger: 'item',
|
|
100
|
+
formatter: tooltipFormatter as never
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const mergedOptions = computed<EChartsOption>(() =>
|
|
106
|
+
merge({}, POLAR_BASE_OPTIONS, radarConfig.value, tooltipOptions.value, advancedOptions, { series: echartsSeries.value, color: palette.value })
|
|
107
|
+
);
|
|
108
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
lang="ts"
|
|
9
|
+
setup>
|
|
10
|
+
import type { FluxStatisticsChartGaugeSeries } from '@flux-ui/types';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildGaugeTooltipOptions, POLAR_BASE_OPTIONS, toGaugeSeries } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
series,
|
|
21
|
+
tooltip = false
|
|
22
|
+
} = defineProps<{
|
|
23
|
+
readonly advancedOptions?: EChartsOption;
|
|
24
|
+
readonly series: readonly FluxStatisticsChartGaugeSeries[];
|
|
25
|
+
readonly tooltip?: boolean;
|
|
26
|
+
}>();
|
|
27
|
+
|
|
28
|
+
const { t, palette } = useChartSeriesSetup(() => series, {
|
|
29
|
+
getLegendItem: (s, color, _, translate) => ({
|
|
30
|
+
color,
|
|
31
|
+
icon: s.icon,
|
|
32
|
+
label: s.name ? translate(String(s.name)) : '',
|
|
33
|
+
value: s.value
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const echartsSeries = computed(() => series.map((s, i) =>
|
|
38
|
+
toGaugeSeries({ ...s, name: s.name ? t(String(s.name)) : s.name }, palette.value[i], i, series.length)
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
42
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
43
|
+
? buildGaugeTooltipOptions(t, $style as never, () => series, () => palette.value)
|
|
44
|
+
: { tooltip: { show: false } };
|
|
45
|
+
|
|
46
|
+
return merge({}, POLAR_BASE_OPTIONS, tooltipOptions, advancedOptions, { series: echartsSeries.value, color: palette.value });
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
ref="chartRef"
|
|
4
|
+
:options="mergedOptions"/>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script
|
|
8
|
+
lang="ts"
|
|
9
|
+
setup>
|
|
10
|
+
import type { FluxStatisticsChartScatterSeries } from '@flux-ui/types';
|
|
11
|
+
import { merge } from 'lodash-es';
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildCartesianBaseOptions, buildCartesianTooltipOptions, toScatterSeries } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
series,
|
|
21
|
+
splitLines = false,
|
|
22
|
+
tooltip = false,
|
|
23
|
+
xAxisLabels = false,
|
|
24
|
+
yAxisLabels = false
|
|
25
|
+
} = defineProps<{
|
|
26
|
+
readonly advancedOptions?: EChartsOption;
|
|
27
|
+
readonly series: readonly FluxStatisticsChartScatterSeries[];
|
|
28
|
+
readonly splitLines?: boolean;
|
|
29
|
+
readonly tooltip?: boolean;
|
|
30
|
+
readonly xAxisLabels?: boolean;
|
|
31
|
+
readonly yAxisLabels?: boolean;
|
|
32
|
+
}>();
|
|
33
|
+
|
|
34
|
+
const { t, palette } = useChartSeriesSetup(() => series);
|
|
35
|
+
|
|
36
|
+
const echartsSeries = computed(() => series.map((s, i) =>
|
|
37
|
+
toScatterSeries({ ...s, name: s.name ? t(String(s.name)) : undefined }, palette.value[i])
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
41
|
+
const base = buildCartesianBaseOptions({
|
|
42
|
+
xAxisType: 'value',
|
|
43
|
+
yAxisType: 'value',
|
|
44
|
+
scale: true,
|
|
45
|
+
xAxisLabels,
|
|
46
|
+
yAxisLabels,
|
|
47
|
+
splitLines
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
51
|
+
? buildCartesianTooltipOptions(t, $style as never, () => series.map(s => s.icon))
|
|
52
|
+
: { tooltip: { show: false } };
|
|
53
|
+
|
|
54
|
+
return merge({}, base, tooltipOptions, advancedOptions, { series: echartsSeries.value, color: palette.value });
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
data-sparkline
|
|
4
|
+
:class="$style.statisticsSparkline"
|
|
5
|
+
:style="{
|
|
6
|
+
'--color': resolvedColor
|
|
7
|
+
}">
|
|
8
|
+
<div
|
|
9
|
+
ref="chart"
|
|
10
|
+
:class="$style.statisticsSparklineChart"/>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script
|
|
15
|
+
lang="ts"
|
|
16
|
+
setup>
|
|
17
|
+
import type { FluxColor } from '@flux-ui/types';
|
|
18
|
+
import { merge } from 'lodash-es';
|
|
19
|
+
import { computed, useTemplateRef } from 'vue';
|
|
20
|
+
import { type EChartsOption, useECharts } from '~flux/statistics/composable';
|
|
21
|
+
import { buildSparklineOptions, deepResolveCssVars, type SparklineSeriesItem, useCssVarVersion } from '~flux/statistics/util';
|
|
22
|
+
import $style from '~flux/statistics/css/Sparkline.module.scss';
|
|
23
|
+
|
|
24
|
+
const FLUX_COLORS: FluxColor[] = ['gray', 'primary', 'danger', 'info', 'success', 'warning'];
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
color,
|
|
28
|
+
options = {},
|
|
29
|
+
series,
|
|
30
|
+
variant = 'line'
|
|
31
|
+
} = defineProps<{
|
|
32
|
+
readonly color?: FluxColor | `#${string}`;
|
|
33
|
+
readonly options?: EChartsOption;
|
|
34
|
+
readonly series: readonly SparklineSeriesItem[];
|
|
35
|
+
readonly variant?: 'line' | 'bar' | 'area';
|
|
36
|
+
}>();
|
|
37
|
+
|
|
38
|
+
const chart = useTemplateRef('chart');
|
|
39
|
+
|
|
40
|
+
const resolvedColor = computed(() => {
|
|
41
|
+
if (!color) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (FLUX_COLORS.includes(color as FluxColor)) {
|
|
46
|
+
return `var(--${color}-600)`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return color;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const themeVersion = useCssVarVersion();
|
|
53
|
+
|
|
54
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
55
|
+
themeVersion.value;
|
|
56
|
+
|
|
57
|
+
const merged = merge(
|
|
58
|
+
{},
|
|
59
|
+
buildSparklineOptions(variant, resolvedColor.value ?? 'var(--chart-1)', series),
|
|
60
|
+
options
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return deepResolveCssVars(merged);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
useECharts(chart, mergedOptions);
|
|
67
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Chart
|
|
3
|
+
:options="mergedOptions"/>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script
|
|
7
|
+
lang="ts"
|
|
8
|
+
setup>
|
|
9
|
+
import type { FluxStatisticsChartTreemapNode } from '@flux-ui/types';
|
|
10
|
+
import { merge } from 'lodash-es';
|
|
11
|
+
import { computed } from 'vue';
|
|
12
|
+
import { useI18n } from 'vue-i18n';
|
|
13
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
14
|
+
import { buildTreemapTooltipOptions, CHART_DEFAULT_COLORS, POLAR_BASE_OPTIONS, toTreemapSeries } from '~flux/statistics/util';
|
|
15
|
+
import Chart from './FluxStatisticsChart.vue';
|
|
16
|
+
import $style from '~flux/statistics/css/Chart.module.scss';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
advancedOptions = {},
|
|
20
|
+
nodes,
|
|
21
|
+
tooltip = false
|
|
22
|
+
} = defineProps<{
|
|
23
|
+
readonly advancedOptions?: EChartsOption;
|
|
24
|
+
readonly nodes: readonly FluxStatisticsChartTreemapNode[];
|
|
25
|
+
readonly tooltip?: boolean;
|
|
26
|
+
}>();
|
|
27
|
+
|
|
28
|
+
const {t} = useI18n({useScope: 'parent'});
|
|
29
|
+
|
|
30
|
+
const echartsSeries = computed(() => [toTreemapSeries(nodes, CHART_DEFAULT_COLORS)]);
|
|
31
|
+
|
|
32
|
+
const mergedOptions = computed<EChartsOption>(() => {
|
|
33
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
34
|
+
? buildTreemapTooltipOptions(t, $style as never)
|
|
35
|
+
: { tooltip: { show: false } };
|
|
36
|
+
|
|
37
|
+
return merge({}, POLAR_BASE_OPTIONS, tooltipOptions, advancedOptions, { series: echartsSeries.value });
|
|
38
|
+
});
|
|
39
|
+
</script>
|
package/src/component/index.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
export { default as FluxStatisticsAreaChart } from './FluxStatisticsAreaChart.vue';
|
|
2
2
|
export { default as FluxStatisticsBarChart } from './FluxStatisticsBarChart.vue';
|
|
3
3
|
export { default as FluxStatisticsBase } from './FluxStatisticsBase.vue';
|
|
4
|
+
export { default as FluxStatisticsBoxPlotChart } from './FluxStatisticsBoxPlotChart.vue';
|
|
5
|
+
export { default as FluxStatisticsBubbleChart } from './FluxStatisticsBubbleChart.vue';
|
|
6
|
+
export { default as FluxStatisticsCandlestickChart } from './FluxStatisticsCandlestickChart.vue';
|
|
4
7
|
export { default as FluxStatisticsChange } from './FluxStatisticsChange.vue';
|
|
5
8
|
export { default as FluxStatisticsChart } from './FluxStatisticsChart.vue';
|
|
6
9
|
export { default as FluxStatisticsChartPane } from './FluxStatisticsChartPane.vue';
|
|
10
|
+
export { default as FluxStatisticsComparison } from './FluxStatisticsComparison.vue';
|
|
7
11
|
export { default as FluxStatisticsDetailsTable } from './FluxStatisticsDetailsTable.vue';
|
|
8
12
|
export { default as FluxStatisticsDetailsTableRow } from './FluxStatisticsDetailsTableRow.vue';
|
|
9
13
|
export { default as FluxStatisticsDonutChart } from './FluxStatisticsDonutChart.vue';
|
|
14
|
+
export { default as FluxStatisticsEmpty } from './FluxStatisticsEmpty.vue';
|
|
10
15
|
export { default as FluxStatisticsGrid } from './FluxStatisticsGrid.vue';
|
|
16
|
+
export { default as FluxStatisticsHeatmapChart } from './FluxStatisticsHeatmapChart.vue';
|
|
11
17
|
export { default as FluxStatisticsLineChart } from './FluxStatisticsLineChart.vue';
|
|
12
18
|
export { default as FluxStatisticsKpi } from './FluxStatisticsKpi.vue';
|
|
13
19
|
export { default as FluxStatisticsLegend } from './FluxStatisticsLegend.vue';
|
|
14
20
|
export { default as FluxStatisticsLegendItem } from './FluxStatisticsLegendItem.vue';
|
|
15
21
|
export { default as FluxStatisticsMeter } from './FluxStatisticsMeter.vue';
|
|
16
22
|
export { default as FluxStatisticsMetric } from './FluxStatisticsMetric.vue';
|
|
23
|
+
export { default as FluxStatisticsMixedChart } from './FluxStatisticsMixedChart.vue';
|
|
17
24
|
export { default as FluxStatisticsPieChart } from './FluxStatisticsPieChart.vue';
|
|
25
|
+
export { default as FluxStatisticsPolarAreaChart } from './FluxStatisticsPolarAreaChart.vue';
|
|
26
|
+
export { default as FluxStatisticsRadarChart } from './FluxStatisticsRadarChart.vue';
|
|
27
|
+
export { default as FluxStatisticsRadialBar } from './FluxStatisticsRadialBar.vue';
|
|
28
|
+
export { default as FluxStatisticsScatterChart } from './FluxStatisticsScatterChart.vue';
|
|
29
|
+
export { default as FluxStatisticsSparkline } from './FluxStatisticsSparkline.vue';
|
|
30
|
+
export { default as FluxStatisticsTreemapChart } from './FluxStatisticsTreemapChart.vue';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { ChartLegendContext, ChartLegendItem } from './useChartLegend';
|
|
2
|
+
export { createChartLegendContext, FluxStatisticsChartLegendInjectionKey } from './useChartLegend';
|
|
3
|
+
export type { ChartHoverSyncMode, UseChartHoverSyncOptions } from './useChartHoverSync';
|
|
4
|
+
export { useChartHoverSync } from './useChartHoverSync';
|
|
5
|
+
export type { ChartLegendItemBuilder, ChartSeriesShape, UseChartSeriesSetupOptions, UseChartSeriesSetupReturn } from './useChartSeriesSetup';
|
|
6
|
+
export { useChartSeriesSetup } from './useChartSeriesSetup';
|
|
7
|
+
export type { UsePieSlicesSetupReturn } from './usePieSlicesSetup';
|
|
8
|
+
export { usePieSlicesSetup } from './usePieSlicesSetup';
|
|
9
|
+
export type { EChartsInstance, EChartsOption, UseEChartsReturn } from './useECharts';
|
|
10
|
+
export { useECharts } from './useECharts';
|