@flux-ui/statistics 3.0.0-next.68 → 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 (119) hide show
  1. package/dist/component/FluxStatisticsLegendScope.vue.d.ts +13 -0
  2. package/dist/component/FluxStatisticsPercentageBar.vue.d.ts +8 -0
  3. package/dist/component/index.d.ts +2 -0
  4. package/dist/composable/index.d.ts +4 -2
  5. package/dist/composable/useChartBaseSetup.d.ts +8 -0
  6. package/dist/composable/{usePieSlicesSetup.d.ts → useChartSlicesSetup.d.ts} +2 -2
  7. package/dist/index.css +67 -32
  8. package/dist/index.js +913 -510
  9. package/dist/index.js.map +1 -1
  10. package/dist/util/index.d.ts +5 -6
  11. package/dist/util/options/buildBaseOptions.d.ts +2 -0
  12. package/dist/util/{baseOptions.d.ts → options/buildCartesianBaseOptions.d.ts} +4 -6
  13. package/dist/util/options/buildCircularBaseOptions.d.ts +2 -0
  14. package/dist/util/options/cartesian/buildAreaChartOptions.d.ts +17 -0
  15. package/dist/util/options/cartesian/buildBarChartOptions.d.ts +17 -0
  16. package/dist/util/options/cartesian/buildBoxPlotChartOptions.d.ts +16 -0
  17. package/dist/util/options/cartesian/buildBubbleChartOptions.d.ts +15 -0
  18. package/dist/util/options/cartesian/buildCandlestickChartOptions.d.ts +17 -0
  19. package/dist/util/options/cartesian/buildHeatmapChartOptions.d.ts +15 -0
  20. package/dist/util/options/cartesian/buildLineChartOptions.d.ts +17 -0
  21. package/dist/util/options/cartesian/buildMixedChartOptions.d.ts +17 -0
  22. package/dist/util/options/cartesian/buildScatterChartOptions.d.ts +15 -0
  23. package/dist/util/options/cartesian/index.d.ts +18 -0
  24. package/dist/util/options/circular/buildDonutChartOptions.d.ts +15 -0
  25. package/dist/util/options/circular/buildGaugeChartOptions.d.ts +14 -0
  26. package/dist/util/options/circular/buildPieChartOptions.d.ts +15 -0
  27. package/dist/util/options/circular/buildPolarAreaChartOptions.d.ts +15 -0
  28. package/dist/util/options/circular/buildRadarChartOptions.d.ts +13 -0
  29. package/dist/util/options/circular/buildTreemapChartOptions.d.ts +12 -0
  30. package/dist/util/options/circular/index.d.ts +12 -0
  31. package/dist/util/options/index.d.ts +6 -0
  32. package/dist/util/series/chartColors.d.ts +3 -0
  33. package/dist/util/{convert.d.ts → series/converters.d.ts} +1 -6
  34. package/dist/util/series/index.d.ts +4 -0
  35. package/dist/util/series/labels.d.ts +5 -0
  36. package/dist/util/tooltips/buildBoxPlotTooltip.d.ts +22 -0
  37. package/dist/util/tooltips/buildCartesianTooltip.d.ts +10 -0
  38. package/dist/util/tooltips/buildGaugeTooltip.d.ts +14 -0
  39. package/dist/util/tooltips/buildHeatmapTooltip.d.ts +17 -0
  40. package/dist/util/tooltips/buildRadarTooltip.d.ts +11 -0
  41. package/dist/util/tooltips/buildSharedItemTooltip.d.ts +10 -0
  42. package/dist/util/tooltips/buildTreemapTooltip.d.ts +12 -0
  43. package/dist/util/tooltips/index.d.ts +15 -0
  44. package/dist/util/tooltips/render.d.ts +4 -0
  45. package/dist/util/tooltips/types.d.ts +24 -0
  46. package/package.json +4 -4
  47. package/src/component/FluxStatisticsAreaChart.vue +15 -19
  48. package/src/component/FluxStatisticsBarChart.vue +15 -19
  49. package/src/component/FluxStatisticsBoxPlotChart.vue +14 -34
  50. package/src/component/FluxStatisticsBubbleChart.vue +13 -23
  51. package/src/component/FluxStatisticsCandlestickChart.vue +14 -45
  52. package/src/component/FluxStatisticsChart.vue +2 -2
  53. package/src/component/FluxStatisticsChartPane.vue +12 -13
  54. package/src/component/FluxStatisticsDonutChart.vue +15 -24
  55. package/src/component/FluxStatisticsHeatmapChart.vue +15 -48
  56. package/src/component/FluxStatisticsLegendScope.vue +16 -0
  57. package/src/component/FluxStatisticsLineChart.vue +15 -19
  58. package/src/component/FluxStatisticsMixedChart.vue +15 -18
  59. package/src/component/FluxStatisticsPercentageBar.vue +90 -0
  60. package/src/component/FluxStatisticsPieChart.vue +15 -24
  61. package/src/component/FluxStatisticsPolarAreaChart.vue +15 -24
  62. package/src/component/FluxStatisticsRadarChart.vue +11 -79
  63. package/src/component/FluxStatisticsRadialBar.vue +11 -20
  64. package/src/component/FluxStatisticsScatterChart.vue +13 -23
  65. package/src/component/FluxStatisticsTreemapChart.vue +11 -15
  66. package/src/component/index.ts +2 -0
  67. package/src/composable/index.ts +4 -2
  68. package/src/composable/useChartBaseSetup.ts +16 -0
  69. package/src/composable/{usePieSlicesSetup.ts → useChartSlicesSetup.ts} +3 -3
  70. package/src/css/Chart.module.scss +10 -15
  71. package/src/css/ChartPane.module.scss +3 -10
  72. package/src/css/Empty.module.scss +2 -2
  73. package/src/css/Legend.module.scss +16 -8
  74. package/src/css/Meter.module.scss +1 -0
  75. package/src/css/PercentageBar.module.scss +36 -0
  76. package/src/util/index.ts +5 -6
  77. package/src/util/options/buildBaseOptions.ts +31 -0
  78. package/src/util/{baseOptions.ts → options/buildCartesianBaseOptions.ts} +15 -22
  79. package/src/util/options/buildCircularBaseOptions.ts +10 -0
  80. package/src/util/options/cartesian/buildAreaChartOptions.ts +44 -0
  81. package/src/util/options/cartesian/buildBarChartOptions.ts +44 -0
  82. package/src/util/options/cartesian/buildBoxPlotChartOptions.ts +63 -0
  83. package/src/util/options/cartesian/buildBubbleChartOptions.ts +48 -0
  84. package/src/util/options/cartesian/buildCandlestickChartOptions.ts +77 -0
  85. package/src/util/options/cartesian/buildHeatmapChartOptions.ts +72 -0
  86. package/src/util/options/cartesian/buildLineChartOptions.ts +44 -0
  87. package/src/util/options/cartesian/buildMixedChartOptions.ts +44 -0
  88. package/src/util/options/cartesian/buildScatterChartOptions.ts +48 -0
  89. package/src/util/options/cartesian/index.ts +18 -0
  90. package/src/util/options/circular/buildDonutChartOptions.ts +31 -0
  91. package/src/util/options/circular/buildGaugeChartOptions.ts +45 -0
  92. package/src/util/options/circular/buildPieChartOptions.ts +31 -0
  93. package/src/util/options/circular/buildPolarAreaChartOptions.ts +31 -0
  94. package/src/util/options/circular/buildRadarChartOptions.ts +52 -0
  95. package/src/util/options/circular/buildTreemapChartOptions.ts +28 -0
  96. package/src/util/options/circular/index.ts +12 -0
  97. package/src/util/options/index.ts +6 -0
  98. package/src/util/series/chartColors.ts +20 -0
  99. package/src/util/{convert.ts → series/converters.ts} +2 -44
  100. package/src/util/series/index.ts +4 -0
  101. package/src/util/series/labels.ts +30 -0
  102. package/src/util/tooltips/buildBoxPlotTooltip.ts +66 -0
  103. package/src/util/tooltips/buildCartesianTooltip.ts +44 -0
  104. package/src/util/tooltips/buildGaugeTooltip.ts +49 -0
  105. package/src/util/tooltips/buildHeatmapTooltip.ts +57 -0
  106. package/src/util/tooltips/buildRadarTooltip.ts +53 -0
  107. package/src/util/tooltips/buildSharedItemTooltip.ts +38 -0
  108. package/src/util/tooltips/buildTreemapTooltip.ts +49 -0
  109. package/src/util/tooltips/index.ts +15 -0
  110. package/src/util/tooltips/render.ts +66 -0
  111. package/src/util/tooltips/types.ts +29 -0
  112. package/dist/util/defaultOptions.d.ts +0 -76
  113. package/src/util/defaultOptions.ts +0 -398
  114. /package/dist/util/{iconSvg.d.ts → icons.d.ts} +0 -0
  115. /package/dist/util/{seriesDefaults.d.ts → series/defaults.d.ts} +0 -0
  116. /package/dist/util/{sparklineOptions.d.ts → sparkline.d.ts} +0 -0
  117. /package/src/util/{iconSvg.ts → icons.ts} +0 -0
  118. /package/src/util/{seriesDefaults.ts → series/defaults.ts} +0 -0
  119. /package/src/util/{sparklineOptions.ts → sparkline.ts} +0 -0
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartBarSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toBarSeries } from '~flux/statistics/util';
13
+ import { buildBarChartOptions, type ChartTooltipValueFormatter } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  labels,
21
20
  series,
