@flux-ui/statistics 3.0.0-next.66 → 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.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/dist/component/FluxStatisticsAreaChart.vue.d.ts +13 -5
  3. package/dist/component/FluxStatisticsBarChart.vue.d.ts +13 -5
  4. package/dist/component/FluxStatisticsBase.vue.d.ts +8 -15
  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/FluxStatisticsChange.vue.d.ts +2 -1
  9. package/dist/component/FluxStatisticsChart.vue.d.ts +8 -19
  10. package/dist/component/FluxStatisticsChartPane.vue.d.ts +9 -17
  11. package/dist/component/FluxStatisticsComparison.vue.d.ts +16 -0
  12. package/dist/component/FluxStatisticsDetailsTable.vue.d.ts +6 -13
  13. package/dist/component/FluxStatisticsDetailsTableRow.vue.d.ts +2 -1
  14. package/dist/component/FluxStatisticsDonutChart.vue.d.ts +10 -5
  15. package/dist/component/FluxStatisticsEmpty.vue.d.ts +19 -0
  16. package/dist/component/FluxStatisticsGrid.vue.d.ts +7 -11
  17. package/dist/component/FluxStatisticsHeatmapChart.vue.d.ts +15 -0
  18. package/dist/component/FluxStatisticsKpi.vue.d.ts +2 -1
  19. package/dist/component/FluxStatisticsLegend.vue.d.ts +7 -11
  20. package/dist/component/FluxStatisticsLegendItem.vue.d.ts +3 -1
  21. package/dist/component/FluxStatisticsLineChart.vue.d.ts +13 -5
  22. package/dist/component/FluxStatisticsMeter.vue.d.ts +2 -1
  23. package/dist/component/FluxStatisticsMetric.vue.d.ts +6 -13
  24. package/dist/component/FluxStatisticsMixedChart.vue.d.ts +17 -0
  25. package/dist/component/FluxStatisticsPieChart.vue.d.ts +10 -5
  26. package/dist/component/FluxStatisticsPolarAreaChart.vue.d.ts +14 -0
  27. package/dist/component/FluxStatisticsRadarChart.vue.d.ts +12 -0
  28. package/dist/component/FluxStatisticsRadialBar.vue.d.ts +11 -0
  29. package/dist/component/FluxStatisticsScatterChart.vue.d.ts +14 -0
  30. package/dist/component/FluxStatisticsSparkline.vue.d.ts +13 -0
  31. package/dist/component/FluxStatisticsTreemapChart.vue.d.ts +11 -0
  32. package/dist/component/index.d.ts +13 -0
  33. package/dist/composable/index.d.ts +10 -0
  34. package/dist/composable/useChartHoverSync.d.ts +9 -0
  35. package/dist/composable/useChartLegend.d.ts +14 -0
  36. package/dist/composable/useChartSeriesSetup.d.ts +23 -0
  37. package/dist/composable/useECharts.d.ts +9 -0
  38. package/dist/composable/usePieSlicesSetup.d.ts +14 -0
  39. package/dist/echarts.d.ts +1 -0
  40. package/dist/index.css +230 -37
  41. package/dist/index.d.ts +5 -2
  42. package/dist/index.js +10924 -9047
  43. package/dist/index.js.map +1 -1
  44. package/dist/util/baseOptions.d.ts +15 -0
  45. package/dist/util/colors.d.ts +4 -0
  46. package/dist/util/convert.d.ts +22 -0
  47. package/dist/util/defaultOptions.d.ts +76 -0
  48. package/dist/util/iconSvg.d.ts +2 -0
  49. package/dist/util/index.d.ts +7 -0
  50. package/dist/util/seriesDefaults.d.ts +15 -0
  51. package/dist/util/sparklineOptions.d.ts +7 -0
  52. package/package.json +14 -15
  53. package/src/component/FluxStatisticsAreaChart.vue +38 -41
  54. package/src/component/FluxStatisticsBarChart.vue +38 -33
  55. package/src/component/FluxStatisticsBase.vue +14 -1
  56. package/src/component/FluxStatisticsBoxPlotChart.vue +69 -0
  57. package/src/component/FluxStatisticsBubbleChart.vue +56 -0
  58. package/src/component/FluxStatisticsCandlestickChart.vue +81 -0
  59. package/src/component/FluxStatisticsChart.vue +19 -169
  60. package/src/component/FluxStatisticsChartPane.vue +23 -11
  61. package/src/component/FluxStatisticsComparison.vue +113 -0
  62. package/src/component/FluxStatisticsDonutChart.vue +39 -18
  63. package/src/component/FluxStatisticsEmpty.vue +44 -0
  64. package/src/component/FluxStatisticsHeatmapChart.vue +80 -0
  65. package/src/component/FluxStatisticsLegend.vue +33 -1
  66. package/src/component/FluxStatisticsLegendItem.vue +3 -1
  67. package/src/component/FluxStatisticsLineChart.vue +38 -41
  68. package/src/component/FluxStatisticsMixedChart.vue +55 -0
  69. package/src/component/FluxStatisticsPieChart.vue +39 -18
  70. package/src/component/FluxStatisticsPolarAreaChart.vue +53 -0
  71. package/src/component/FluxStatisticsRadarChart.vue +108 -0
  72. package/src/component/FluxStatisticsRadialBar.vue +48 -0
  73. package/src/component/FluxStatisticsScatterChart.vue +56 -0
  74. package/src/component/FluxStatisticsSparkline.vue +67 -0
  75. package/src/component/FluxStatisticsTreemapChart.vue +39 -0
  76. package/src/component/index.ts +13 -0
  77. package/src/composable/index.ts +10 -0
  78. package/src/composable/useChartHoverSync.ts +92 -0
  79. package/src/composable/useChartLegend.ts +23 -0
  80. package/src/composable/useChartSeriesSetup.ts +75 -0
  81. package/src/composable/useECharts.ts +55 -0
  82. package/src/composable/usePieSlicesSetup.ts +58 -0
  83. package/src/css/Base.module.scss +28 -1
  84. package/src/css/Chart.module.scss +66 -32
  85. package/src/css/ChartPane.module.scss +24 -9
  86. package/src/css/Comparison.module.scss +52 -0
  87. package/src/css/Empty.module.scss +39 -0
  88. package/src/css/Grid.module.scss +1 -0
  89. package/src/css/Legend.module.scss +11 -1
  90. package/src/css/Metric.module.scss +6 -0
  91. package/src/css/Sparkline.module.scss +13 -0
  92. package/src/echarts.ts +47 -0
  93. package/src/index.ts +7 -3
  94. package/src/util/baseOptions.ts +74 -0
  95. package/src/util/colors.ts +86 -0
  96. package/src/util/convert.ts +360 -0
  97. package/src/util/defaultOptions.ts +398 -0
  98. package/src/util/iconSvg.ts +20 -0
  99. package/src/util/index.ts +7 -0
  100. package/src/util/seriesDefaults.ts +210 -0
  101. package/src/util/sparklineOptions.ts +67 -0
