evui 3.4.206 → 3.4.208
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/README.md +18 -33
- package/dist/404.html +44 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.js +22645 -0
- package/dist/index.umd.cjs +28 -0
- package/dist/style.css +1 -0
- package/package.json +46 -43
- package/dist/evui.common.js +0 -63678
- package/dist/evui.common.js.map +0 -1
- package/dist/evui.umd.js +0 -63688
- package/dist/evui.umd.js.map +0 -1
- package/dist/evui.umd.min.js +0 -2
- package/dist/evui.umd.min.js.map +0 -1
- package/dist/img/EVUI.b82ee81a.svg +0 -293
- package/src/assets/logo.png +0 -0
- package/src/common/emitter.js +0 -20
- package/src/common/utils.bignumber.js +0 -67
- package/src/common/utils.debounce.js +0 -223
- package/src/common/utils.js +0 -151
- package/src/common/utils.table.js +0 -78
- package/src/common/utils.throttle.js +0 -83
- package/src/common/utils.tree.js +0 -18
- package/src/components/button/Button.vue +0 -195
- package/src/components/button/index.js +0 -7
- package/src/components/buttonGroup/ButtonGroup.vue +0 -11
- package/src/components/buttonGroup/index.js +0 -7
- package/src/components/calendar/Calendar.vue +0 -725
- package/src/components/calendar/index.js +0 -7
- package/src/components/calendar/uses.js +0 -1410
- package/src/components/chart/Chart.vue +0 -363
- package/src/components/chart/ChartToolbar.vue +0 -52
- package/src/components/chart/chart.core.js +0 -1170
- package/src/components/chart/chartZoom.core.js +0 -540
- package/src/components/chart/element/element.bar.js +0 -672
- package/src/components/chart/element/element.bar.time.js +0 -166
- package/src/components/chart/element/element.heatmap.js +0 -743
- package/src/components/chart/element/element.line.js +0 -611
- package/src/components/chart/element/element.pie.js +0 -197
- package/src/components/chart/element/element.scatter.js +0 -320
- package/src/components/chart/element/element.tip.js +0 -717
- package/src/components/chart/helpers/helpers.canvas.js +0 -265
- package/src/components/chart/helpers/helpers.constant.js +0 -235
- package/src/components/chart/helpers/helpers.util.js +0 -400
- package/src/components/chart/index.js +0 -9
- package/src/components/chart/model/index.js +0 -50
- package/src/components/chart/model/model.series.js +0 -125
- package/src/components/chart/model/model.store.js +0 -1427
- package/src/components/chart/plugins/plugins.interaction.js +0 -1655
- package/src/components/chart/plugins/plugins.legend.gradient.js +0 -606
- package/src/components/chart/plugins/plugins.legend.js +0 -1543
- package/src/components/chart/plugins/plugins.pie.js +0 -254
- package/src/components/chart/plugins/plugins.scrollbar.js +0 -732
- package/src/components/chart/plugins/plugins.title.js +0 -61
- package/src/components/chart/plugins/plugins.tooltip.js +0 -1041
- package/src/components/chart/scale/scale.js +0 -951
- package/src/components/chart/scale/scale.linear.js +0 -268
- package/src/components/chart/scale/scale.logarithmic.js +0 -135
- package/src/components/chart/scale/scale.step.js +0 -430
- package/src/components/chart/scale/scale.time.category.js +0 -338
- package/src/components/chart/scale/scale.time.js +0 -49
- package/src/components/chart/style/chart.scss +0 -405
- package/src/components/chart/uses.js +0 -721
- package/src/components/chartBrush/ChartBrush.vue +0 -323
- package/src/components/chartBrush/chartBrush.core.js +0 -691
- package/src/components/chartBrush/index.js +0 -9
- package/src/components/chartBrush/uses.js +0 -23
- package/src/components/chartGroup/ChartGroup.vue +0 -144
- package/src/components/chartGroup/index.js +0 -9
- package/src/components/chartGroup/style/chartGroup.scss +0 -5
- package/src/components/chartGroup/uses.js +0 -53
- package/src/components/checkbox/Checkbox.vue +0 -229
- package/src/components/checkbox/index.js +0 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +0 -44
- package/src/components/checkboxGroup/index.js +0 -7
- package/src/components/contextMenu/ContextMenu.vue +0 -95
- package/src/components/contextMenu/MenuList.vue +0 -182
- package/src/components/contextMenu/index.js +0 -7
- package/src/components/contextMenu/uses.js +0 -223
- package/src/components/datePicker/DatePicker.vue +0 -504
- package/src/components/datePicker/index.js +0 -7
- package/src/components/datePicker/uses.js +0 -460
- package/src/components/grid/Grid.vue +0 -1535
- package/src/components/grid/GridColumnSetting.vue +0 -358
- package/src/components/grid/GridFilterSetting.vue +0 -323
- package/src/components/grid/GridPagination.vue +0 -75
- package/src/components/grid/GridSummary.vue +0 -314
- package/src/components/grid/GridToolbar.vue +0 -35
- package/src/components/grid/icon/icon-option-button.vue +0 -17
- package/src/components/grid/icon/icon-sort-button.vue +0 -67
- package/src/components/grid/index.js +0 -11
- package/src/components/grid/style/grid.scss +0 -417
- package/src/components/grid/uses.js +0 -1629
- package/src/components/icon/Icon.vue +0 -53
- package/src/components/icon/index.js +0 -8
- package/src/components/inputNumber/InputNumber.vue +0 -212
- package/src/components/inputNumber/index.js +0 -7
- package/src/components/inputNumber/uses.js +0 -217
- package/src/components/loading/Loading.vue +0 -125
- package/src/components/loading/index.js +0 -7
- package/src/components/menu/Menu.vue +0 -79
- package/src/components/menu/MenuItem.vue +0 -201
- package/src/components/menu/index.js +0 -7
- package/src/components/message/Message.vue +0 -229
- package/src/components/message/index.js +0 -34
- package/src/components/messageBox/MessageBox.vue +0 -358
- package/src/components/messageBox/index.js +0 -22
- package/src/components/notification/Notification.vue +0 -316
- package/src/components/notification/index.js +0 -49
- package/src/components/pagination/Pagination.vue +0 -317
- package/src/components/pagination/index.js +0 -7
- package/src/components/pagination/pageButton.vue +0 -31
- package/src/components/progress/Progress.vue +0 -139
- package/src/components/progress/index.js +0 -7
- package/src/components/radio/Radio.vue +0 -159
- package/src/components/radio/index.js +0 -7
- package/src/components/radioGroup/RadioGroup.vue +0 -41
- package/src/components/radioGroup/index.js +0 -7
- package/src/components/scheduler/Scheduler.vue +0 -149
- package/src/components/scheduler/index.js +0 -7
- package/src/components/scheduler/uses.js +0 -183
- package/src/components/select/Select.vue +0 -556
- package/src/components/select/index.js +0 -7
- package/src/components/select/uses.js +0 -379
- package/src/components/slider/Slider.vue +0 -505
- package/src/components/slider/index.js +0 -7
- package/src/components/slider/uses.js +0 -391
- package/src/components/tabPanel/TabPanel.vue +0 -74
- package/src/components/tabPanel/index.js +0 -7
- package/src/components/tabs/Tabs.vue +0 -517
- package/src/components/tabs/index.js +0 -7
- package/src/components/textField/TextField.vue +0 -399
- package/src/components/textField/index.js +0 -7
- package/src/components/timePicker/TimePicker.vue +0 -364
- package/src/components/timePicker/index.js +0 -7
- package/src/components/toggle/Toggle.vue +0 -115
- package/src/components/toggle/index.js +0 -7
- package/src/components/tree/Tree.vue +0 -338
- package/src/components/tree/TreeNode.vue +0 -293
- package/src/components/tree/index.js +0 -7
- package/src/components/treeGrid/TreeGrid.vue +0 -1074
- package/src/components/treeGrid/TreeGridNode.vue +0 -349
- package/src/components/treeGrid/TreeGridToolbar.vue +0 -35
- package/src/components/treeGrid/icon/icon-tree.png +0 -0
- package/src/components/treeGrid/index.js +0 -9
- package/src/components/treeGrid/style/treeGrid.scss +0 -277
- package/src/components/treeGrid/uses.js +0 -1178
- package/src/components/window/Window.vue +0 -329
- package/src/components/window/index.js +0 -7
- package/src/components/window/uses.js +0 -908
- package/src/directives/clickoutside.js +0 -90
- package/src/main.js +0 -120
- package/src/style/components/input.scss +0 -108
- package/src/style/functions.scss +0 -3
- package/src/style/index.scss +0 -6
- package/src/style/lib/fonts/EVUI.eot +0 -0
- package/src/style/lib/fonts/EVUI.svg +0 -293
- package/src/style/lib/fonts/EVUI.ttf +0 -0
- package/src/style/lib/fonts/EVUI.woff +0 -0
- package/src/style/lib/icon.css +0 -888
- package/src/style/mixins.scss +0 -94
- package/src/style/themes.scss +0 -69
- package/src/style/variables.scss +0 -22
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { defaultsDeep } from 'lodash-es';
|
|
2
|
-
import { PLOT_BAND_OPTION, PLOT_LINE_OPTION } from '@/components/chart/helpers/helpers.constant';
|
|
3
|
-
import { bnMinus, bnPlus } from '@/common/utils.bignumber';
|
|
4
|
-
import { truthyNumber } from '@/common/utils';
|
|
5
|
-
import Scale from './scale';
|
|
6
|
-
import Util from '../helpers/helpers.util';
|
|
7
|
-
|
|
8
|
-
class StepScale extends Scale {
|
|
9
|
-
constructor(type, axisOpt, ctx, labels, options) {
|
|
10
|
-
super(type, axisOpt, ctx, options);
|
|
11
|
-
this.labels = labels;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Calculate min/max value, label and size information for step scale
|
|
16
|
-
* @param {object} minMax min/max information (unused on step scale)
|
|
17
|
-
* @param {object} scrollbarOpt scroll bar option
|
|
18
|
-
* @param {object} chartRect chart size information
|
|
19
|
-
*
|
|
20
|
-
* @returns {object} min/max value and label
|
|
21
|
-
*/
|
|
22
|
-
calculateScaleRange(minMax, scrollbarOpt, chartRect) {
|
|
23
|
-
const stepMinMax = this.labelStyle.alignToGridLine
|
|
24
|
-
? minMax : Util.getStringMinMax(this.labels);
|
|
25
|
-
let maxValue = stepMinMax.max;
|
|
26
|
-
let minValue = stepMinMax.min;
|
|
27
|
-
|
|
28
|
-
let minIndex = 0;
|
|
29
|
-
let maxIndex = this.labels.length - 1;
|
|
30
|
-
let labelCount = this.labels.length;
|
|
31
|
-
|
|
32
|
-
const range = scrollbarOpt?.use ? scrollbarOpt?.range : this.range;
|
|
33
|
-
if (Array.isArray(range) && range?.length) {
|
|
34
|
-
const [min, max] = range;
|
|
35
|
-
if (truthyNumber(min) && truthyNumber(max)) {
|
|
36
|
-
minIndex = min < minIndex ? minIndex : min;
|
|
37
|
-
maxIndex = max > maxIndex ? maxIndex : max;
|
|
38
|
-
maxValue = this.labels[maxIndex];
|
|
39
|
-
minValue = this.labels[minIndex];
|
|
40
|
-
labelCount = maxIndex - minIndex + 1;
|
|
41
|
-
}
|
|
42
|
-
} else if (typeof range === 'function') {
|
|
43
|
-
const [min, max] = range(minValue, maxValue);
|
|
44
|
-
minIndex = min < minIndex ? minIndex : min;
|
|
45
|
-
maxIndex = max > maxIndex ? maxIndex : max;
|
|
46
|
-
maxValue = this.labels[maxIndex];
|
|
47
|
-
minValue = this.labels[minIndex];
|
|
48
|
-
labelCount = maxIndex - minIndex + 1;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const maxWidth = this.labelStyle?.maxWidth ?? chartRect.chartWidth / (labelCount + 2);
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
min: minValue,
|
|
55
|
-
max: maxValue,
|
|
56
|
-
minIndex,
|
|
57
|
-
maxIndex,
|
|
58
|
-
minLabel: this.getLabelFormat(minValue, maxWidth),
|
|
59
|
-
maxLabel: this.getLabelFormat(maxValue, maxWidth),
|
|
60
|
-
size: Util.calcTextSize(
|
|
61
|
-
this.getLabelFormat(maxValue, maxWidth),
|
|
62
|
-
Util.getLabelStyle(this.labelStyle),
|
|
63
|
-
),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
getIndexInterval(range) {
|
|
68
|
-
const step = range.maxSteps;
|
|
69
|
-
|
|
70
|
-
if (this.interval) {
|
|
71
|
-
return this.interval;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return Math.ceil(this.labels.length / step);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* With range information, calculate how many labels in axis
|
|
79
|
-
* @param {object} range min/max information
|
|
80
|
-
*
|
|
81
|
-
* @returns {object} steps, interval, min/max graph value
|
|
82
|
-
*/
|
|
83
|
-
calculateSteps(range) {
|
|
84
|
-
const {
|
|
85
|
-
minValue,
|
|
86
|
-
maxValue,
|
|
87
|
-
minIndex,
|
|
88
|
-
maxIndex,
|
|
89
|
-
} = range;
|
|
90
|
-
|
|
91
|
-
const oriSteps = (maxIndex - minIndex) + 1;
|
|
92
|
-
let indexInterval = 1;
|
|
93
|
-
|
|
94
|
-
const isNumbersArray = this.labels.every(label => !isNaN(label));
|
|
95
|
-
if (this.labelStyle.alignToGridLine && isNumbersArray) {
|
|
96
|
-
indexInterval = this.getIndexInterval(range);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
oriSteps,
|
|
101
|
-
steps: oriSteps,
|
|
102
|
-
indexInterval,
|
|
103
|
-
graphMin: minValue,
|
|
104
|
-
graphMax: maxValue,
|
|
105
|
-
minIndex,
|
|
106
|
-
maxIndex,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Draw axis
|
|
112
|
-
* @param {object} chartRect min/max information
|
|
113
|
-
* @param {object} labelOffset label offset information
|
|
114
|
-
* @param {object} stepInfo label steps information
|
|
115
|
-
* @param {object} hitInfo legend Hit Info
|
|
116
|
-
* @param {object} selectedLabelInfo Selected Label Info
|
|
117
|
-
*
|
|
118
|
-
* @returns {undefined}
|
|
119
|
-
*/
|
|
120
|
-
draw(chartRect, labelOffset, stepInfo, hitInfo, selectedLabelInfo) {
|
|
121
|
-
const ctx = this.ctx;
|
|
122
|
-
const labels = this.labels;
|
|
123
|
-
const aPos = {
|
|
124
|
-
x1: chartRect.x1 + labelOffset.left,
|
|
125
|
-
x2: chartRect.x2 - labelOffset.right,
|
|
126
|
-
y1: chartRect.y1 + labelOffset.top,
|
|
127
|
-
y2: chartRect.y2 - labelOffset.bottom,
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const steps = stepInfo.steps;
|
|
131
|
-
const indexInterval = stepInfo.indexInterval;
|
|
132
|
-
const startIndex = stepInfo.minIndex;
|
|
133
|
-
|
|
134
|
-
const startPoint = aPos[this.units.rectStart];
|
|
135
|
-
const endPoint = aPos[this.units.rectEnd];
|
|
136
|
-
const offsetPoint = aPos[this.units.rectOffset(this.position)];
|
|
137
|
-
const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
|
|
138
|
-
const maxWidth = this.labelStyle?.maxWidth ?? chartRect.chartWidth / (steps + 2);
|
|
139
|
-
|
|
140
|
-
const AXIS_TICK_LENGTH = 5;
|
|
141
|
-
|
|
142
|
-
this.drawAxisTitle(chartRect, labelOffset);
|
|
143
|
-
|
|
144
|
-
if (this.labelStyle?.show) {
|
|
145
|
-
// label font 설정
|
|
146
|
-
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
147
|
-
|
|
148
|
-
if (this.type === 'x') {
|
|
149
|
-
ctx.textAlign = 'center';
|
|
150
|
-
ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
|
|
151
|
-
} else {
|
|
152
|
-
ctx.textAlign = this.position === 'left' ? 'right' : 'left';
|
|
153
|
-
ctx.textBaseline = 'middle';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
ctx.fillStyle = this.labelStyle.color;
|
|
157
|
-
ctx.lineWidth = this.axisLineWidth;
|
|
158
|
-
const aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
159
|
-
|
|
160
|
-
ctx.beginPath();
|
|
161
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
162
|
-
if (this.type === 'x') {
|
|
163
|
-
ctx.moveTo(startPoint, offsetPoint + aliasPixel);
|
|
164
|
-
ctx.lineTo(endPoint, offsetPoint + aliasPixel);
|
|
165
|
-
} else {
|
|
166
|
-
ctx.moveTo(offsetPoint + aliasPixel, startPoint);
|
|
167
|
-
ctx.lineTo(offsetPoint + aliasPixel, endPoint);
|
|
168
|
-
}
|
|
169
|
-
ctx.stroke();
|
|
170
|
-
|
|
171
|
-
if (steps === 0) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const labelGap = (endPoint - startPoint) / steps;
|
|
176
|
-
const alignToGridLine = this.labelStyle.alignToGridLine;
|
|
177
|
-
let labelCenter = null;
|
|
178
|
-
let linePosition = null;
|
|
179
|
-
|
|
180
|
-
ctx.beginPath();
|
|
181
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
182
|
-
|
|
183
|
-
let labelText;
|
|
184
|
-
let labelPoint;
|
|
185
|
-
let index;
|
|
186
|
-
const drawnLabels = [];
|
|
187
|
-
|
|
188
|
-
for (index = 0; index < steps; index += indexInterval) {
|
|
189
|
-
const labelIndex = startIndex + index;
|
|
190
|
-
const item = this.labels[labelIndex];
|
|
191
|
-
labelCenter = Math.round(startPoint + (labelGap * index));
|
|
192
|
-
linePosition = labelCenter + aliasPixel;
|
|
193
|
-
labelText = this.getLabelFormat(item, maxWidth);
|
|
194
|
-
|
|
195
|
-
const {
|
|
196
|
-
selectLabel: selectLabelOpt,
|
|
197
|
-
selectItem: selectItemOpt,
|
|
198
|
-
horizontal,
|
|
199
|
-
} = this.options;
|
|
200
|
-
|
|
201
|
-
let targetAxis;
|
|
202
|
-
if (selectedLabelInfo?.targetAxis) {
|
|
203
|
-
targetAxis = selectedLabelInfo?.targetAxis === 'yAxis' ? 'y' : 'x';
|
|
204
|
-
} else {
|
|
205
|
-
targetAxis = horizontal ? 'y' : 'x';
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const isBlurredLabel = selectLabelOpt?.use
|
|
209
|
-
&& selectLabelOpt?.useLabelOpacity
|
|
210
|
-
&& targetAxis === this.type
|
|
211
|
-
&& selectedLabelInfo?.dataIndex?.length
|
|
212
|
-
&& !selectedLabelInfo?.dataIndex?.includes(labelIndex);
|
|
213
|
-
|
|
214
|
-
const labelColor = this.labelStyle.color;
|
|
215
|
-
let defaultOpacity = 1;
|
|
216
|
-
|
|
217
|
-
if (Util.getColorStringType(labelColor) === 'RGBA') {
|
|
218
|
-
defaultOpacity = Util.getOpacity(labelColor);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
ctx.fillStyle = Util.colorStringToRgba(labelColor, isBlurredLabel ? 0.1 : defaultOpacity);
|
|
222
|
-
|
|
223
|
-
if (this.type === 'x') {
|
|
224
|
-
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
225
|
-
const xPoint = alignToGridLine ? labelCenter : labelCenter + (labelGap / 2);
|
|
226
|
-
ctx.fillText(labelText, xPoint, labelPoint);
|
|
227
|
-
|
|
228
|
-
if (!isBlurredLabel
|
|
229
|
-
&& selectItemOpt?.showLabelTip
|
|
230
|
-
&& hitInfo?.label
|
|
231
|
-
&& !horizontal) {
|
|
232
|
-
const selectedLabel = hitInfo.label;
|
|
233
|
-
if (selectedLabel === labelText) {
|
|
234
|
-
const height = Math.round(ctx.measureText(this.labelStyle?.fontSize).width);
|
|
235
|
-
Util.showLabelTip({
|
|
236
|
-
ctx: this.ctx,
|
|
237
|
-
width: Math.round(ctx.measureText(selectedLabel).width) + 10,
|
|
238
|
-
height,
|
|
239
|
-
x: labelCenter + (labelGap / 2),
|
|
240
|
-
y: labelPoint + (height - 2),
|
|
241
|
-
borderRadius: 2,
|
|
242
|
-
arrowSize: 3,
|
|
243
|
-
text: labelText,
|
|
244
|
-
backgroundColor: selectItemOpt?.labelTipStyle?.backgroundColor,
|
|
245
|
-
textColor: selectItemOpt?.labelTipStyle?.textColor,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (this.showAxisTick) {
|
|
251
|
-
ctx.beginPath();
|
|
252
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
253
|
-
ctx.moveTo(labelCenter + (labelGap / 2), offsetPoint);
|
|
254
|
-
ctx.lineTo(labelCenter + (labelGap / 2), offsetPoint + AXIS_TICK_LENGTH);
|
|
255
|
-
ctx.stroke();
|
|
256
|
-
ctx.closePath();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (index > 0 && this.showGrid) {
|
|
260
|
-
ctx.beginPath();
|
|
261
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
262
|
-
ctx.moveTo(linePosition, offsetPoint);
|
|
263
|
-
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
264
|
-
ctx.stroke();
|
|
265
|
-
ctx.closePath();
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
269
|
-
const yPoint = alignToGridLine ? labelCenter : labelCenter + (labelGap / 2);
|
|
270
|
-
ctx.fillText(labelText, labelPoint, yPoint);
|
|
271
|
-
drawnLabels.push(labelText);
|
|
272
|
-
|
|
273
|
-
if (this.showAxisTick) {
|
|
274
|
-
ctx.beginPath();
|
|
275
|
-
ctx.strokeStyle = this.axisLineColor;
|
|
276
|
-
ctx.moveTo(offsetPoint + (this.axisLineWidth ?? 1), yPoint);
|
|
277
|
-
ctx.lineTo(offsetPoint - AXIS_TICK_LENGTH, yPoint);
|
|
278
|
-
ctx.stroke();
|
|
279
|
-
ctx.closePath();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (index > 0 && this.showGrid) {
|
|
283
|
-
ctx.beginPath();
|
|
284
|
-
ctx.strokeStyle = this.gridLineColor;
|
|
285
|
-
ctx.moveTo(offsetPoint, linePosition);
|
|
286
|
-
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
287
|
-
ctx.stroke();
|
|
288
|
-
ctx.closePath();
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
ctx.stroke();
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (alignToGridLine && index >= this.labels.length) {
|
|
295
|
-
const cellInterval = bnMinus(+labels[1], +labels[0]);
|
|
296
|
-
const lastLabelValue = bnPlus(+labels[labels.length - 1], cellInterval);
|
|
297
|
-
if (
|
|
298
|
-
isNaN(lastLabelValue)
|
|
299
|
-
|| (indexInterval !== 1
|
|
300
|
-
&& bnMinus(lastLabelValue, drawnLabels[drawnLabels.length - 1]) <= cellInterval)
|
|
301
|
-
) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
labelCenter = Math.round(startPoint + (labelGap * labels.length));
|
|
306
|
-
linePosition = labelCenter + aliasPixel;
|
|
307
|
-
|
|
308
|
-
const lastLabelText = this.getLabelFormat(`${lastLabelValue}`, maxWidth);
|
|
309
|
-
if (this.type === 'x') {
|
|
310
|
-
ctx.fillText(lastLabelText, labelCenter, labelPoint);
|
|
311
|
-
if (this.showGrid) {
|
|
312
|
-
ctx.moveTo(linePosition, offsetPoint);
|
|
313
|
-
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
314
|
-
}
|
|
315
|
-
} else {
|
|
316
|
-
ctx.fillText(lastLabelText, labelPoint, labelCenter);
|
|
317
|
-
if (this.showGrid) {
|
|
318
|
-
ctx.moveTo(offsetPoint, linePosition);
|
|
319
|
-
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
ctx.stroke();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
ctx.closePath();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// draw plot lines and plot bands
|
|
329
|
-
if (this.plotBands?.length || this.plotLines?.length) {
|
|
330
|
-
const padding = Util.aliasPixel(ctx.lineWidth) + 1;
|
|
331
|
-
const minX = aPos.x1 + padding;
|
|
332
|
-
const maxX = aPos.x2;
|
|
333
|
-
const minY = aPos.y1 + padding;
|
|
334
|
-
const maxY = aPos.y2;
|
|
335
|
-
const labelGap = (endPoint - startPoint) / (this.labelStyle.show ? labels.length : 1);
|
|
336
|
-
|
|
337
|
-
this.plotBands?.forEach((plotBand) => {
|
|
338
|
-
if (!plotBand.from && !plotBand.to) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const mergedPlotBandOpt = defaultsDeep({}, plotBand, PLOT_BAND_OPTION);
|
|
343
|
-
const { from = 0, to = labels.length, label: labelOpt } = mergedPlotBandOpt;
|
|
344
|
-
const fromPos = Math.round(startPoint + (labelGap * from));
|
|
345
|
-
const toPos = Math.round(startPoint + (labelGap * to));
|
|
346
|
-
|
|
347
|
-
this.setPlotBandStyle(mergedPlotBandOpt);
|
|
348
|
-
|
|
349
|
-
if (this.type === 'x') {
|
|
350
|
-
this.drawXPlotBand(fromPos, toPos, minX, maxX, minY, maxY);
|
|
351
|
-
} else {
|
|
352
|
-
this.drawYPlotBand(fromPos, toPos, minX, maxX, minY, maxY);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (labelOpt.show) {
|
|
356
|
-
const labelOptions = this.getNormalizedLabelOptions(chartRect, labelOpt);
|
|
357
|
-
const textXY = this.getPlotBandLabelPosition(fromPos, toPos, labelOptions, maxX, minY);
|
|
358
|
-
this.drawPlotLabel(labelOptions, textXY);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
ctx.restore();
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
this.plotLines?.forEach((plotLine) => {
|
|
365
|
-
if (!plotLine.value) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const mergedPlotLineOpt = defaultsDeep({}, plotLine, PLOT_LINE_OPTION);
|
|
370
|
-
const { value, label: labelOpt } = mergedPlotLineOpt;
|
|
371
|
-
const dataPos = Math.round(startPoint + (labelGap * value)) + (labelGap / 2);
|
|
372
|
-
|
|
373
|
-
this.setPlotLineStyle(mergedPlotLineOpt);
|
|
374
|
-
|
|
375
|
-
if (this.type === 'x') {
|
|
376
|
-
this.drawXPlotLine(dataPos, minX, maxX, minY, maxY);
|
|
377
|
-
} else {
|
|
378
|
-
this.drawYPlotLine(dataPos, minX, maxX, minY, maxY);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (labelOpt.show) {
|
|
382
|
-
const labelOptions = this.getNormalizedLabelOptions(chartRect, labelOpt);
|
|
383
|
-
const textXY = this.getPlotLineLabelPosition(dataPos, labelOptions, maxX, minY);
|
|
384
|
-
this.drawPlotLabel(labelOptions, textXY);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
ctx.restore();
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Transforming label by designated format
|
|
394
|
-
* @param {string} value label value
|
|
395
|
-
* @param {number} maxWidth max width for each label
|
|
396
|
-
* @param {object} data data for formatting
|
|
397
|
-
*
|
|
398
|
-
* @returns {string} formatted label
|
|
399
|
-
*/
|
|
400
|
-
getLabelFormat(value, maxWidth, data = {}) {
|
|
401
|
-
if (this.formatter) {
|
|
402
|
-
const formattedLabel = this.formatter(value, data);
|
|
403
|
-
|
|
404
|
-
if (typeof formattedLabel === 'string') {
|
|
405
|
-
return formattedLabel;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return this.labelStyle.fitWidth ? this.fittingString(value, maxWidth) : value;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Transforming ellipsis label by designated format and specific width
|
|
414
|
-
* @param {string} value label value
|
|
415
|
-
* @param {number} maxWidth max width for each label
|
|
416
|
-
*
|
|
417
|
-
* @returns {string} formatted label
|
|
418
|
-
*/
|
|
419
|
-
fittingString(value, maxWidth) {
|
|
420
|
-
const ctx = this.ctx;
|
|
421
|
-
|
|
422
|
-
ctx.save();
|
|
423
|
-
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
424
|
-
const dir = this.labelStyle.fitDir;
|
|
425
|
-
|
|
426
|
-
return Util.truncateLabelWithEllipsis(value, maxWidth, ctx, dir);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
export default StepScale;
|