22
21
  splitLines = false,
@@ -37,20 +36,17 @@
37
36
 
38
37
  const { t, palette } = useChartSeriesSetup(() => series);
39
38
 
40
- const xLabels = computed<readonly string[]>(() => labels ?? extractLabels(series) ?? cartesianFallbackLabels(series));
41
-
42
- const echartsSeries = computed(() => series.map((s, i) =>
43
- toBarSeries({ ...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[] } };
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 });
55
- });
39
+ const mergedOptions = computed(() => buildBarChartOptions({
40
+ series,
41
+ labels,
42
+ palette: palette.value,
43
+ t,
44
+ styles: $style,
45
+ tooltip,
46
+ tooltipValueFormatter,
47
+ xAxisLabels,
48
+ yAxisLabels,
49
+ splitLines,
50
+ advancedOptions
51
+ }));
56
52
  </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartBoxPlotSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildBoxPlotTooltipOptions, buildCartesianBaseOptions, toBoxPlotSeries } from '~flux/statistics/util';
13
+ import { buildBoxPlotChartOptions } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  labels,
21
20
  series,
22
21
  splitLines = false,
@@ -35,35 +34,16 @@
35
34
 
36
35
  const { t, palette } = useChartSeriesSetup(() => series);
37
36
 
38
- const xLabels = computed<readonly string[] | undefined>(() => {
39
- if (labels) {
40
- return labels;
41
- }
42
-
43
- for (const s of series) {
44
- const fromPoints = s.data.map(p => p.label ?? '').filter(Boolean);
45
- if (fromPoints.length > 0) {
46
- return s.data.map(p => p.label ?? '');
47
- }
48
- }
49
-
50
- return undefined;
51
- });
52
-
53
- const echartsSeries = computed(() => series.map((s, i) =>
54
- toBoxPlotSeries({ ...s, name: s.name ? t(String(s.name)) : undefined }, palette.value[i])
55
- ));
56
-
57
- const mergedOptions = computed<EChartsOption>(() => {
58
- const base = buildCartesianBaseOptions({ xAxisLabels, yAxisLabels, splitLines });
59
- const xAxisOverride: EChartsOption | undefined = xLabels.value
60
- ? { xAxis: { type: 'category', data: xLabels.value as string[] } }
61
- : undefined;
62
-
63
- const tooltipOptions: EChartsOption = tooltip
64
- ? buildBoxPlotTooltipOptions(t, $style as never, () => series, () => palette.value)
65
- : { tooltip: { show: false } };
66
-
67
- return merge({}, base, xAxisOverride ?? {}, tooltipOptions, advancedOptions, { series: echartsSeries.value, color: palette.value });
68
- });
37
+ const mergedOptions = computed(() => buildBoxPlotChartOptions({
38
+ series,
39
+ labels,
40
+ palette: palette.value,
41
+ t,
42
+ styles: $style,
43
+ tooltip,
44
+ xAxisLabels,
45
+ yAxisLabels,
46
+ splitLines,
47
+ advancedOptions
48
+ }));
69
49
  </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartBubbleSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildCartesianBaseOptions, buildCartesianTooltipOptions, toBubbleSeries } from '~flux/statistics/util';