@@ -0,0 +1,15 @@
1
+ import { EChartsOption } from '../composable';
2
+ interface CartesianBaseConfig {
3
+ readonly xAxisType?: 'category' | 'value';
4
+ readonly yAxisType?: 'value' | 'category';
5
+ readonly scale?: boolean;
6
+ readonly tooltipTrigger?: 'axis' | 'item';
7
+ readonly xAxisLabels?: boolean;
8
+ readonly yAxisLabels?: boolean;
9
+ readonly splitLines?: boolean;
10
+ }
11
+ export declare function buildCartesianGrid(xAxisLabels: boolean, yAxisLabels: boolean): EChartsOption['grid'];
12
+ export declare function buildCartesianBaseOptions(config?: CartesianBaseConfig): EChartsOption;
13
+ export declare const POLAR_BASE_OPTIONS: EChartsOption;
14
+ export declare const SPARKLINE_AXIS_BASE: EChartsOption;
15
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Ref } from 'vue';
2
+ export declare function useCssVarVersion(): Ref<number, number>;
3
+ export declare function resolveCssVar(input: string, root?: HTMLElement): string;
4
+ export declare function deepResolveCssVars<T>(value: T, root?: HTMLElement): T;
@@ -0,0 +1,22 @@
1
+ import { FluxStatisticsChartAreaSeries, FluxStatisticsChartBarSeries, FluxStatisticsChartBoxPlotSeries, FluxStatisticsChartBubbleSeries, FluxStatisticsChartCandlestickSeries, FluxStatisticsChartCartesianSeries, FluxStatisticsChartCategoryPoint, FluxStatisticsChartColor, FluxStatisticsChartGaugeSeries, FluxStatisticsChartHeatmapSeries, FluxStatisticsChartLineSeries, FluxStatisticsChartMixedSeries, FluxStatisticsChartPieSlice, FluxStatisticsChartRadarSeries, FluxStatisticsChartScatterSeries, FluxStatisticsChartTreemapNode } from '@flux-ui/types';
2
+ import { BarSeriesOption, BoxplotSeriesOption, CandlestickSeriesOption, GaugeSeriesOption, HeatmapSeriesOption, LineSeriesOption, PieSeriesOption, RadarSeriesOption, ScatterSeriesOption, TreemapSeriesOption } from 'echarts/charts';
3
+ export declare function resolveChartColor(color?: FluxStatisticsChartColor): string | undefined;
4
+ export declare function extractLabels(series: readonly {
5
+ readonly data: readonly (number | FluxStatisticsChartCategoryPoint)[];
6
+ }[]): readonly string[] | undefined;
7
+ export declare function toLineSeries(s: FluxStatisticsChartLineSeries, fallbackColor: string): LineSeriesOption;
8
+ export declare function toAreaSeries(s: FluxStatisticsChartAreaSeries, fallbackColor: string): LineSeriesOption;
9
+ export declare function toBarSeries(s: FluxStatisticsChartBarSeries, fallbackColor: string): BarSeriesOption;
10
+ export declare function toMixedSeries(s: FluxStatisticsChartMixedSeries, fallbackColor: string): LineSeriesOption | BarSeriesOption;
11
+ export declare function toPieSeries(slices: readonly FluxStatisticsChartPieSlice[], palette: readonly string[]): PieSeriesOption;
12
+ export declare function toDonutSeries(slices: readonly FluxStatisticsChartPieSlice[], palette: readonly string[]): PieSeriesOption;
13
+ export declare function toPolarAreaSeries(slices: readonly FluxStatisticsChartPieSlice[], palette: readonly string[]): PieSeriesOption;
14
+ export declare function toRadarSeries(series: readonly FluxStatisticsChartRadarSeries[], palette: readonly string[]): RadarSeriesOption;
15
+ export declare function toScatterSeries(s: FluxStatisticsChartScatterSeries, fallbackColor: string): ScatterSeriesOption;
16
+ export declare function toBubbleSeries(s: FluxStatisticsChartBubbleSeries, fallbackColor: string): ScatterSeriesOption;
17
+ export declare function toCandlestickSeries(s: FluxStatisticsChartCandlestickSeries): CandlestickSeriesOption;
18
+ export declare function toBoxPlotSeries(s: FluxStatisticsChartBoxPlotSeries, fallbackColor: string): BoxplotSeriesOption;
19
+ export declare function toHeatmapSeries(s: FluxStatisticsChartHeatmapSeries, xLabels: readonly (string | number)[], yLabels: readonly (string | number)[]): HeatmapSeriesOption;
20
+ export declare function toTreemapSeries(nodes: readonly FluxStatisticsChartTreemapNode[], palette: readonly string[]): TreemapSeriesOption;
21
+ export declare function toGaugeSeries(s: FluxStatisticsChartGaugeSeries, fallbackColor: string, index: number, total: number): GaugeSeriesOption;
22
+ export declare function cartesianFallbackLabels(series: readonly FluxStatisticsChartCartesianSeries[]): string[];
@@ -0,0 +1,76 @@
1
+ import { FluxIconName } from '@flux-ui/types';
2
+ import { EChartsOption } from '../composable';
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
+ export type TooltipStyleClasses = {
16
+ readonly statisticsChartTooltipTitle: string;
17
+ readonly statisticsChartTooltipBody: string;
18
+ readonly statisticsChartTooltipSection: string;
19
+ readonly statisticsChartTooltipSectionTitle: string;
20
+ readonly statisticsChartTooltipSectionBody: string;
21
+ readonly statisticsChartTooltipSeriesColor: string;
22
+ readonly statisticsChartTooltipSeriesIcon: string;
23
+ readonly statisticsChartTooltipSeriesName: string;
24
+ readonly statisticsChartTooltipSeriesValue: string;
25
+ readonly isActive: string;
26
+ readonly isDimmed: string;
27
+ };
28
+ export type Translator = (key: string) => string;
29
+ export interface SharedTooltipItem {
30
+ readonly name: string;
31
+ readonly value: number | string;
32
+ readonly color: string;
33
+ readonly icon?: FluxIconName;
34
+ readonly seriesIndex?: number;
35
+ readonly dataIndex?: number;
36
+ }
37
+ export type ChartTooltipValueFormatter = (value: number | string, item: SharedTooltipItem) => string;
38
+ export declare const CHART_DEFAULT_COLORS: readonly ["var(--chart-1)", "var(--chart-2)", "var(--chart-3)", "var(--chart-4)"];
39
+ export declare function buildTooltipFormatter(t: Translator, styles: TooltipStyleClasses, getSeriesIcons?: () => readonly (FluxIconName | undefined)[], valueFormatter?: ChartTooltipValueFormatter): (params: TooltipParam | TooltipParam[]) => string;
40
+ export declare function buildCartesianTooltipOptions(t: Translator, styles: TooltipStyleClasses, getSeriesIcons: () => readonly (FluxIconName | undefined)[], valueFormatter?: ChartTooltipValueFormatter): EChartsOption;
41
+ export declare function buildSharedItemTooltipFormatter(t: Translator, styles: TooltipStyleClasses, getItems: () => readonly SharedTooltipItem[], getTitle?: () => string | undefined, valueFormatter?: ChartTooltipValueFormatter): (params: TooltipParam | TooltipParam[]) => string;
42
+ export interface BoxPlotTooltipPoint {
43
+ readonly label?: string;
44
+ readonly min: number;
45
+ readonly q1: number;
46
+ readonly median: number;
47
+ readonly q3: number;
48
+ readonly max: number;
49
+ }
50
+ export declare function buildBoxPlotTooltipOptions(t: Translator, styles: TooltipStyleClasses, getSeries: () => readonly {
51
+ readonly name?: string;
52
+ readonly icon?: FluxIconName;
53
+ readonly data: readonly BoxPlotTooltipPoint[];
54
+ }[], getPalette: () => readonly string[]): EChartsOption;
55
+ export interface HeatmapTooltipPoint {
56
+ readonly x: string | number;
57
+ readonly y: string | number;
58
+ readonly value: number;
59
+ readonly formatted?: string;
60
+ }
61
+ export declare function buildHeatmapTooltipOptions(t: Translator, styles: TooltipStyleClasses, getSeries: () => readonly {
62
+ readonly name?: string;
63
+ readonly data: readonly HeatmapTooltipPoint[];
64
+ }[]): EChartsOption;
65
+ export interface TreemapTooltipNode {
66
+ readonly name: string;
67
+ readonly value?: number;
68
+ readonly color?: string;
69
+ }
70
+ export declare function buildTreemapTooltipOptions(t: Translator, styles: TooltipStyleClasses): EChartsOption;
71
+ export declare function buildGaugeTooltipOptions(t: Translator, styles: TooltipStyleClasses, getSeries: () => readonly {
72
+ readonly name?: string;
73
+ readonly value: number;
74
+ readonly icon?: FluxIconName;
75
+ }[], getPalette: () => readonly string[]): EChartsOption;
76
+ export declare function buildDefaultOptions(): EChartsOption;
@@ -0,0 +1,2 @@
1
+ import { FluxIconName } from '@flux-ui/types';
2
+ export declare function renderIconSvg(name: FluxIconName | undefined, color: string, size?: number): string;
@@ -0,0 +1,7 @@
1
+ export * from './baseOptions';
2
+ export * from './colors';
3
+ export * from './convert';
4
+ export * from './defaultOptions';
5
+ export * from './iconSvg';
6
+ export * from './seriesDefaults';
7
+ export * from './sparklineOptions';
@@ -0,0 +1,15 @@
1
+ import { BarSeriesOption, BoxplotSeriesOption, CandlestickSeriesOption, GaugeSeriesOption, HeatmapSeriesOption, LineSeriesOption, PieSeriesOption, RadarSeriesOption, ScatterSeriesOption, TreemapSeriesOption } from 'echarts/charts';
2
+ export declare const LINE_SERIES_DEFAULTS: Partial<LineSeriesOption>;
3
+ export declare const AREA_SERIES_DEFAULTS: Partial<LineSeriesOption>;
4
+ export declare const BAR_SERIES_DEFAULTS: Partial<BarSeriesOption>;
5
+ export declare const PIE_SERIES_DEFAULTS: Partial<PieSeriesOption>;
6
+ export declare const DONUT_SERIES_DEFAULTS: Partial<PieSeriesOption>;
7
+ export declare const POLAR_AREA_SERIES_DEFAULTS: Partial<PieSeriesOption>;
8
+ export declare const RADAR_SERIES_DEFAULTS: Partial<RadarSeriesOption>;
9
+ export declare const HEATMAP_SERIES_DEFAULTS: Partial<HeatmapSeriesOption>;
10
+ export declare const SCATTER_SERIES_DEFAULTS: Partial<ScatterSeriesOption>;
11
+ export declare const BUBBLE_SERIES_DEFAULTS: Partial<ScatterSeriesOption>;
12
+ export declare const BOXPLOT_SERIES_DEFAULTS: Partial<BoxplotSeriesOption>;
13
+ export declare const CANDLESTICK_SERIES_DEFAULTS: Partial<CandlestickSeriesOption>;
14
+ export declare const TREEMAP_SERIES_DEFAULTS: Partial<TreemapSeriesOption>;
15
+ export declare const GAUGE_SERIES_DEFAULTS: Partial<GaugeSeriesOption>;
@@ -0,0 +1,7 @@
1
+ import { EChartsOption } from '../composable';
2
+ export type SparklineVariant = 'line' | 'bar' | 'area';
3
+ export interface SparklineSeriesItem {
4
+ readonly name?: string;
5
+ readonly data: (number | string | null)[];
6
+ }
7
+ export declare function buildSparklineOptions(variant: SparklineVariant, color: string, series: readonly SparklineSeriesItem[]): EChartsOption;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flux-ui/statistics",
3
3
  "description": "Statistics components for the Flux UI library.",
