evui 3.3.36 → 3.3.39
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/LICENSE +21 -21
- package/README.md +40 -40
- package/dist/evui.common.js +1907 -1832
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +1907 -1832
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/dist/img/{EVUI.7f3588fb.svg → EVUI.b82ee81a.svg} +292 -292
- package/dist/img/{icon_mysql.7ea26d5d.svg → icon_mysql.1085fdc9.svg} +78 -78
- package/dist/img/{icon_oracle.9009b108.svg → icon_oracle.0572d3ee.svg} +13 -13
- package/dist/img/{icon_postgresql.f8fffba9.svg → icon_postgresql.ee12bde8.svg} +58 -58
- package/package.json +61 -61
- package/src/common/emitter.js +20 -20
- package/src/common/utils.debounce.js +223 -223
- package/src/common/utils.js +134 -134
- package/src/common/utils.table.js +78 -78
- package/src/common/utils.throttle.js +83 -83
- package/src/common/utils.tree.js +18 -18
- package/src/components/button/Button.vue +198 -198
- package/src/components/button/index.js +7 -7
- package/src/components/buttonGroup/ButtonGroup.vue +11 -11
- package/src/components/buttonGroup/index.js +7 -7
- package/src/components/calendar/Calendar.vue +661 -661
- package/src/components/calendar/index.js +7 -7
- package/src/components/calendar/uses.js +1272 -1272
- package/src/components/chart/Chart.vue +189 -192
- package/src/components/chart/chart.core.js +870 -870
- package/src/components/chart/element/element.bar.js +524 -524
- package/src/components/chart/element/element.bar.time.js +156 -156
- package/src/components/chart/element/element.heatmap.js +533 -533
- package/src/components/chart/element/element.line.js +339 -339
- package/src/components/chart/element/element.pie.js +197 -197
- package/src/components/chart/element/element.scatter.js +184 -184
- package/src/components/chart/element/element.tip.js +550 -542
- package/src/components/chart/helpers/helpers.canvas.js +265 -265
- package/src/components/chart/helpers/helpers.constant.js +206 -206
- package/src/components/chart/helpers/helpers.util.js +346 -338
- package/src/components/chart/index.js +9 -9
- package/src/components/chart/model/index.js +4 -4
- package/src/components/chart/model/model.series.js +93 -93
- package/src/components/chart/model/model.store.js +977 -967
- package/src/components/chart/plugins/plugins.interaction.js +769 -769
- package/src/components/chart/plugins/plugins.legend.gradient.js +602 -602
- package/src/components/chart/plugins/plugins.legend.js +1155 -1151
- package/src/components/chart/plugins/plugins.pie.js +254 -254
- package/src/components/chart/plugins/plugins.title.js +56 -56
- package/src/components/chart/plugins/plugins.tooltip.js +692 -692
- package/src/components/chart/scale/scale.js +848 -848
- package/src/components/chart/scale/scale.linear.js +38 -38
- package/src/components/chart/scale/scale.logarithmic.js +128 -128
- package/src/components/chart/scale/scale.step.js +336 -336
- package/src/components/chart/scale/scale.time.category.js +277 -277
- package/src/components/chart/scale/scale.time.js +48 -48
- package/src/components/chart/style/chart.scss +312 -312
- package/src/components/chart/uses.js +264 -252
- package/src/components/checkbox/Checkbox.vue +200 -200
- package/src/components/checkbox/index.js +7 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +44 -44
- package/src/components/checkboxGroup/index.js +7 -7
- package/src/components/contextMenu/ContextMenu.vue +80 -80
- package/src/components/contextMenu/MenuList.vue +149 -149
- package/src/components/contextMenu/index.js +7 -7
- package/src/components/contextMenu/uses.js +203 -203
- package/src/components/datePicker/DatePicker.vue +437 -437
- package/src/components/datePicker/index.js +7 -7
- package/src/components/datePicker/uses.js +419 -419
- package/src/components/grid/Grid.vue +827 -827
- package/src/components/grid/grid.filter.window.vue +493 -493
- package/src/components/grid/grid.pagination.vue +75 -75
- package/src/components/grid/grid.summary.vue +265 -265
- package/src/components/grid/grid.toolbar.vue +26 -26
- package/src/components/grid/index.js +11 -11
- package/src/components/grid/style/grid.scss +263 -263
- package/src/components/grid/uses.js +1002 -1007
- package/src/components/icon/Icon.vue +49 -49
- package/src/components/icon/index.js +8 -8
- package/src/components/inputNumber/InputNumber.vue +212 -212
- package/src/components/inputNumber/index.js +7 -7
- package/src/components/inputNumber/uses.js +217 -217
- package/src/components/loading/Loading.vue +125 -125
- package/src/components/loading/index.js +7 -7
- package/src/components/menu/Menu.vue +68 -68
- package/src/components/menu/MenuItem.vue +187 -187
- package/src/components/menu/index.js +7 -7
- package/src/components/message/Message.vue +223 -223
- package/src/components/message/index.js +31 -31
- package/src/components/messageBox/MessageBox.vue +358 -358
- package/src/components/messageBox/index.js +22 -22
- package/src/components/notification/Notification.vue +316 -316
- package/src/components/notification/index.js +49 -49
- package/src/components/pagination/Pagination.vue +271 -271
- package/src/components/pagination/index.js +7 -7
- package/src/components/pagination/pageButton.vue +30 -30
- package/src/components/progress/Progress.vue +139 -139
- package/src/components/progress/index.js +7 -7
- package/src/components/radio/Radio.vue +159 -159
- package/src/components/radio/index.js +7 -7
- package/src/components/radioGroup/RadioGroup.vue +41 -41
- package/src/components/radioGroup/index.js +7 -7
- package/src/components/scheduler/Scheduler.vue +149 -149
- package/src/components/scheduler/index.js +7 -7
- package/src/components/scheduler/uses.js +183 -183
- package/src/components/select/Select.vue +440 -440
- package/src/components/select/index.js +7 -7
- package/src/components/select/uses.js +270 -270
- package/src/components/slider/Slider.vue +505 -505
- package/src/components/slider/index.js +7 -7
- package/src/components/slider/uses.js +390 -390
- package/src/components/tabPanel/TabPanel.vue +74 -74
- package/src/components/tabPanel/index.js +7 -7
- package/src/components/tabs/Tabs.vue +517 -517
- package/src/components/tabs/index.js +7 -7
- package/src/components/textField/TextField.vue +375 -375
- package/src/components/textField/index.js +7 -7
- package/src/components/timePicker/TimePicker.vue +352 -352
- package/src/components/timePicker/index.js +7 -7
- package/src/components/toggle/Toggle.vue +115 -115
- package/src/components/toggle/index.js +7 -7
- package/src/components/tree/Tree.vue +313 -313
- package/src/components/tree/TreeNode.vue +293 -293
- package/src/components/tree/index.js +7 -7
- package/src/components/treeGrid/TreeGrid.vue +758 -758
- package/src/components/treeGrid/TreeGridNode.vue +275 -275
- package/src/components/treeGrid/index.js +9 -9
- package/src/components/treeGrid/style/treeGrid.scss +261 -261
- package/src/components/treeGrid/treeGrid.toolbar.vue +26 -26
- package/src/components/treeGrid/uses.js +867 -867
- package/src/components/window/Window.vue +329 -329
- package/src/components/window/index.js +7 -7
- package/src/components/window/uses.js +899 -899
- package/src/directives/clickoutside.js +90 -90
- package/src/main.js +116 -116
- package/src/style/components/input.scss +108 -108
- package/src/style/functions.scss +3 -3
- package/src/style/index.scss +6 -6
- package/src/style/lib/fonts/EVUI.svg +292 -292
- package/src/style/lib/icon.css +888 -888
- package/src/style/mixins.scss +94 -94
- package/src/style/themes.scss +67 -67
- package/src/style/variables.scss +22 -22
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
import { merge } from 'lodash-es';
|
|
2
|
-
import { PIE_OPTION, COLOR } from '../helpers/helpers.constant';
|
|
3
|
-
import Util from '../helpers/helpers.util';
|
|
4
|
-
|
|
5
|
-
class Pie {
|
|
6
|
-
constructor(sId, opt, sIdx) {
|
|
7
|
-
const merged = merge({}, PIE_OPTION, opt);
|
|
8
|
-
Object.keys(merged).forEach((key) => {
|
|
9
|
-
this[key] = merged[key];
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
if (this.name === undefined) {
|
|
13
|
-
this.name = `series-${sIdx}`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (this.color === undefined) {
|
|
17
|
-
this.color = COLOR[sIdx];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
this.sId = sId;
|
|
21
|
-
this.show = true;
|
|
22
|
-
this.data = [];
|
|
23
|
-
this.type = 'pie';
|
|
24
|
-
this.centerX = 0;
|
|
25
|
-
this.centerY = 0;
|
|
26
|
-
this.radius = 0;
|
|
27
|
-
this.doughnutHoleSize = 0;
|
|
28
|
-
this.startAngle = 0;
|
|
29
|
-
this.endAngle = 0;
|
|
30
|
-
this.ctx = null;
|
|
31
|
-
this.isSelect = false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Draw series data
|
|
36
|
-
* @param context
|
|
37
|
-
* @param strokeOptions
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @returns {undefined}
|
|
41
|
-
*/
|
|
42
|
-
draw(context, strokeOptions) {
|
|
43
|
-
const ctx = context ?? this.ctx;
|
|
44
|
-
const slice = new Path2D();
|
|
45
|
-
|
|
46
|
-
const radius = this.isSelect ? this.radius + 5 : this.radius;
|
|
47
|
-
|
|
48
|
-
const color = this.color;
|
|
49
|
-
const noneDownplayOpacity = color.includes('rgba') ? Util.getOpacity(color) : 1;
|
|
50
|
-
const opacity = this.isDownplay ? 0.1 : noneDownplayOpacity;
|
|
51
|
-
|
|
52
|
-
ctx.beginPath();
|
|
53
|
-
slice.moveTo(this.centerX, this.centerY);
|
|
54
|
-
slice.arc(this.centerX, this.centerY, radius, this.startAngle, this.endAngle);
|
|
55
|
-
slice.lineTo(this.centerX, this.centerY);
|
|
56
|
-
ctx.fillStyle = Util.colorStringToRgba(color, opacity);
|
|
57
|
-
ctx.fill(slice);
|
|
58
|
-
|
|
59
|
-
if (strokeOptions.use) {
|
|
60
|
-
ctx.lineCap = 'round';
|
|
61
|
-
ctx.lineWidth = strokeOptions?.lineWidth;
|
|
62
|
-
ctx.strokeStyle = strokeOptions?.color;
|
|
63
|
-
ctx.stroke(slice);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (this.showValue?.use) {
|
|
67
|
-
this.drawValueLabels(ctx);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
ctx.closePath();
|
|
71
|
-
this.ctx = ctx;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Find graph item
|
|
76
|
-
* @param {array} offset mouse position
|
|
77
|
-
*
|
|
78
|
-
* @returns {object} graph item
|
|
79
|
-
*/
|
|
80
|
-
findGraphData([offsetX, offsetY]) {
|
|
81
|
-
const item = { data: null, hit: false, color: null, index: -1 };
|
|
82
|
-
const {
|
|
83
|
-
radius,
|
|
84
|
-
startAngle,
|
|
85
|
-
endAngle,
|
|
86
|
-
centerX,
|
|
87
|
-
centerY,
|
|
88
|
-
} = this;
|
|
89
|
-
|
|
90
|
-
const distance = Math.sqrt((offsetX - centerX) ** 2 + (offsetY - centerY) ** 2);
|
|
91
|
-
const radian = (2.5 * Math.PI) - Math.atan2((offsetX - centerX), (offsetY - centerY));
|
|
92
|
-
const isPointInPath = radius > distance && radian >= startAngle && radian <= endAngle;
|
|
93
|
-
|
|
94
|
-
if (this.show && isPointInPath) {
|
|
95
|
-
item.type = this.type;
|
|
96
|
-
item.data = this.data;
|
|
97
|
-
item.hit = true;
|
|
98
|
-
item.color = this.color;
|
|
99
|
-
item.index = 0;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return item;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Draw item highlight
|
|
107
|
-
*
|
|
108
|
-
* @param item {object} object for drawing series data
|
|
109
|
-
* @param context {CanvasRenderingContext2D} canvas context
|
|
110
|
-
*
|
|
111
|
-
* @returns {undefined}
|
|
112
|
-
*/
|
|
113
|
-
itemHighlight(item, context) {
|
|
114
|
-
const ctx = context;
|
|
115
|
-
const radius = this.isSelect ? this.radius + 5 : this.radius;
|
|
116
|
-
|
|
117
|
-
ctx.save();
|
|
118
|
-
ctx.shadowOffsetX = 0;
|
|
119
|
-
ctx.shadowOffsetY = 0;
|
|
120
|
-
ctx.shadowBlur = 4;
|
|
121
|
-
|
|
122
|
-
const color = item?.data?.dataColor || this.color;
|
|
123
|
-
ctx.fillStyle = color;
|
|
124
|
-
ctx.shadowColor = color;
|
|
125
|
-
|
|
126
|
-
ctx.beginPath();
|
|
127
|
-
ctx.moveTo(this.centerX, this.centerY);
|
|
128
|
-
ctx.arc(this.centerX, this.centerY, radius, this.startAngle, this.endAngle);
|
|
129
|
-
ctx.lineTo(this.centerX, this.centerY);
|
|
130
|
-
ctx.fill();
|
|
131
|
-
|
|
132
|
-
if (this.showValue?.use) {
|
|
133
|
-
this.drawValueLabels(ctx);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
ctx.closePath();
|
|
137
|
-
ctx.restore();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Draw value label if series 'use' of showValue option is true
|
|
142
|
-
*
|
|
143
|
-
* @param context canvas context
|
|
144
|
-
*/
|
|
145
|
-
drawValueLabels(context) {
|
|
146
|
-
const ctx = context;
|
|
147
|
-
const value = this.data.o;
|
|
148
|
-
const { fontSize, textColor, formatter } = this.showValue;
|
|
149
|
-
|
|
150
|
-
let formattedTxt;
|
|
151
|
-
if (formatter) {
|
|
152
|
-
formattedTxt = formatter({
|
|
153
|
-
value,
|
|
154
|
-
percentage: this.data.percentage,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!formatter || typeof formattedTxt !== 'string') {
|
|
159
|
-
formattedTxt = Util.labelSignFormat(value);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const ratio = 1.8;
|
|
163
|
-
const radius = this.radius - this.doughnutHoleSize;
|
|
164
|
-
const innerAngle = ((this.endAngle - this.startAngle) * 180) / Math.PI;
|
|
165
|
-
const valueHeight = fontSize + 4;
|
|
166
|
-
const valueWidth = Math.round(ctx.measureText(formattedTxt).width);
|
|
167
|
-
|
|
168
|
-
if (innerAngle >= valueWidth * ratio
|
|
169
|
-
&& innerAngle >= valueHeight * ratio
|
|
170
|
-
&& radius >= valueWidth * ratio
|
|
171
|
-
&& radius >= valueHeight * ratio
|
|
172
|
-
) {
|
|
173
|
-
ctx.save();
|
|
174
|
-
ctx.beginPath();
|
|
175
|
-
|
|
176
|
-
const noneDownplayOpacity = textColor.includes('rgba') ? Util.getOpacity(textColor) : 1;
|
|
177
|
-
const opacity = this.state === 'downplay' ? 0.1 : noneDownplayOpacity;
|
|
178
|
-
|
|
179
|
-
ctx.font = `normal normal normal ${fontSize}px Roboto`;
|
|
180
|
-
ctx.fillStyle = Util.colorStringToRgba(textColor, opacity);
|
|
181
|
-
ctx.lineWidth = 1;
|
|
182
|
-
ctx.textAlign = 'center';
|
|
183
|
-
ctx.textBaseline = 'middle';
|
|
184
|
-
|
|
185
|
-
const halfRadius = (radius / 2) + this.doughnutHoleSize;
|
|
186
|
-
const centerAngle = ((this.endAngle - this.startAngle) / 2) + this.startAngle;
|
|
187
|
-
const xPos = halfRadius * Math.cos(centerAngle) + this.centerX;
|
|
188
|
-
const yPos = halfRadius * Math.sin(centerAngle) + this.centerY;
|
|
189
|
-
|
|
190
|
-
ctx.fillText(formattedTxt, xPos, yPos);
|
|
191
|
-
|
|
192
|
-
ctx.restore();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export default Pie;
|
|
1
|
+
import { merge } from 'lodash-es';
|
|
2
|
+
import { PIE_OPTION, COLOR } from '../helpers/helpers.constant';
|
|
3
|
+
import Util from '../helpers/helpers.util';
|
|
4
|
+
|
|
5
|
+
class Pie {
|
|
6
|
+
constructor(sId, opt, sIdx) {
|
|
7
|
+
const merged = merge({}, PIE_OPTION, opt);
|
|
8
|
+
Object.keys(merged).forEach((key) => {
|
|
9
|
+
this[key] = merged[key];
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
if (this.name === undefined) {
|
|
13
|
+
this.name = `series-${sIdx}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (this.color === undefined) {
|
|
17
|
+
this.color = COLOR[sIdx];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.sId = sId;
|
|
21
|
+
this.show = true;
|
|
22
|
+
this.data = [];
|
|
23
|
+
this.type = 'pie';
|
|
24
|
+
this.centerX = 0;
|
|
25
|
+
this.centerY = 0;
|
|
26
|
+
this.radius = 0;
|
|
27
|
+
this.doughnutHoleSize = 0;
|
|
28
|
+
this.startAngle = 0;
|
|
29
|
+
this.endAngle = 0;
|
|
30
|
+
this.ctx = null;
|
|
31
|
+
this.isSelect = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Draw series data
|
|
36
|
+
* @param context
|
|
37
|
+
* @param strokeOptions
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* @returns {undefined}
|
|
41
|
+
*/
|
|
42
|
+
draw(context, strokeOptions) {
|
|
43
|
+
const ctx = context ?? this.ctx;
|
|
44
|
+
const slice = new Path2D();
|
|
45
|
+
|
|
46
|
+
const radius = this.isSelect ? this.radius + 5 : this.radius;
|
|
47
|
+
|
|
48
|
+
const color = this.color;
|
|
49
|
+
const noneDownplayOpacity = color.includes('rgba') ? Util.getOpacity(color) : 1;
|
|
50
|
+
const opacity = this.isDownplay ? 0.1 : noneDownplayOpacity;
|
|
51
|
+
|
|
52
|
+
ctx.beginPath();
|
|
53
|
+
slice.moveTo(this.centerX, this.centerY);
|
|
54
|
+
slice.arc(this.centerX, this.centerY, radius, this.startAngle, this.endAngle);
|
|
55
|
+
slice.lineTo(this.centerX, this.centerY);
|
|
56
|
+
ctx.fillStyle = Util.colorStringToRgba(color, opacity);
|
|
57
|
+
ctx.fill(slice);
|
|
58
|
+
|
|
59
|
+
if (strokeOptions.use) {
|
|
60
|
+
ctx.lineCap = 'round';
|
|
61
|
+
ctx.lineWidth = strokeOptions?.lineWidth;
|
|
62
|
+
ctx.strokeStyle = strokeOptions?.color;
|
|
63
|
+
ctx.stroke(slice);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.showValue?.use) {
|
|
67
|
+
this.drawValueLabels(ctx);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ctx.closePath();
|
|
71
|
+
this.ctx = ctx;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Find graph item
|
|
76
|
+
* @param {array} offset mouse position
|
|
77
|
+
*
|
|
78
|
+
* @returns {object} graph item
|
|
79
|
+
*/
|
|
80
|
+
findGraphData([offsetX, offsetY]) {
|
|
81
|
+
const item = { data: null, hit: false, color: null, index: -1 };
|
|
82
|
+
const {
|
|
83
|
+
radius,
|
|
84
|
+
startAngle,
|
|
85
|
+
endAngle,
|
|
86
|
+
centerX,
|
|
87
|
+
centerY,
|
|
88
|
+
} = this;
|
|
89
|
+
|
|
90
|
+
const distance = Math.sqrt((offsetX - centerX) ** 2 + (offsetY - centerY) ** 2);
|
|
91
|
+
const radian = (2.5 * Math.PI) - Math.atan2((offsetX - centerX), (offsetY - centerY));
|
|
92
|
+
const isPointInPath = radius > distance && radian >= startAngle && radian <= endAngle;
|
|
93
|
+
|
|
94
|
+
if (this.show && isPointInPath) {
|
|
95
|
+
item.type = this.type;
|
|
96
|
+
item.data = this.data;
|
|
97
|
+
item.hit = true;
|
|
98
|
+
item.color = this.color;
|
|
99
|
+
item.index = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return item;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Draw item highlight
|
|
107
|
+
*
|
|
108
|
+
* @param item {object} object for drawing series data
|
|
109
|
+
* @param context {CanvasRenderingContext2D} canvas context
|
|
110
|
+
*
|
|
111
|
+
* @returns {undefined}
|
|
112
|
+
*/
|
|
113
|
+
itemHighlight(item, context) {
|
|
114
|
+
const ctx = context;
|
|
115
|
+
const radius = this.isSelect ? this.radius + 5 : this.radius;
|
|
116
|
+
|
|
117
|
+
ctx.save();
|
|
118
|
+
ctx.shadowOffsetX = 0;
|
|
119
|
+
ctx.shadowOffsetY = 0;
|
|
120
|
+
ctx.shadowBlur = 4;
|
|
121
|
+
|
|
122
|
+
const color = item?.data?.dataColor || this.color;
|
|
123
|
+
ctx.fillStyle = color;
|
|
124
|
+
ctx.shadowColor = color;
|
|
125
|
+
|
|
126
|
+
ctx.beginPath();
|
|
127
|
+
ctx.moveTo(this.centerX, this.centerY);
|
|
128
|
+
ctx.arc(this.centerX, this.centerY, radius, this.startAngle, this.endAngle);
|
|
129
|
+
ctx.lineTo(this.centerX, this.centerY);
|
|
130
|
+
ctx.fill();
|
|
131
|
+
|
|
132
|
+
if (this.showValue?.use) {
|
|
133
|
+
this.drawValueLabels(ctx);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
ctx.closePath();
|
|
137
|
+
ctx.restore();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Draw value label if series 'use' of showValue option is true
|
|
142
|
+
*
|
|
143
|
+
* @param context canvas context
|
|
144
|
+
*/
|
|
145
|
+
drawValueLabels(context) {
|
|
146
|
+
const ctx = context;
|
|
147
|
+
const value = this.data.o;
|
|
148
|
+
const { fontSize, textColor, formatter } = this.showValue;
|
|
149
|
+
|
|
150
|
+
let formattedTxt;
|
|
151
|
+
if (formatter) {
|
|
152
|
+
formattedTxt = formatter({
|
|
153
|
+
value,
|
|
154
|
+
percentage: this.data.percentage,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!formatter || typeof formattedTxt !== 'string') {
|
|
159
|
+
formattedTxt = Util.labelSignFormat(value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const ratio = 1.8;
|
|
163
|
+
const radius = this.radius - this.doughnutHoleSize;
|
|
164
|
+
const innerAngle = ((this.endAngle - this.startAngle) * 180) / Math.PI;
|
|
165
|
+
const valueHeight = fontSize + 4;
|
|
166
|
+
const valueWidth = Math.round(ctx.measureText(formattedTxt).width);
|
|
167
|
+
|
|
168
|
+
if (innerAngle >= valueWidth * ratio
|
|
169
|
+
&& innerAngle >= valueHeight * ratio
|
|
170
|
+
&& radius >= valueWidth * ratio
|
|
171
|
+
&& radius >= valueHeight * ratio
|
|
172
|
+
) {
|
|
173
|
+
ctx.save();
|
|
174
|
+
ctx.beginPath();
|
|
175
|
+
|
|
176
|
+
const noneDownplayOpacity = textColor.includes('rgba') ? Util.getOpacity(textColor) : 1;
|
|
177
|
+
const opacity = this.state === 'downplay' ? 0.1 : noneDownplayOpacity;
|
|
178
|
+
|
|
179
|
+
ctx.font = `normal normal normal ${fontSize}px Roboto`;
|
|
180
|
+
ctx.fillStyle = Util.colorStringToRgba(textColor, opacity);
|
|
181
|
+
ctx.lineWidth = 1;
|
|
182
|
+
ctx.textAlign = 'center';
|
|
183
|
+
ctx.textBaseline = 'middle';
|
|
184
|
+
|
|
185
|
+
const halfRadius = (radius / 2) + this.doughnutHoleSize;
|
|
186
|
+
const centerAngle = ((this.endAngle - this.startAngle) / 2) + this.startAngle;
|
|
187
|
+
const xPos = halfRadius * Math.cos(centerAngle) + this.centerX;
|
|
188
|
+
const yPos = halfRadius * Math.sin(centerAngle) + this.centerY;
|
|
189
|
+
|
|
190
|
+
ctx.fillText(formattedTxt, xPos, yPos);
|
|
191
|
+
|
|
192
|
+
ctx.restore();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default Pie;
|