13
+ import { buildBubbleChartOptions } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  series,
21
20
  splitLines = false,
22
21
  tooltip = false,
@@ -33,24 +32,15 @@
33
32
 
34
33
  const { t, palette } = useChartSeriesSetup(() => series);
35
34
 
36
- const echartsSeries = computed(() => series.map((s, i) =>
37
- toBubbleSeries({ ...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
- });
35
+ const mergedOptions = computed(() => buildBubbleChartOptions({
36
+ series,
37
+ palette: palette.value,
38
+ t,
39
+ styles: $style,
40
+ tooltip,
41
+ xAxisLabels,
42
+ yAxisLabels,
43
+ splitLines,
44
+ advancedOptions
45
+ }));
56
46
  </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartCandlestickSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildCartesianBaseOptions, buildCartesianTooltipOptions, resolveChartColor, toCandlestickSeries } from '~flux/statistics/util';
13
+ import { buildCandlestickChartOptions, candlestickLegendItemBuilder } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  labels,
21
20
  series,
22
21
  splitLines = false,
@@ -34,48 +33,18 @@
34
33
  }>();
35
34
 
36
35
  const { t } = useChartSeriesSetup(() => series, {
37
- getLegendItem: s => [
38
- {
39
- color: resolveChartColor(s.positiveColor) ?? 'var(--success-500)',
40
- icon: s.icon,
41
- label: 'Up'
42
- },
43
- {
44
- color: resolveChartColor(s.negativeColor) ?? 'var(--danger-500)',
45
- label: 'Down'
46
- }
47
- ]
36
+ getLegendItem: candlestickLegendItemBuilder
48
37
  });