4
- "version": "3.0.0-next.66",
4
+ "version": "3.0.0-next.68",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/basmilius",
@@ -49,29 +49,28 @@
49
49
  "types": "./dist/index.d.ts",
50
50
  "sideEffects": false,
51
51
  "dependencies": {
52
- "@basmilius/common": "^3.25.0",
53
- "@basmilius/utils": "^3.25.0",
54
- "@flux-ui/components": "3.0.0-next.66",
55
- "@flux-ui/internals": "3.0.0-next.66",
56
- "@flux-ui/types": "3.0.0-next.66",
52
+ "@basmilius/common": "^3.33.0",
53
+ "@basmilius/utils": "^3.33.0",
54
+ "@flux-ui/components": "3.0.0-next.68",
55
+ "@flux-ui/internals": "3.0.0-next.68",
56
+ "@flux-ui/types": "3.0.0-next.68",
57
57
  "clsx": "^2.1.1"
58
58
  },
59
59
  "peerDependencies": {
60
- "apexcharts": "^5.10.6",
60
+ "echarts": "^6.0.0",
61
61
  "lodash-es": "^4.18.1",
62
- "vue": "^3.6.0-beta.10",
63
- "vue-i18n": "^11.4.0",
64
- "vue3-apexcharts": "^1.11.1"
62
+ "vue": "^3.6.0-beta.12",
63
+ "vue-i18n": "^11.4.2"
65
64
  },
