mrxy-yk 1.8.7 → 1.9.0
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.
|
@@ -64,8 +64,14 @@ export declare function useEcLineOption(...args: ConstructorParameters<typeof Ec
|
|
|
64
64
|
* const chartHook = useEcPieOption({
|
|
65
65
|
* name: '报警种类',
|
|
66
66
|
* unit: '次',
|
|
67
|
-
*
|
|
67
|
+
* // 格式化图例
|
|
68
|
+
* lengthFormatter: '{name}{value}{unit}({percent}%)',
|
|
69
|
+
* // 标签显示在中心
|
|
68
70
|
* showCenterLabelData: true,
|
|
71
|
+
* // 标签数据格式化
|
|
72
|
+
* labelFormatter: '{total}\n{unit}\n{name}',
|
|
73
|
+
* // 中心标签数据保留位数
|
|
74
|
+
* centerLabelDataFractionDigits: 2
|
|
69
75
|
* })
|
|
70
76
|
* chartHook.setSeriesData([
|
|
71
77
|
* {name: 'A', value: 100},
|
|
@@ -79,8 +79,14 @@ function useEcLineOption(...args) {
|
|
|
79
79
|
* const chartHook = useEcPieOption({
|
|
80
80
|
* name: '报警种类',
|
|
81
81
|
* unit: '次',
|
|
82
|
-
*
|
|
82
|
+
* // 格式化图例
|
|
83
|
+
* lengthFormatter: '{name}{value}{unit}({percent}%)',
|
|
84
|
+
* // 标签显示在中心
|
|
83
85
|
* showCenterLabelData: true,
|
|
86
|
+
* // 标签数据格式化
|
|
87
|
+
* labelFormatter: '{total}\n{unit}\n{name}',
|
|
88
|
+
* // 中心标签数据保留位数
|
|
89
|
+
* centerLabelDataFractionDigits: 2
|
|
84
90
|
* })
|
|
85
91
|
* chartHook.setSeriesData([
|
|
86
92
|
* {name: 'A', value: 100},
|
|
@@ -18,7 +18,7 @@ var EcPieOption = class extends EcBasicOption {
|
|
|
18
18
|
showCenterLabelData = false;
|
|
19
19
|
centerLabelData = 0;
|
|
20
20
|
constructor(option) {
|
|
21
|
-
const { unit, name, lengthFormatter, showCenterLabelData, labelFormatter, series: seriesOption = {}, option: ecOptionBasicOption } = option || {};
|
|
21
|
+
const { unit, name, lengthFormatter, showCenterLabelData, labelDataFractionDigits = 2, labelFormatter, series: seriesOption = {}, option: ecOptionBasicOption } = option || {};
|
|
22
22
|
const seriesLabel = { rich: {
|
|
23
23
|
name: {
|
|
24
24
|
fontSize: 14,
|
|
@@ -48,9 +48,11 @@ var EcPieOption = class extends EcBasicOption {
|
|
|
48
48
|
if (typeof labelFormatter === "function") return labelFormatter({
|
|
49
49
|
name,
|
|
50
50
|
unit: this.unit,
|
|
51
|
-
total: this.centerLabelData
|
|
51
|
+
total: this.centerLabelData,
|
|
52
|
+
value: e.value,
|
|
53
|
+
e
|
|
52
54
|
});
|
|
53
|
-
return labelFormatter.replace(/\{name}/g, `{name|${name}}`).replace(/\{unit}/g, `{unit|${unit || ""}}`).replace(/\{total}/g, `{total|${this.centerLabelData.toFixed(
|
|
55
|
+
return labelFormatter.replace(/\{name}/g, `{name|${name}}`).replace(/\{unit}/g, `{unit|${unit || ""}}`).replace(/\{value}/g, `{value|${e.value || ""}}`).replace(/\{total}/g, `{total|${this.centerLabelData.toFixed(labelDataFractionDigits)}}`);
|
|
54
56
|
} });
|
|
55
57
|
seriesOption.label = ObjectUtil.assignDeep(seriesLabel, seriesOption.label || {});
|
|
56
58
|
const series = [new EcPieSeries({
|
|
@@ -86,17 +86,19 @@ export namespace PieModule {
|
|
|
86
86
|
unit: string,
|
|
87
87
|
value: number,
|
|
88
88
|
percent: string,
|
|
89
|
-
total: number
|
|
89
|
+
total: number,
|
|
90
90
|
}): string
|
|
91
91
|
}
|
|
92
92
|
// 是否显示中心标签数据
|
|
93
93
|
showCenterLabelData?: boolean
|
|
94
|
+
// 标签数据保留位数,缺省值:2
|
|
95
|
+
labelDataFractionDigits?: number
|
|
94
96
|
/**
|
|
95
97
|
* 标签数据格式化
|
|
96
98
|
* @example
|
|
97
|
-
* {
|
|
99
|
+
* {unit}{total}{name}
|
|
98
100
|
*/
|
|
99
|
-
labelFormatter?: string | { (params: { name: string, unit: string, total: number }): string }
|
|
101
|
+
labelFormatter?: string | { (params: { name: string, unit: string, total: number, value: number, e: any }): string }
|
|
100
102
|
option?: EcOptionBasicOption
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -7,7 +7,7 @@ var resizeObserver = new ResizeObserver(ObjectUtil.debounce((entries) => {
|
|
|
7
7
|
const dom = entries[i].target;
|
|
8
8
|
const raw = resizePool.get(dom);
|
|
9
9
|
const { width, height } = dom.getBoundingClientRect();
|
|
10
|
-
if (raw.size.width
|
|
10
|
+
if (raw.size.width && raw.size.height && width && height) {
|
|
11
11
|
let duration = 500;
|
|
12
12
|
if (dom.dataset.resizeInit === "true") {
|
|
13
13
|
dom.dataset.resizeInit = "false";
|
|
@@ -18,6 +18,8 @@ var resizeObserver = new ResizeObserver(ObjectUtil.debounce((entries) => {
|
|
|
18
18
|
easing: "cubicOut"
|
|
19
19
|
} });
|
|
20
20
|
}
|
|
21
|
+
raw.size.width = width;
|
|
22
|
+
raw.size.height = height;
|
|
21
23
|
}
|
|
22
24
|
}, 50));
|
|
23
25
|
var EChartsUtil = {
|