@flux-ui/statistics 3.0.0-next.68 → 3.0.0-next.70
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/dist/component/FluxStatisticsLegendScope.vue.d.ts +13 -0
- package/dist/component/FluxStatisticsPercentageBar.vue.d.ts +8 -0
- package/dist/component/index.d.ts +2 -0
- package/dist/composable/index.d.ts +4 -2
- package/dist/composable/useChartBaseSetup.d.ts +8 -0
- package/dist/composable/{usePieSlicesSetup.d.ts → useChartSlicesSetup.d.ts} +2 -2
- package/dist/index.css +67 -32
- package/dist/index.js +917 -517
- package/dist/index.js.map +1 -1
- package/dist/util/index.d.ts +5 -6
- package/dist/util/options/buildBaseOptions.d.ts +2 -0
- package/dist/util/{baseOptions.d.ts → options/buildCartesianBaseOptions.d.ts} +4 -6
- package/dist/util/options/buildCircularBaseOptions.d.ts +2 -0
- package/dist/util/options/cartesian/buildAreaChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildBarChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildBoxPlotChartOptions.d.ts +16 -0
- package/dist/util/options/cartesian/buildBubbleChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/buildCandlestickChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildHeatmapChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/buildLineChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildMixedChartOptions.d.ts +17 -0
- package/dist/util/options/cartesian/buildScatterChartOptions.d.ts +15 -0
- package/dist/util/options/cartesian/index.d.ts +18 -0
- package/dist/util/options/circular/buildDonutChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildGaugeChartOptions.d.ts +14 -0
- package/dist/util/options/circular/buildPieChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildPolarAreaChartOptions.d.ts +15 -0
- package/dist/util/options/circular/buildRadarChartOptions.d.ts +13 -0
- package/dist/util/options/circular/buildTreemapChartOptions.d.ts +12 -0
- package/dist/util/options/circular/index.d.ts +12 -0
- package/dist/util/options/index.d.ts +6 -0
- package/dist/util/series/chartColors.d.ts +3 -0
- package/dist/util/{convert.d.ts → series/converters.d.ts} +1 -6
- package/dist/util/series/index.d.ts +4 -0
- package/dist/util/series/labels.d.ts +5 -0
- package/dist/util/tooltips/buildBoxPlotTooltip.d.ts +22 -0
- package/dist/util/tooltips/buildCartesianTooltip.d.ts +10 -0
- package/dist/util/tooltips/buildGaugeTooltip.d.ts +14 -0
- package/dist/util/tooltips/buildHeatmapTooltip.d.ts +17 -0
- package/dist/util/tooltips/buildRadarTooltip.d.ts +11 -0
- package/dist/util/tooltips/buildSharedItemTooltip.d.ts +10 -0
- package/dist/util/tooltips/buildTreemapTooltip.d.ts +12 -0
- package/dist/util/tooltips/index.d.ts +15 -0
- package/dist/util/tooltips/render.d.ts +4 -0
- package/dist/util/tooltips/types.d.ts +24 -0
- package/package.json +13 -13
- package/src/component/FluxStatisticsAreaChart.vue +15 -19
- package/src/component/FluxStatisticsBarChart.vue +15 -19
- package/src/component/FluxStatisticsBoxPlotChart.vue +14 -34
- package/src/component/FluxStatisticsBubbleChart.vue +13 -23
- package/src/component/FluxStatisticsCandlestickChart.vue +14 -45
- package/src/component/FluxStatisticsChart.vue +2 -2
- package/src/component/FluxStatisticsChartPane.vue +12 -13
- package/src/component/FluxStatisticsDonutChart.vue +15 -24
- package/src/component/FluxStatisticsHeatmapChart.vue +15 -48
- package/src/component/FluxStatisticsLegendScope.vue +16 -0
- package/src/component/FluxStatisticsLineChart.vue +15 -19
- package/src/component/FluxStatisticsMixedChart.vue +15 -18
- package/src/component/FluxStatisticsPercentageBar.vue +90 -0
- package/src/component/FluxStatisticsPieChart.vue +15 -24
- package/src/component/FluxStatisticsPolarAreaChart.vue +15 -24
- package/src/component/FluxStatisticsRadarChart.vue +11 -79
- package/src/component/FluxStatisticsRadialBar.vue +11 -20
- package/src/component/FluxStatisticsScatterChart.vue +13 -23
- package/src/component/FluxStatisticsTreemapChart.vue +11 -15
- package/src/component/index.ts +2 -0
- package/src/composable/index.ts +4 -2
- package/src/composable/useChartBaseSetup.ts +16 -0
- package/src/composable/{usePieSlicesSetup.ts → useChartSlicesSetup.ts} +3 -3
- package/src/css/Chart.module.scss +10 -15
- package/src/css/ChartPane.module.scss +3 -10
- package/src/css/Empty.module.scss +2 -2
- package/src/css/Legend.module.scss +16 -8
- package/src/css/Meter.module.scss +1 -0
- package/src/css/PercentageBar.module.scss +36 -0
- package/src/util/index.ts +5 -6
- package/src/util/options/buildBaseOptions.ts +31 -0
- package/src/util/{baseOptions.ts → options/buildCartesianBaseOptions.ts} +15 -22
- package/src/util/options/buildCircularBaseOptions.ts +10 -0
- package/src/util/options/cartesian/buildAreaChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildBarChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildBoxPlotChartOptions.ts +63 -0
- package/src/util/options/cartesian/buildBubbleChartOptions.ts +48 -0
- package/src/util/options/cartesian/buildCandlestickChartOptions.ts +77 -0
- package/src/util/options/cartesian/buildHeatmapChartOptions.ts +72 -0
- package/src/util/options/cartesian/buildLineChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildMixedChartOptions.ts +44 -0
- package/src/util/options/cartesian/buildScatterChartOptions.ts +48 -0
- package/src/util/options/cartesian/index.ts +18 -0
- package/src/util/options/circular/buildDonutChartOptions.ts +31 -0
- package/src/util/options/circular/buildGaugeChartOptions.ts +45 -0
- package/src/util/options/circular/buildPieChartOptions.ts +31 -0
- package/src/util/options/circular/buildPolarAreaChartOptions.ts +31 -0
- package/src/util/options/circular/buildRadarChartOptions.ts +52 -0
- package/src/util/options/circular/buildTreemapChartOptions.ts +28 -0
- package/src/util/options/circular/index.ts +12 -0
- package/src/util/options/index.ts +6 -0
- package/src/util/series/chartColors.ts +20 -0
- package/src/util/{convert.ts → series/converters.ts} +2 -44
- package/src/util/series/index.ts +4 -0
- package/src/util/series/labels.ts +30 -0
- package/src/util/tooltips/buildBoxPlotTooltip.ts +66 -0
- package/src/util/tooltips/buildCartesianTooltip.ts +44 -0
- package/src/util/tooltips/buildGaugeTooltip.ts +49 -0
- package/src/util/tooltips/buildHeatmapTooltip.ts +57 -0
- package/src/util/tooltips/buildRadarTooltip.ts +53 -0
- package/src/util/tooltips/buildSharedItemTooltip.ts +38 -0
- package/src/util/tooltips/buildTreemapTooltip.ts +49 -0
- package/src/util/tooltips/index.ts +15 -0
- package/src/util/tooltips/render.ts +66 -0
- package/src/util/tooltips/types.ts +29 -0
- package/dist/util/defaultOptions.d.ts +0 -76
- package/src/util/defaultOptions.ts +0 -398
- /package/dist/util/{iconSvg.d.ts → icons.d.ts} +0 -0
- /package/dist/util/{seriesDefaults.d.ts → series/defaults.d.ts} +0 -0
- /package/dist/util/{sparklineOptions.d.ts → sparkline.d.ts} +0 -0
- /package/src/util/{iconSvg.ts → icons.ts} +0 -0
- /package/src/util/{seriesDefaults.ts → series/defaults.ts} +0 -0
- /package/src/util/{sparklineOptions.ts → sparkline.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { AreaChartOptionsInput } from './buildAreaChartOptions';
|
|
2
|
+
export { buildAreaChartOptions } from './buildAreaChartOptions';
|
|
3
|
+
export type { BarChartOptionsInput } from './buildBarChartOptions';
|
|
4
|
+
export { buildBarChartOptions } from './buildBarChartOptions';
|
|
5
|
+
export type { BoxPlotChartOptionsInput } from './buildBoxPlotChartOptions';
|
|
6
|
+
export { buildBoxPlotChartOptions } from './buildBoxPlotChartOptions';
|
|
7
|
+
export type { BubbleChartOptionsInput } from './buildBubbleChartOptions';
|
|
8
|
+
export { buildBubbleChartOptions } from './buildBubbleChartOptions';
|
|
9
|
+
export type { CandlestickChartOptionsInput } from './buildCandlestickChartOptions';
|
|
10
|
+
export { buildCandlestickChartOptions, candlestickLegendItemBuilder } from './buildCandlestickChartOptions';
|
|
11
|
+
export type { HeatmapChartOptionsInput } from './buildHeatmapChartOptions';
|
|
12
|
+
export { buildHeatmapChartOptions } from './buildHeatmapChartOptions';
|
|
13
|
+
export type { LineChartOptionsInput } from './buildLineChartOptions';
|
|
14
|
+
export { buildLineChartOptions } from './buildLineChartOptions';
|
|
15
|
+
export type { MixedChartOptionsInput } from './buildMixedChartOptions';
|
|
16
|
+
export { buildMixedChartOptions } from './buildMixedChartOptions';
|
|
17
|
+
export type { ScatterChartOptionsInput } from './buildScatterChartOptions';
|
|
18
|
+
export { buildScatterChartOptions } from './buildScatterChartOptions';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
4
|
+
import { toDonutSeries } from '../../series';
|
|
5
|
+
import type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipStyleClasses, Translator } from '../../tooltips';
|
|
6
|
+
import { buildSharedItemTooltip } from '../../tooltips';
|
|
7
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
8
|
+
|
|
9
|
+
export interface DonutChartOptionsInput {
|
|
10
|
+
readonly slices: readonly FluxStatisticsChartPieSlice[];
|
|
11
|
+
readonly palette: readonly string[];
|
|
12
|
+
readonly tooltipItems: readonly SharedTooltipItem[];
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
readonly t: Translator;
|
|
15
|
+
readonly styles: TooltipStyleClasses;
|
|
16
|
+
readonly tooltip?: boolean;
|
|
17
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
18
|
+
readonly advancedOptions?: EChartsOption;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function buildDonutChartOptions(input: DonutChartOptionsInput): EChartsOption {
|
|
22
|
+
const { slices, palette, tooltipItems, title, t, styles, tooltip = false, tooltipValueFormatter, advancedOptions = {} } = input;
|
|
23
|
+
|
|
24
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
25
|
+
? buildSharedItemTooltip({ t, styles, getItems: () => tooltipItems, getTitle: () => title, valueFormatter: tooltipValueFormatter })
|
|
26
|
+
: { tooltip: { show: false } };
|
|
27
|
+
|
|
28
|
+
const echartsSeries = [toDonutSeries(slices, palette)];
|
|
29
|
+
|
|
30
|
+
return merge({}, buildCircularBaseOptions(), tooltipOptions, advancedOptions, { series: echartsSeries, color: palette });
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FluxStatisticsChartGaugeSeries } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { ChartLegendItem } from '~flux/statistics/composable/useChartLegend';
|
|
4
|
+
import type { EChartsOption } from '~flux/statistics/composable/useECharts';
|
|
5
|
+
import { toGaugeSeries } from '../../series';
|
|
6
|
+
import type { TooltipStyleClasses, Translator } from '../../tooltips';
|
|
7
|
+
import { buildGaugeTooltip } from '../../tooltips';
|
|
8
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
9
|
+
|
|
10
|
+
export interface GaugeChartOptionsInput {
|
|
11
|
+
readonly series: readonly FluxStatisticsChartGaugeSeries[];
|
|
12
|
+
readonly palette: readonly string[];
|
|
13
|
+
readonly t: Translator;
|
|
14
|
+
readonly styles: TooltipStyleClasses;
|
|
15
|
+
readonly tooltip?: boolean;
|
|
16
|
+
readonly advancedOptions?: EChartsOption;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function gaugeLegendItemBuilder(
|
|
20
|
+
s: FluxStatisticsChartGaugeSeries,
|
|
21
|
+
color: string,
|
|
22
|
+
_index: number,
|
|
23
|
+
t: Translator
|
|
24
|
+
): ChartLegendItem {
|
|
25
|
+
return {
|
|
26
|
+
color,
|
|
27
|
+
icon: s.icon,
|
|
28
|
+
label: s.name ? t(String(s.name)) : '',
|
|
29
|
+
value: s.value
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildGaugeChartOptions(input: GaugeChartOptionsInput): EChartsOption {
|
|
34
|
+
const { series, palette, t, styles, tooltip = false, advancedOptions = {} } = input;
|
|
35
|
+
|
|
36
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
37
|
+
? buildGaugeTooltip({ t, styles, getSeries: () => series, getPalette: () => palette })
|
|
38
|
+
: { tooltip: { show: false } };
|
|
39
|
+
|
|
40
|
+
const echartsSeries = series.map((s, i) =>
|
|
41
|
+
toGaugeSeries({ ...s, name: s.name ? t(String(s.name)) : s.name }, palette[i], i, series.length)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return merge({}, buildCircularBaseOptions(), tooltipOptions, advancedOptions, { series: echartsSeries, color: palette });
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
4
|
+
import { toPieSeries } from '../../series';
|
|
5
|
+
import type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipStyleClasses, Translator } from '../../tooltips';
|
|
6
|
+
import { buildSharedItemTooltip } from '../../tooltips';
|
|
7
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
8
|
+
|
|
9
|
+
export interface PieChartOptionsInput {
|
|
10
|
+
readonly slices: readonly FluxStatisticsChartPieSlice[];
|
|
11
|
+
readonly palette: readonly string[];
|
|
12
|
+
readonly tooltipItems: readonly SharedTooltipItem[];
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
readonly t: Translator;
|
|
15
|
+
readonly styles: TooltipStyleClasses;
|
|
16
|
+
readonly tooltip?: boolean;
|
|
17
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
18
|
+
readonly advancedOptions?: EChartsOption;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function buildPieChartOptions(input: PieChartOptionsInput): EChartsOption {
|
|
22
|
+
const { slices, palette, tooltipItems, title, t, styles, tooltip = false, tooltipValueFormatter, advancedOptions = {} } = input;
|
|
23
|
+
|
|
24
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
25
|
+
? buildSharedItemTooltip({ t, styles, getItems: () => tooltipItems, getTitle: () => title, valueFormatter: tooltipValueFormatter })
|
|
26
|
+
: { tooltip: { show: false } };
|
|
27
|
+
|
|
28
|
+
const echartsSeries = [toPieSeries(slices, palette)];
|
|
29
|
+
|
|
30
|
+
return merge({}, buildCircularBaseOptions(), tooltipOptions, advancedOptions, { series: echartsSeries, color: palette });
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FluxStatisticsChartPieSlice } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
4
|
+
import { toPolarAreaSeries } from '../../series';
|
|
5
|
+
import type { ChartTooltipValueFormatter, SharedTooltipItem, TooltipStyleClasses, Translator } from '../../tooltips';
|
|
6
|
+
import { buildSharedItemTooltip } from '../../tooltips';
|
|
7
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
8
|
+
|
|
9
|
+
export interface PolarAreaChartOptionsInput {
|
|
10
|
+
readonly slices: readonly FluxStatisticsChartPieSlice[];
|
|
11
|
+
readonly palette: readonly string[];
|
|
12
|
+
readonly tooltipItems: readonly SharedTooltipItem[];
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
readonly t: Translator;
|
|
15
|
+
readonly styles: TooltipStyleClasses;
|
|
16
|
+
readonly tooltip?: boolean;
|
|
17
|
+
readonly tooltipValueFormatter?: ChartTooltipValueFormatter;
|
|
18
|
+
readonly advancedOptions?: EChartsOption;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function buildPolarAreaChartOptions(input: PolarAreaChartOptionsInput): EChartsOption {
|
|
22
|
+
const { slices, palette, tooltipItems, title, t, styles, tooltip = false, tooltipValueFormatter, advancedOptions = {} } = input;
|
|
23
|
+
|
|
24
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
25
|
+
? buildSharedItemTooltip({ t, styles, getItems: () => tooltipItems, getTitle: () => title, valueFormatter: tooltipValueFormatter })
|
|
26
|
+
: { tooltip: { show: false } };
|
|
27
|
+
|
|
28
|
+
const echartsSeries = [toPolarAreaSeries(slices, palette)];
|
|
29
|
+
|
|
30
|
+
return merge({}, buildCircularBaseOptions(), tooltipOptions, advancedOptions, { series: echartsSeries, color: palette });
|
|
31
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { FluxStatisticsChartRadarIndicator, FluxStatisticsChartRadarSeries } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
4
|
+
import { toRadarSeries } from '../../series';
|
|
5
|
+
import type { TooltipStyleClasses, Translator } from '../../tooltips';
|
|
6
|
+
import { buildRadarTooltip } from '../../tooltips';
|
|
7
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
8
|
+
|
|
9
|
+
export interface RadarChartOptionsInput {
|
|
10
|
+
readonly series: readonly FluxStatisticsChartRadarSeries[];
|
|
11
|
+
readonly indicators: readonly FluxStatisticsChartRadarIndicator[];
|
|
12
|
+
readonly palette: readonly string[];
|
|
13
|
+
readonly t: Translator;
|
|
14
|
+
readonly styles: TooltipStyleClasses;
|
|
15
|
+
readonly tooltip?: boolean;
|
|
16
|
+
readonly advancedOptions?: EChartsOption;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function buildRadarChartOptions(input: RadarChartOptionsInput): EChartsOption {
|
|
20
|
+
const { series, indicators, palette, t, styles, tooltip = false, advancedOptions = {} } = input;
|
|
21
|
+
|
|
22
|
+
const radarConfig: EChartsOption = {
|
|
23
|
+
radar: {
|
|
24
|
+
indicator: indicators.map(i => ({ name: t(String(i.name)), max: i.max })),
|
|
25
|
+
splitLine: { lineStyle: { color: 'var(--gray-200)' } },
|
|
26
|
+
splitArea: { show: false },
|
|
27
|
+
axisLine: { lineStyle: { color: 'var(--gray-200)' } },
|
|
28
|
+
axisName: {
|
|
29
|
+
color: 'var(--foreground-secondary)',
|
|
30
|
+
fontSize: 12,
|
|
31
|
+
fontWeight: 500
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
37
|
+
? buildRadarTooltip({
|
|
38
|
+
t,
|
|
39
|
+
styles,
|
|
40
|
+
getSeries: () => series,
|
|
41
|
+
getIndicators: () => indicators,
|
|
42
|
+
getPalette: () => palette
|
|
43
|
+
})
|
|
44
|
+
: { tooltip: { show: false } };
|
|
45
|
+
|
|
46
|
+
const echartsSeries = [toRadarSeries(
|
|
47
|
+
series.map(s => ({ ...s, name: s.name ? t(String(s.name)) : undefined })),
|
|
48
|
+
palette
|
|
49
|
+
)];
|
|
50
|
+
|
|
51
|
+
return merge({}, buildCircularBaseOptions(), radarConfig, tooltipOptions, advancedOptions, { series: echartsSeries, color: palette });
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FluxStatisticsChartTreemapNode } from '@flux-ui/types';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
4
|
+
import { CHART_DEFAULT_COLORS, toTreemapSeries } from '../../series';
|
|
5
|
+
import type { TooltipStyleClasses, Translator } from '../../tooltips';
|
|
6
|
+
import { buildTreemapTooltip } from '../../tooltips';
|
|
7
|
+
import { buildCircularBaseOptions } from '../buildCircularBaseOptions';
|
|
8
|
+
|
|
9
|
+
export interface TreemapChartOptionsInput {
|
|
10
|
+
readonly nodes: readonly FluxStatisticsChartTreemapNode[];
|
|
11
|
+
readonly palette?: readonly string[];
|
|
12
|
+
readonly t: Translator;
|
|
13
|
+
readonly styles: TooltipStyleClasses;
|
|
14
|
+
readonly tooltip?: boolean;
|
|
15
|
+
readonly advancedOptions?: EChartsOption;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildTreemapChartOptions(input: TreemapChartOptionsInput): EChartsOption {
|
|
19
|
+
const { nodes, palette = CHART_DEFAULT_COLORS, t, styles, tooltip = false, advancedOptions = {} } = input;
|
|
20
|
+
|
|
21
|
+
const tooltipOptions: EChartsOption = tooltip
|
|
22
|
+
? buildTreemapTooltip({ t, styles })
|
|
23
|
+
: { tooltip: { show: false } };
|
|
24
|
+
|
|
25
|
+
const echartsSeries = [toTreemapSeries(nodes, palette)];
|
|
26
|
+
|
|
27
|
+
return merge({}, buildCircularBaseOptions(), tooltipOptions, advancedOptions, { series: echartsSeries });
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { DonutChartOptionsInput } from './buildDonutChartOptions';
|
|
2
|
+
export { buildDonutChartOptions } from './buildDonutChartOptions';
|
|
3
|
+
export type { GaugeChartOptionsInput } from './buildGaugeChartOptions';
|
|
4
|
+
export { buildGaugeChartOptions, gaugeLegendItemBuilder } from './buildGaugeChartOptions';
|
|
5
|
+
export type { PieChartOptionsInput } from './buildPieChartOptions';
|
|
6
|
+
export { buildPieChartOptions } from './buildPieChartOptions';
|
|
7
|
+
export type { PolarAreaChartOptionsInput } from './buildPolarAreaChartOptions';
|
|
8
|
+
export { buildPolarAreaChartOptions } from './buildPolarAreaChartOptions';
|
|
9
|
+
export type { RadarChartOptionsInput } from './buildRadarChartOptions';
|
|
10
|
+
export { buildRadarChartOptions } from './buildRadarChartOptions';
|
|
11
|
+
export type { TreemapChartOptionsInput } from './buildTreemapChartOptions';
|
|
12
|
+
export { buildTreemapChartOptions } from './buildTreemapChartOptions';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './cartesian';
|
|
2
|
+
export * from './circular';
|
|
3
|
+
export { buildBaseOptions } from './buildBaseOptions';
|
|
4
|
+
export type { CartesianBaseConfig } from './buildCartesianBaseOptions';
|
|
5
|
+
export { buildCartesianBaseOptions, buildCartesianGrid } from './buildCartesianBaseOptions';
|
|
6
|
+
export { buildCircularBaseOptions } from './buildCircularBaseOptions';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FluxStatisticsChartColor } from '@flux-ui/types';
|
|
2
|
+
|
|
3
|
+
export const CHART_DEFAULT_COLORS = [
|
|
4
|
+
'var(--chart-1)',
|
|
5
|
+
'var(--chart-2)',
|
|
6
|
+
'var(--chart-3)',
|
|
7
|
+
'var(--chart-4)'
|
|
8
|
+
] as const;
|
|
9
|
+
|
|
10
|
+
export function resolveChartColor(color?: FluxStatisticsChartColor): string | undefined {
|
|
11
|
+
if (!color) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (color.startsWith('#') || color.startsWith('var(')) {
|
|
16
|
+
return color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return `var(--${color}-600)`;
|
|
20
|
+
}
|
|
@@ -4,9 +4,7 @@ import type {
|
|
|
4
4
|
FluxStatisticsChartBoxPlotSeries,
|
|
5
5
|
FluxStatisticsChartBubbleSeries,
|
|
6
6
|
FluxStatisticsChartCandlestickSeries,
|
|
7
|
-
FluxStatisticsChartCartesianSeries,
|
|
8
7
|
FluxStatisticsChartCategoryPoint,
|
|
9
|
-
FluxStatisticsChartColor,
|
|
10
8
|
FluxStatisticsChartGaugeSeries,
|
|
11
9
|
FluxStatisticsChartHeatmapSeries,
|
|
12
10
|
FluxStatisticsChartLineSeries,
|
|
@@ -28,6 +26,7 @@ import type {
|
|
|
28
26
|
ScatterSeriesOption,
|
|
29
27
|
TreemapSeriesOption
|
|
30
28
|
} from 'echarts/charts';
|
|
29
|
+
import { resolveChartColor } from './chartColors';
|
|
31
30
|
import {
|
|
32
31
|
AREA_SERIES_DEFAULTS,
|
|
33
32
|
BAR_SERIES_DEFAULTS,
|
|
@@ -43,43 +42,7 @@ import {
|
|
|
43
42
|
RADAR_SERIES_DEFAULTS,
|
|
44
43
|
SCATTER_SERIES_DEFAULTS,
|
|
45
44
|
TREEMAP_SERIES_DEFAULTS
|
|
46
|
-
} from './
|
|
47
|
-
|
|
48
|
-
export function resolveChartColor(color?: FluxStatisticsChartColor): string | undefined {
|
|
49
|
-
if (!color) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (color.startsWith('#') || color.startsWith('var(')) {
|
|
54
|
-
return color;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return `var(--${color}-600)`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function extractLabels(
|
|
61
|
-
series: readonly { readonly data: readonly (number | FluxStatisticsChartCategoryPoint)[] }[]
|
|
62
|
-
): readonly string[] | undefined {
|
|
63
|
-
for (const s of series) {
|
|
64
|
-
const labels: string[] = [];
|
|
65
|
-
let hasAny = false;
|
|
66
|
-
|
|
67
|
-
for (const point of s.data) {
|
|
68
|
-
if (typeof point === 'object' && point !== null && typeof point.label === 'string') {
|
|
69
|
-
labels.push(point.label);
|
|
70
|
-
hasAny = true;
|
|
71
|
-
} else {
|
|
72
|
-
labels.push('');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (hasAny) {
|
|
77
|
-
return labels;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
45
|
+
} from './defaults';
|
|
83
46
|
|
|
84
47
|
function extractValues(data: readonly (number | FluxStatisticsChartCategoryPoint)[]): number[] {
|
|
85
48
|
return data.map(point => typeof point === 'number' ? point : point.value);
|
|
@@ -353,8 +316,3 @@ export function toGaugeSeries(
|
|
|
353
316
|
}
|
|
354
317
|
} as GaugeSeriesOption;
|
|
355
318
|
}
|
|
356
|
-
|
|
357
|
-
export function cartesianFallbackLabels(series: readonly FluxStatisticsChartCartesianSeries[]): string[] {
|
|
358
|
-
const longest = series.reduce((max, s) => Math.max(max, s.data.length), 0);
|
|
359
|
-
return Array.from({ length: longest }, (_, i) => String(i + 1));
|
|
360
|
-
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FluxStatisticsChartCartesianSeries, FluxStatisticsChartCategoryPoint } from '@flux-ui/types';
|
|
2
|
+
|
|
3
|
+
export function extractLabels(
|
|
4
|
+
series: readonly { readonly data: readonly (number | FluxStatisticsChartCategoryPoint)[] }[]
|
|
5
|
+
): readonly string[] | undefined {
|
|
6
|
+
for (const s of series) {
|
|
7
|
+
const labels: string[] = [];
|
|
8
|
+
let hasAny = false;
|
|
9
|
+
|
|
10
|
+
for (const point of s.data) {
|
|
11
|
+
if (typeof point === 'object' && point !== null && typeof point.label === 'string') {
|
|
12
|
+
labels.push(point.label);
|
|
13
|
+
hasAny = true;
|
|
14
|
+
} else {
|
|
15
|
+
labels.push('');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (hasAny) {
|
|
20
|
+
return labels;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function cartesianFallbackLabels(series: readonly FluxStatisticsChartCartesianSeries[]): string[] {
|
|
28
|
+
const longest = series.reduce((max, s) => Math.max(max, s.data.length), 0);
|
|
29
|
+
return Array.from({ length: longest }, (_, i) => String(i + 1));
|
|
30
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
2
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
3
|
+
import { renderTooltip } from './render';
|
|
4
|
+
import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
5
|
+
|
|
6
|
+
export interface BoxPlotTooltipPoint {
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
readonly min: number;
|
|
9
|
+
readonly q1: number;
|
|
10
|
+
readonly median: number;
|
|
11
|
+
readonly q3: number;
|
|
12
|
+
readonly max: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BoxPlotTooltipInput {
|
|
16
|
+
readonly t: Translator;
|
|
17
|
+
readonly styles: TooltipStyleClasses;
|
|
18
|
+
readonly getSeries: () => readonly { readonly name?: string; readonly icon?: FluxIconName; readonly data: readonly BoxPlotTooltipPoint[] }[];
|
|
19
|
+
readonly getPalette: () => readonly string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function buildBoxPlotTooltip(input: BoxPlotTooltipInput): EChartsOption {
|
|
23
|
+
const { t, styles, getSeries, getPalette } = input;
|
|
24
|
+
|
|
25
|
+
const formatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
26
|
+
const param = Array.isArray(params) ? params[0] : params;
|
|
27
|
+
|
|
28
|
+
if (!param) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const series = getSeries();
|
|
33
|
+
const palette = getPalette();
|
|
34
|
+
const seriesIndex = param.seriesIndex ?? 0;
|
|
35
|
+
const dataIndex = param.dataIndex ?? 0;
|
|
36
|
+
const s = series[seriesIndex];
|
|
37
|
+
const point = s?.data[dataIndex];
|
|
38
|
+
|
|
39
|
+
if (!s || !point) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const color = palette[seriesIndex % palette.length];
|
|
44
|
+
const seriesName = s.name ? t(String(s.name)) : '';
|
|
45
|
+
const pointLabel = point.label ? t(String(point.label)) : '';
|
|
46
|
+
const title = [seriesName, pointLabel].filter(Boolean).join(' — ');
|
|
47
|
+
|
|
48
|
+
const items: SharedTooltipItem[] = [
|
|
49
|
+
{ name: 'Min', value: point.min, color },
|
|
50
|
+
{ name: 'Q1', value: point.q1, color },
|
|
51
|
+
{ name: 'Median', value: point.median, color },
|
|
52
|
+
{ name: 'Q3', value: point.q3, color },
|
|
53
|
+
{ name: 'Max', value: point.max, color }
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
return renderTooltip(t, styles, title, items);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
tooltip: {
|
|
61
|
+
show: true,
|
|
62
|
+
trigger: 'item',
|
|
63
|
+
formatter: formatter as never
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
2
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
3
|
+
import { extractValue, renderTooltip } from './render';
|
|
4
|
+
import type { ChartTooltipValueFormatter, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
5
|
+
|
|
6
|
+
export interface CartesianTooltipInput {
|
|
7
|
+
readonly t: Translator;
|
|
8
|
+
readonly styles: TooltipStyleClasses;
|
|
9
|
+
readonly getSeriesIcons: () => readonly (FluxIconName | undefined)[];
|
|
10
|
+
readonly valueFormatter?: ChartTooltipValueFormatter;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buildCartesianTooltip(input: CartesianTooltipInput): EChartsOption {
|
|
14
|
+
const { t, styles, getSeriesIcons, valueFormatter } = input;
|
|
15
|
+
|
|
16
|
+
const formatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
17
|
+
const items = Array.isArray(params) ? params : [params];
|
|
18
|
+
|
|
19
|
+
if (items.length === 0) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const rawTitle = items[0].axisValueLabel ?? items[0].axisValue ?? items[0].name ?? '';
|
|
24
|
+
const title = rawTitle ? t(String(rawTitle)) : '';
|
|
25
|
+
const icons = getSeriesIcons();
|
|
26
|
+
|
|
27
|
+
return renderTooltip(t, styles, title, items.map(param => ({
|
|
28
|
+
name: param.seriesName ?? '',
|
|
29
|
+
value: extractValue(param.value),
|
|
30
|
+
color: param.color,
|
|
31
|
+
icon: icons[param.seriesIndex],
|
|
32
|
+
seriesIndex: param.seriesIndex,
|
|
33
|
+
dataIndex: param.dataIndex
|
|
34
|
+
})), -1, valueFormatter);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
tooltip: {
|
|
39
|
+
show: true,
|
|
40
|
+
trigger: 'axis',
|
|
41
|
+
formatter: formatter as never
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FluxIconName } from '@flux-ui/types';
|
|
2
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
3
|
+
import { renderTooltip } from './render';
|
|
4
|
+
import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
5
|
+
|
|
6
|
+
export interface GaugeTooltipInput {
|
|
7
|
+
readonly t: Translator;
|
|
8
|
+
readonly styles: TooltipStyleClasses;
|
|
9
|
+
readonly getSeries: () => readonly { readonly name?: string; readonly value: number; readonly icon?: FluxIconName }[];
|
|
10
|
+
readonly getPalette: () => readonly string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buildGaugeTooltip(input: GaugeTooltipInput): EChartsOption {
|
|
14
|
+
const { t, styles, getSeries, getPalette } = input;
|
|
15
|
+
|
|
16
|
+
const formatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
17
|
+
const param = Array.isArray(params) ? params[0] : params;
|
|
18
|
+
|
|
19
|
+
if (!param) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const series = getSeries();
|
|
24
|
+
const palette = getPalette();
|
|
25
|
+
const seriesIndex = param.seriesIndex ?? 0;
|
|
26
|
+
const s = series[seriesIndex];
|
|
27
|
+
|
|
28
|
+
if (!s) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const color = palette[seriesIndex % palette.length];
|
|
33
|
+
const title = s.name ? t(String(s.name)) : '';
|
|
34
|
+
|
|
35
|
+
const items: SharedTooltipItem[] = [
|
|
36
|
+
{ name: '', value: s.value, color, icon: s.icon }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
return renderTooltip(t, styles, title, items);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
tooltip: {
|
|
44
|
+
show: true,
|
|
45
|
+
trigger: 'item',
|
|
46
|
+
formatter: formatter as never
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
2
|
+
import { renderTooltip } from './render';
|
|
3
|
+
import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
4
|
+
|
|
5
|
+
export interface HeatmapTooltipPoint {
|
|
6
|
+
readonly x: string | number;
|
|
7
|
+
readonly y: string | number;
|
|
8
|
+
readonly value: number;
|
|
9
|
+
readonly formatted?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface HeatmapTooltipInput {
|
|
13
|
+
readonly t: Translator;
|
|
14
|
+
readonly styles: TooltipStyleClasses;
|
|
15
|
+
readonly getSeries: () => readonly { readonly name?: string; readonly data: readonly HeatmapTooltipPoint[] }[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildHeatmapTooltip(input: HeatmapTooltipInput): EChartsOption {
|
|
19
|
+
const { t, styles, getSeries } = input;
|
|
20
|
+
|
|
21
|
+
const formatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
22
|
+
const param = Array.isArray(params) ? params[0] : params;
|
|
23
|
+
|
|
24
|
+
if (!param) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const series = getSeries();
|
|
29
|
+
const seriesIndex = param.seriesIndex ?? 0;
|
|
30
|
+
const dataIndex = param.dataIndex ?? 0;
|
|
31
|
+
const s = series[seriesIndex];
|
|
32
|
+
const point = s?.data[dataIndex];
|
|
33
|
+
|
|
34
|
+
if (!s || !point) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const seriesName = s.name ? t(String(s.name)) : '';
|
|
39
|
+
const xLabel = t(String(point.x));
|
|
40
|
+
const yLabel = t(String(point.y));
|
|
41
|
+
const title = [seriesName, `${xLabel} · ${yLabel}`].filter(Boolean).join(' — ');
|
|
42
|
+
|
|
43
|
+
const items: SharedTooltipItem[] = [
|
|
44
|
+
{ name: '', value: point.formatted ?? point.value, color: 'var(--primary-600)' }
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
return renderTooltip(t, styles, title, items);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
tooltip: {
|
|
52
|
+
show: true,
|
|
53
|
+
trigger: 'item',
|
|
54
|
+
formatter: formatter as never
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FluxStatisticsChartRadarIndicator, FluxStatisticsChartRadarSeries } from '@flux-ui/types';
|
|
2
|
+
import type { EChartsOption } from '~flux/statistics/composable';
|
|
3
|
+
import { renderTooltip } from './render';
|
|
4
|
+
import type { SharedTooltipItem, TooltipParam, TooltipStyleClasses, Translator } from './types';
|
|
5
|
+
|
|
6
|
+
export interface RadarTooltipInput {
|
|
7
|
+
readonly t: Translator;
|
|
8
|
+
readonly styles: TooltipStyleClasses;
|
|
9
|
+
readonly getSeries: () => readonly FluxStatisticsChartRadarSeries[];
|
|
10
|
+
readonly getIndicators: () => readonly FluxStatisticsChartRadarIndicator[];
|
|
11
|
+
readonly getPalette: () => readonly string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function buildRadarTooltip(input: RadarTooltipInput): EChartsOption {
|
|
15
|
+
const { t, styles, getSeries, getIndicators, getPalette } = input;
|
|
16
|
+
|
|
17
|
+
const formatter = (params: TooltipParam | TooltipParam[]): string => {
|
|
18
|
+
const param = Array.isArray(params) ? params[0] : params;
|
|
19
|
+
|
|
20
|
+
if (!param) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const series = getSeries();
|
|
25
|
+
const indicators = getIndicators();
|
|
26
|
+
const palette = getPalette();
|
|
27
|
+
const ringIndex = param.dataIndex ?? 0;
|
|
28
|
+
const ring = series[ringIndex];
|
|
29
|
+
|
|
30
|
+
if (!ring) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const color = palette[ringIndex % palette.length];
|
|
35
|
+
const title = ring.name ? t(String(ring.name)) : '';
|
|
36
|
+
|
|
37
|
+
const items: SharedTooltipItem[] = indicators.map((indicator, idx) => ({
|
|
38
|
+
name: indicator.name,
|
|
39
|
+
value: ring.values[idx] ?? '',
|
|
40
|
+
color
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
return renderTooltip(t, styles, title, items);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
tooltip: {
|
|
48
|
+
show: true,
|
|
49
|
+
trigger: 'item',
|
|
50
|
+
formatter: formatter as never
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|