66
65
  "devDependencies": {
67
- "@basmilius/vite-preset": "^3.25.0",
66
+ "@basmilius/vite-preset": "^3.33.0",
68
67
  "@types/lodash-es": "^4.17.12",
69
- "@types/node": "^25.6.0",
70
- "@vitejs/plugin-vue": "^6.0.6",
68
+ "@types/node": "^25.8.0",
69
+ "@vitejs/plugin-vue": "^6.0.7",
71
70
  "@vue/tsconfig": "^0.9.1",
72
71
  "sass-embedded": "^1.99.0",
73
72
  "typescript": "^6.0.3",
74
- "vite": "^8.0.10",
75
- "vue-tsc": "^3.2.8"
73
+ "vite": "^8.0.13",
74
+ "vue-tsc": "^3.2.9"
76
75
  }
77
76
  }
@@ -1,59 +1,56 @@
1
1
  <template>
2
2
  <Chart
3
- :aspectRatio="aspectRatio"
4
- :options="merge({
5
- chart: {
6
- type: 'area',
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 { ApexOptions } from 'apexcharts';
10
+ import type { FluxStatisticsChartAreaSeries } from '@flux-ui/types';
37
11
  import { merge } from 'lodash-es';
38
12
  import { computed } from 'vue';
39
- import { useI18n } from 'vue-i18n';
13
+ import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
+ import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toAreaSeries } 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
- options = {},
44
- series
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 aspectRatio?: number;
47
- readonly options?: ApexOptions;
48
- readonly series: ApexOptions['series'];
28
+ readonly advancedOptions?: EChartsOption;
29
+ readonly labels?: readonly string[];
30
+ readonly series: readonly FluxStatisticsChartAreaSeries[];
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} = useI18n({useScope: 'parent'});
38
+ const { t, palette } = useChartSeriesSetup(() => series);
52
39
 