49
38
 
50
- const xLabels = computed<readonly string[] | undefined>(() => {
51
- if (labels) {
52
- return labels;
53
- }
54
-
55
- for (const s of series) {
56
- const fromPoints = s.data.map(p => p.label ?? '').filter(Boolean);
57
- if (fromPoints.length > 0) {
58
- return s.data.map(p => p.label ?? '');
59
- }
60
- }
61
-
62
- return undefined;
63
- });
64
-
65
- const echartsSeries = computed(() => series.map(s =>
66
- toCandlestickSeries({ ...s, name: s.name ? t(String(s.name)) : undefined })
67
- ));
68
-
69
- const mergedOptions = computed<EChartsOption>(() => {
70
- const base = buildCartesianBaseOptions({ scale: true, xAxisLabels, yAxisLabels, splitLines });
71
- const xAxisOverride: EChartsOption | undefined = xLabels.value
72
- ? { xAxis: { type: 'category', data: xLabels.value as string[] } }
73
- : undefined;
74
-
75
- const tooltipOptions: EChartsOption = tooltip
76
- ? buildCartesianTooltipOptions(t, $style as never, () => series.map(s => s.icon))
77
- : { tooltip: { show: false } };
78
-
79
- return merge({}, base, xAxisOverride ?? {}, tooltipOptions, advancedOptions, { series: echartsSeries.value });
80
- });
39
+ const mergedOptions = computed(() => buildCandlestickChartOptions({
40
+ series,
41
+ labels,
42
+ t,
43
+ styles: $style,
44
+ tooltip,
45
+ xAxisLabels,
46
+ yAxisLabels,
47
+ splitLines,
48
+ advancedOptions
49
+ }));
81
50
  </script>
@@ -10,7 +10,7 @@
10
10
  import { merge } from 'lodash-es';
11
11
  import { computed, useTemplateRef } from 'vue';
12
12
  import { type EChartsOption, useECharts } from '~flux/statistics/composable';
13
- import { buildDefaultOptions, deepResolveCssVars } from '~flux/statistics/util';
13
+ import { buildBaseOptions, deepResolveCssVars } from '~flux/statistics/util';
14
14
  import $style from '~flux/statistics/css/Chart.module.scss';
15
15
 
16
16
  const {
@@ -21,7 +21,7 @@
21
21
 
22
22
  const chart = useTemplateRef('chart');
23
23
 
24
- const defaults = buildDefaultOptions();
24
+ const defaults = buildBaseOptions();
25
25
 
26
26
  const mergedOptions = computed<EChartsOption>(() => {
27
27
  const merged = merge({}, defaults, options) as EChartsOption & { color?: unknown; series?: unknown };
@@ -15,17 +15,19 @@
15
15
  </template>
16
16
 
17
17
  <template #content>
18
- <div :class="$style.statisticsChartPaneBody">
19
- <div :class="$style.statisticsChartPaneContainer">
20
- <slot/>
21
- </div>
18
+ <FluxStatisticsLegendScope>
19
+ <div :class="$style.statisticsChartPaneBody">
20
+ <div :class="$style.statisticsChartPaneContainer">
21
+ <slot/>
22
+ </div>
22
23
 
23
- <slot name="legend"/>
24
- </div>
24
+ <slot name="legend"/>
25
+ </div>
25
26
 
26
- <FluxToolbar v-if="slots.toolbar">
27
- <slot name="toolbar"/>
28
- </FluxToolbar>
27
+ <FluxToolbar v-if="slots.toolbar">
28
+ <slot name="toolbar"/>
29
+ </FluxToolbar>
30
+ </FluxStatisticsLegendScope>
29
31
  </template>
30
32
  </Base>
31
33
  </template>
@@ -35,9 +37,8 @@
35
37
  setup>
36
38
  import { FluxToolbar } from '@flux-ui/components';
37
39
  import type { FluxIconName } from '@flux-ui/types';
38
- import { provide } from 'vue';
39
- import { createChartLegendContext, FluxStatisticsChartLegendInjectionKey } from '~flux/statistics/composable';
40
40
  import Base from './FluxStatisticsBase.vue';
41
+ import FluxStatisticsLegendScope from './FluxStatisticsLegendScope.vue';
41
42
  import $style from '~flux/statistics/css/ChartPane.module.scss';
42
43
 
43
44
  defineProps<{
@@ -54,6 +55,4 @@
54
55
  legend?(): any;
55
56
  toolbar?(): any;
56
57
  }>();
57
-
58
- provide(FluxStatisticsChartLegendInjectionKey, createChartLegendContext());
59
58
  </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
- import { usePieSlicesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildSharedItemTooltipFormatter, type ChartTooltipValueFormatter, POLAR_BASE_OPTIONS, toDonutSeries } from '~flux/statistics/util';
12
+ import { useChartSlicesSetup, type EChartsOption } from '~flux/statistics/composable';
13
+ import { buildDonutChartOptions, type ChartTooltipValueFormatter } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  slices,
21
20
  title,
22
21
  tooltip = false,
@@ -29,25 +28,17 @@
29
28
  readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
30
29
  }>();
31
30
 
32
- const { t, palette, tooltipItems } = usePieSlicesSetup(() => slices);
31
+ const { t, palette, tooltipItems } = useChartSlicesSetup(() => slices);
33
32
 
34
- const echartsSeries = computed(() => [toDonutSeries(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
- );
33
+ const mergedOptions = computed(() => buildDonutChartOptions({
34
+ slices,
35
+ palette: palette.value,
36
+ tooltipItems: tooltipItems.value,
37
+ title,
38
+ t,
39
+ styles: $style,
40
+ tooltip,
41
+ tooltipValueFormatter,
42
+ advancedOptions
43
+ }));
53
44
  </script>
@@ -6,18 +6,15 @@
6
6
  <script
7
7
  lang="ts"
8
8
  setup>
9
- import { blue100, blue300, blue500, blue700 } from '@flux-ui/internals';
10
9
  import type { FluxStatisticsChartHeatmapSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
10
  import { computed } from 'vue';
13
- import { useI18n } from 'vue-i18n';
14
- import type { EChartsOption } from '~flux/statistics/composable';
15
- import { buildCartesianBaseOptions, buildHeatmapTooltipOptions, toHeatmapSeries } from '~flux/statistics/util';
11
+ import { useChartBaseSetup, type EChartsOption } from '~flux/statistics/composable';
12
+ import { buildHeatmapChartOptions } from '~flux/statistics/util';
16
13
  import Chart from './FluxStatisticsChart.vue';
17
14
  import $style from '~flux/statistics/css/Chart.module.scss';
18
15
 
19
16
  const {
20
- advancedOptions = {},
17
+ advancedOptions,
21
18
  series,
22
19
  tooltip = false,
23
20
  xAxisLabels = false,
@@ -34,47 +31,17 @@
34
31
  readonly yLabels?: readonly string[];
35
32
  }>();
36
33
 
37
- const {t} = useI18n({useScope: 'parent'});
34
+ const { t } = useChartBaseSetup();
38
35
 
39
- const translatedXLabels = computed(() => xLabels.map(label => t(String(label))));
40
- const translatedYLabels = computed(() => yLabels.map(label => t(String(label))));
41
-
42
- const echartsSeries = computed(() => series.map(s =>
43
- toHeatmapSeries({ ...s, name: s.name ? t(String(s.name)) : undefined }, xLabels, yLabels)
44
- ));
45
-
46
- const mergedOptions = computed<EChartsOption>(() => {
47
- const base: EChartsOption = {
48
- ...buildCartesianBaseOptions({ yAxisType: 'category', xAxisLabels, yAxisLabels }),
49
- color: [blue500],
50
- visualMap: {
51
- show: false,
52
- min: 0,
53
- max: 100,
54
- inRange: { color: [blue100, blue300, blue500, blue700] }
55
- },
56
- xAxis: {
57
- type: 'category',
58
- data: translatedXLabels.value as string[],
59
- axisLabel: { show: xAxisLabels, color: 'var(--foreground-secondary)' },
60
- axisLine: { show: false },
61
- axisTick: { show: false },
62
- splitLine: { show: false }
63
- },
64
- yAxis: {
65
- type: 'category',
66
- data: translatedYLabels.value as string[],
67
- axisLabel: { show: yAxisLabels, color: 'var(--foreground-secondary)' },
68
- axisLine: { show: false },
69
- axisTick: { show: false },
70
- splitLine: { show: false }
71
- }
72
- };
73
-
74
- const tooltipOptions: EChartsOption = tooltip
75
- ? buildHeatmapTooltipOptions(t, $style as never, () => series)
76
- : { tooltip: { show: false } };
77
-
78
- return merge({}, base, tooltipOptions, advancedOptions, { series: echartsSeries.value });
79
- });
36
+ const mergedOptions = computed(() => buildHeatmapChartOptions({
37
+ series,
38
+ xLabels,
39
+ yLabels,
40
+ t,
41
+ styles: $style,
42
+ tooltip,
43
+ xAxisLabels,
44
+ yAxisLabels,
45
+ advancedOptions
46
+ }));
80
47
  </script>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <slot/>
3
+ </template>
4
+
5
+ <script
6
+ lang="ts"
7
+ setup>
8
+ import { provide } from 'vue';
9
+ import { createChartLegendContext, FluxStatisticsChartLegendInjectionKey } from '~flux/statistics/composable';
10
+
11
+ defineSlots<{
12
+ default(): any;
13
+ }>();
14
+
15
+ provide(FluxStatisticsChartLegendInjectionKey, createChartLegendContext());
16
+ </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartLineSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toLineSeries } from '~flux/statistics/util';
13
+ import { buildLineChartOptions, type ChartTooltipValueFormatter } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  labels,
21
20
  series,
22
21
  splitLines = false,
@@ -37,20 +36,17 @@
37
36
 
38
37
  const { t, palette } = useChartSeriesSetup(() => series);
39
38
 
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 });
55
- });
39
+ const mergedOptions = computed(() => buildLineChartOptions({
40
+ series,
41
+ labels,
42
+ palette: palette.value,
43
+ t,
44
+ styles: $style,
45
+ tooltip,
46
+ tooltipValueFormatter,
47
+ xAxisLabels,
48
+ yAxisLabels,
49
+ splitLines,
50
+ advancedOptions
51
+ }));
56
52
  </script>