53
- const translatedSeries = computed(() => {
54
- return (series as any).map((seriesItem: any) => ({
55
- ...seriesItem,
56
- name: t(seriesItem.name as string)
57
- }));
40
+ const xLabels = computed<readonly string[]>(() => labels ?? extractLabels(series) ?? cartesianFallbackLabels(series));
41
+
42
+ const echartsSeries = computed(() => series.map((s, i) =>
43
+ toAreaSeries({ ...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>
@@ -1,51 +1,56 @@
1
1
  <template>
2
2
  <Chart
3
- :aspectRatio="aspectRatio"
4
- :options="merge({
5
- chart: {
6
- type: 'bar'
7
- },
8
- grid: {
9
- show: true,
10
- clipMarkers: false,
11
- padding: {
12
- top: 18,
13
- left: 9,
14
- right: 9
15
- }
16
- },
17
- tooltip: {
18
- shared: true,
19
- intersect: false
20
- }
21
- }, options)"
22
- :series="translatedSeries"/>
3
+ ref="chartRef"
4
+ :options="mergedOptions"/>
23
5
  </template>
24
6
 
25
7
  <script
26
8
  lang="ts"
27
9
  setup>
28
- import type { ApexOptions } from 'apexcharts';
10
+ import type { FluxStatisticsChartBarSeries } from '@flux-ui/types';
29
11
  import { merge } from 'lodash-es';
30
12
  import { computed } from 'vue';
31
- import { useI18n } from 'vue-i18n';
13
+ import { useChartSeriesSetup, type EChartsOption } from '~flux/statistics/composable';
14
+ import { buildCartesianBaseOptions, buildCartesianTooltipOptions, cartesianFallbackLabels, type ChartTooltipValueFormatter, extractLabels, toBarSeries } from '~flux/statistics/util';
32
15
  import Chart from './FluxStatisticsChart.vue';
16
+ import $style from '~flux/statistics/css/Chart.module.scss';
33
17
 
34
18
  const {
35
- options = {},
36
- series
19
+ advancedOptions = {},
20
+ labels,
21
+ series,
22
+ splitLines = false,
23
+ tooltip = false,
24
+ tooltipValueFormatter,
25
+ xAxisLabels = false,
26
+ yAxisLabels = false
37
27
  } = defineProps<{
38
- readonly aspectRatio?: number;
39
- readonly options?: ApexOptions;
40
- readonly series: ApexOptions['series'];
28
+ readonly advancedOptions?: EChartsOption;
29
+ readonly labels?: readonly string[];
30
+ readonly series: readonly FluxStatisticsChartBarSeries[];
31
+ readonly splitLines?: boolean;
32
+ readonly tooltip?: boolean;
33
+ readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
34
+ readonly xAxisLabels?: boolean;
35
+ readonly yAxisLabels?: boolean;
41
36
  }>();
42
37
 
43
- const {t} = useI18n({useScope: 'parent'});
38
+ const { t, palette } = useChartSeriesSetup(() => series);
44
39
 
45
- const translatedSeries = computed(() => {
46
- return (series as any).map((seriesItem: any) => ({
47
- ...seriesItem,
48
- name: t(seriesItem.name as string)
49
- }));
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 });
50
55
  });
51
56
  </script>
@@ -7,6 +7,18 @@
7
7
  {{ title }}
8
8
  </span>
9
9
 
10
+ <FluxTooltip
11
+ v-if="slots.info"
12
+ direction="vertical">
13
+ <template #content>
14
+ <slot name="info"/>
15
+ </template>
16
+
17
+ <FluxIcon
18
+ :class="$style.statisticsBaseHeaderInfo"
19
+ name="circle-info"/>
20
+ </FluxTooltip>
21
+
10
22
  <FluxIcon
11
23
  v-if="icon"
12
24
  :class="$style.statisticsBaseHeaderIcon"
@@ -26,7 +38,7 @@
26
38
  <script
27
39
  lang="ts"
28
40
  setup>
29
- import { FluxIcon, FluxPane } from '@flux-ui/components';
41
+ import { FluxIcon, FluxPane, FluxTooltip } from '@flux-ui/components';
30
42
  import type { FluxIconName } from '@flux-ui/types';
31
43
  import $style from '~flux/statistics/css/Base.module.scss';
32
44
 
@@ -39,5 +51,6 @@
39
51
  const slots = defineSlots<{
40
52
  content?(): any;
41
53
  default?(): any;
54
+ info?(): any;
42
55
  }>();
43
56
  </script>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <Chart
3
+ ref="chartRef"
4
+ :options="mergedOptions"/>
5
+ </template>
6
+
7
+ <script
8
+ lang="ts"
9
+ setup>
10
+ import type { FluxStatisticsChartBoxPlotSeries } 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 { buildBoxPlotTooltipOptions, buildCartesianBaseOptions, toBoxPlotSeries } 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
+ xAxisLabels = false,
25
+ yAxisLabels = false
26
+ } = defineProps<{
27
+ readonly advancedOptions?: EChartsOption;
28
+ readonly labels?: readonly string[];
29
+ readonly series: readonly FluxStatisticsChartBoxPlotSeries[];
30
+ readonly splitLines?: boolean;
31
+ readonly tooltip?: boolean;
32
+ readonly xAxisLabels?: boolean;
33
+ readonly yAxisLabels?: boolean;
34
+ }>();
35
+
36
+ const { t, palette } = useChartSeriesSetup(() => series);
37
+
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
+ });
69
+ </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 { FluxStatisticsChartBubbleSeries } 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, toBubbleSeries } 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 FluxStatisticsChartBubbleSeries[];
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
+ 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
+ });
56
+ </script>
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <Chart
3
+ ref="chartRef"
4
+ :options="mergedOptions"/>
5
+ </template>
6
+
7
+ <script
8
+ lang="ts"
9
+ setup>
10
+ import type { FluxStatisticsChartCandlestickSeries } 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, resolveChartColor, toCandlestickSeries } 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
+ xAxisLabels = false,
25
+ yAxisLabels = false
26
+ } = defineProps<{
27
+ readonly advancedOptions?: EChartsOption;
28
+ readonly labels?: readonly string[];
29
+ readonly series: readonly FluxStatisticsChartCandlestickSeries[];
30
+ readonly splitLines?: boolean;
31
+ readonly tooltip?: boolean;
32
+ readonly xAxisLabels?: boolean;
33
+ readonly yAxisLabels?: boolean;
34
+ }>();
35
+
36
+ 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
+ ]
48
+ });
49
+
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
+ });
81
+ </script>