@@ -8,15 +8,14 @@
8
8
  lang="ts"
9
9
  setup>
10
10
  import type { FluxStatisticsChartMixedSeries } from '@flux-ui/types';
11
- import { merge } from 'lodash-es';
12
11
  import { computed } from 'vue';
13
12
  import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
- import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toMixedSeries } from '~flux/statistics/util';
13
+ import { buildMixedChartOptions, type ChartTooltipValueFormatter } from '~flux/statistics/util';
15
14
  import Chart from './FluxStatisticsChart.vue';
16
15
  import $style from '~flux/statistics/css/Chart.module.scss';
17
16
 
18
17
  const {
19
- advancedOptions = {},
18
+ advancedOptions,
20
19
  labels,
21
20
  series,
22
21
  splitLines = false,
@@ -37,19 +36,17 @@
37
36
 
38
37
  const { t, palette } = useChartSeriesSetup(() => series);
39
38
 
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
- });
39
+ const mergedOptions = computed(() => buildMixedChartOptions({
40
+ series,
41
+ labels,
42
+ palette: palette.value,
43
+ t,
44
+ styles: $style,
45
+ tooltip,
46
+ tooltipValueFormatter,
47
+ xAxisLabels,
48
+ yAxisLabels,
49
+ splitLines,
50
+ advancedOptions
51
+ }));
55
52
  </script>