evui 2.0.8 → 2.1.1
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/{adac9fa4f723f9d2cb5b6640517114a9.png → 0b8d1200e71cae8d747dce4e69c4efb6.png} +0 -0
- package/dist/1.css +4 -0
- package/dist/1.css.map +1 -0
- package/dist/1.evui.min.js +2 -0
- package/dist/1.evui.min.js.map +1 -0
- package/dist/1ba679c05036b34bf359aa2e6c450faa.ttf +0 -0
- package/dist/2.css +4 -0
- package/dist/2.css.map +1 -0
- package/dist/2.evui.min.js +2 -0
- package/dist/2.evui.min.js.map +1 -0
- package/dist/{e8c322de9658cbeb8a774b6624167c2c.woff2 → 278156e41e0ad908cf7f841b17130502.woff2} +0 -0
- package/dist/3.evui.min.js +2 -0
- package/dist/3.evui.min.js.map +1 -0
- package/dist/32be89b11725274cd3e801192ba88361.ttf +0 -0
- package/dist/{0ab54153eeeca0ce03978cc463b257f7.woff2 → 38c6d8bab26db77d8c806813e1497763.woff2} +0 -0
- package/dist/4.evui.min.js +2 -0
- package/dist/4.evui.min.js.map +1 -0
- package/dist/{faff92145777a3cbaf8e7367b4807987.woff → 425399f81e4ce7cbd967685402ba0260.woff} +0 -0
- package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
- package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
- package/dist/{ad97afd3337e8cda302d10ff5a4026b8.ttf → 5367103510b27b78482794590e1ce3b0.ttf} +0 -0
- package/dist/{65363c4d55617bbeb57d8ce6dcd46099.svg → 57e963e3d6dd0a9cf05150b40eebf69b.svg} +0 -0
- package/dist/{c5ebe0b32dc1b5cc449a76c4204d13bb.ttf → 65a2fb6d9aaa164b41a039302093995b.ttf} +0 -0
- package/dist/{cd6c777f1945164224dee082abaea03a.woff2 → 687a4990ea22bb1a49d469a5d9319790.woff2} +0 -0
- package/dist/{7583da5c07275cd5eb364507616f998f.ttf → 6c1d906bf5ba48676f65b2d65e935e1a.ttf} +0 -0
- package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
- package/dist/{701ae6abd4719e9c2ada3535a497b341.eot → 752905fa5edf21fc52a10a0c1ca9c7a4.eot} +0 -0
- package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
- package/dist/{b551b554a67e86a840bc80cbb8066c30.svg → 7d62eb50e7bb05eedb2a4656f7fe8f3b.svg} +0 -0
- package/dist/{8e3c7f5520f5ae906c6cf6d7f3ddcd19.eot → a01e3f2d6c83dc3aee175e2482b3f777.eot} +0 -0
- package/dist/{448f2aaa315fa9dce7b2cf6ce31caed6.svg → b30fd8419d7e6d5918856c7531d33482.svg} +0 -0
- package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
- package/dist/{b87b9ba532ace76ae9f6edfe9f72ded2.ttf → c656b8caa454ed19b9a2ef7f4f5b8fea.ttf} +0 -0
- package/dist/{a046592bac8f2fd96e994733faf3858c.woff → cac87dc00c87a5d74711d0276713808a.woff} +0 -0
- package/dist/{13db00b7a34fee4d819ab7f9838cc428.eot → d68fa3e67dbb653a13cec44b1bcabcfe.eot} +0 -0
- package/dist/{ef60a4f6c25ef7f39f2d25a748dbecfe.woff → ddae9b1ba9b0b42f58809904b0b21349.woff} +0 -0
- package/dist/evui.min.js +12 -59485
- package/dist/evui.min.js.gz +0 -0
- package/dist/evui.min.js.map +1 -1
- package/dist/main.css +85 -0
- package/dist/main.css.gz +0 -0
- package/dist/main.css.map +1 -0
- package/package.json +58 -89
- package/src/common/emitter.js +20 -0
- package/src/common/utils.debounce.js +223 -0
- package/src/common/utils.js +51 -17
- package/src/common/utils.throttle.js +83 -0
- package/src/common/utils.tree.js +18 -0
- package/src/components/button/button.vue +316 -241
- package/src/components/chart/chart.core.js +699 -0
- package/src/components/chart/chart.vue +200 -204
- package/src/components/chart/element/element.bar.js +311 -0
- package/src/components/chart/element/element.bar.time.js +115 -0
- package/src/components/chart/element/element.line.js +288 -0
- package/src/components/chart/element/element.pie.js +86 -0
- package/src/components/chart/element/element.scatter.js +83 -0
- package/src/components/chart/element/element.tip.js +356 -0
- package/src/components/chart/helpers/helpers.canvas.js +237 -0
- package/src/components/chart/helpers/helpers.constant.js +138 -0
- package/src/components/chart/helpers/helpers.util.js +154 -0
- package/src/components/chart/index.js +0 -1
- package/src/components/chart/model/index.js +4 -0
- package/src/components/chart/model/model.series.js +86 -0
- package/src/components/chart/model/model.store.js +559 -0
- package/src/components/chart/plugins/plugins.interaction.js +324 -0
- package/src/components/chart/plugins/plugins.legend.js +589 -0
- package/src/components/chart/plugins/plugins.pie.js +179 -0
- package/src/components/chart/plugins/plugins.title.js +56 -0
- package/src/components/chart/plugins/plugins.tooltip.js +384 -0
- package/src/components/chart/scale/scale.js +272 -0
- package/src/components/chart/scale/scale.linear.js +30 -0
- package/src/components/chart/scale/scale.logarithmic.js +120 -0
- package/src/components/chart/scale/scale.step.js +197 -0
- package/src/components/chart/scale/scale.time.category.js +204 -0
- package/src/components/chart/scale/scale.time.js +40 -0
- package/src/components/checkbox/checkbox-group.vue +31 -12
- package/src/components/checkbox/checkbox.vue +269 -19
- package/src/components/codeview/code.vue +42 -29
- package/src/components/contextmenu/contextmenu.child.vue +79 -0
- package/src/components/contextmenu/contextmenu.vue +276 -0
- package/src/components/contextmenu/contextmenu.wrap.vue +189 -0
- package/src/components/contextmenu/index.js +3 -0
- package/src/components/datepicker/calendar.core.js +604 -510
- package/src/components/datepicker/calendar.vue +0 -3
- package/src/components/datepicker/datepicker.vue +73 -14
- package/src/components/datepicker/index.js +5 -1
- package/src/components/grid/grid.filter.vue +290 -0
- package/src/components/grid/grid.filter.window.vue +411 -0
- package/src/components/grid/grid.render.vue +45 -0
- package/src/components/grid/grid.vue +1338 -0
- package/src/components/icon/icon.vue +22 -7
- package/src/components/input/input.number.vue +309 -277
- package/src/components/label/label.vue +2 -2
- package/src/components/loadingmask/loadingmask.vue +52 -63
- package/src/components/loginfield/index.js +3 -0
- package/src/components/loginfield/loginfield.vue +339 -0
- package/src/components/markdown/index.js +3 -0
- package/src/components/markdown/markdown.vue +1001 -0
- package/src/components/menu/index.js +1 -3
- package/src/components/menu/menu.nav.item.vue +115 -0
- package/src/components/menu/menu.nav.sub.vue +42 -0
- package/src/components/menu/menu.nav.vue +71 -98
- package/src/components/message/index.js +3 -0
- package/src/components/message/message.js +63 -0
- package/src/components/message/message.vue +191 -0
- package/src/components/message-box/index.js +3 -0
- package/src/components/message-box/message-box.js +31 -0
- package/src/components/message-box/message-box.vue +298 -0
- package/src/components/notification/index.js +3 -0
- package/src/components/notification/notification.js +75 -0
- package/src/components/notification/notification.vue +242 -0
- package/src/components/radio/radio-group.vue +12 -2
- package/src/components/radio/radio.vue +186 -25
- package/src/components/selectbox/dropdown.vue +96 -39
- package/src/components/selectbox/listbox.vue +68 -29
- package/src/components/selectbox/option.vue +1 -1
- package/src/components/selectbox/selectbox.vue +445 -245
- package/src/components/slider/slider-tooltip.vue +7 -7
- package/src/components/slider/slider.vue +20 -25
- package/src/components/splitter/index.js +3 -0
- package/src/components/splitter/splitter.vue +294 -0
- package/src/components/table/table.black.css +1 -1
- package/src/components/table/table.filter.lite.vue +8 -8
- package/src/components/table/table.filter.vue +1 -1
- package/src/components/table/table.grey.css +5 -6
- package/src/components/table/table.navy.css +1 -1
- package/src/components/table/table.vue +60 -55
- package/src/components/tabs/tab-panel.vue +19 -5
- package/src/components/tabs/tabs.vue +182 -87
- package/src/components/textfield/textfield.vue +140 -80
- package/src/components/timepicker/index.js +2 -2
- package/src/components/timepicker/spinner.vue +15 -17
- package/src/components/timepicker/timepicker.vue +98 -53
- package/src/components/toggle/toggle.vue +206 -158
- package/src/components/tree/index.js +2 -6
- package/src/components/tree/render.js +17 -0
- package/src/components/tree/tree-node.vue +214 -0
- package/src/components/tree/tree.vue +296 -0
- package/src/components/tree-table/index.js +7 -0
- package/src/components/{tree → tree-table}/tree.table.black.css +0 -0
- package/src/components/{tree → tree-table}/tree.table.grey.css +12 -12
- package/src/components/{tree → tree-table}/tree.table.vue +151 -95
- package/src/components/tree-table/tree.util.js +119 -0
- package/src/components/window/window.vue +238 -183
- package/src/index.js +29 -12
- package/src/styles/base/base.scss +50 -0
- package/src/styles/base/index.scss +1 -0
- package/src/styles/default.scss +5 -0
- package/src/styles/{codemirror.css → lib/codemirror.css} +0 -0
- package/src/styles/{all.css → lib/fontawesome.css} +1 -1
- package/src/styles/lib/icon.css +792 -0
- package/src/styles/themes/index.scss +2 -0
- package/src/styles/themes/mixin.scss +33 -0
- package/src/styles/themes/variables.scss +206 -0
- package/src/styles/utils/colors.scss +222 -0
- package/src/styles/utils/index.scss +2 -0
- package/src/styles/utils/mixins.scss +34 -0
- package/src/styles/utils/variables.scss +27 -0
- package/src/webfonts/EVUI.eot +0 -0
- package/src/webfonts/EVUI.svg +251 -173
- package/src/webfonts/EVUI.ttf +0 -0
- package/src/webfonts/EVUI.woff +0 -0
- package/src/webfonts/Roboto-Bold.ttf +0 -0
- package/src/webfonts/Roboto-Medium.ttf +0 -0
- package/src/webfonts/Roboto-Regular.ttf +0 -0
- package/dist/3c9453211570a4ede66a4b4954a32bbb.ttf +0 -0
- package/dist/8634884f932627fc43782e6963b64ccd.svg +0 -183
- package/dist/b9e64d9b5fa6b500eb5df6fa980d3e5b.eot +0 -0
- package/dist/f0ac0c8b3c9cd3ef9002749985ae546f.woff +0 -0
- package/src/components/chart/charts/chart.bar.js +0 -334
- package/src/components/chart/charts/chart.base.js +0 -1075
- package/src/components/chart/charts/chart.line.js +0 -262
- package/src/components/chart/charts/chart.pie.js +0 -383
- package/src/components/chart/charts/chart.scatter.js +0 -349
- package/src/components/chart/charts/chart.sunburst.js +0 -193
- package/src/components/chart/core/axis/axis.js +0 -217
- package/src/components/chart/core/axis/axis.scale.auto.js +0 -69
- package/src/components/chart/core/axis/axis.scale.fixed.js +0 -65
- package/src/components/chart/core/axis/axis.scale.steps.js +0 -149
- package/src/components/chart/core/core.constant.js +0 -91
- package/src/components/chart/core/core.legend.js +0 -473
- package/src/components/chart/core/core.util.js +0 -66
- package/src/components/chart/core/data/data.js +0 -412
- package/src/components/chart/core/data/data.pie.js +0 -70
- package/src/components/chart/core/data/data.stack.js +0 -222
- package/src/components/chart/core/data/data.sunburst.js +0 -172
- package/src/components/menu/menu.context.children.vue +0 -201
- package/src/components/menu/menu.context.vue +0 -144
- package/src/components/tabs/jun/tab.vue +0 -123
- package/src/components/tabs/jun/tabs.vue +0 -484
- package/src/components/tree/tree.util.js +0 -39
- package/src/styles/evui.css +0 -386
- package/src/styles/icon.css +0 -557
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { defaultsDeep } from 'lodash-es';
|
|
2
|
+
import { AXIS_OPTION, AXIS_UNITS } from '../helpers/helpers.constant';
|
|
3
|
+
import Util from '../helpers/helpers.util';
|
|
4
|
+
|
|
5
|
+
class Scale {
|
|
6
|
+
constructor(type, opt, ctx) {
|
|
7
|
+
const merged = defaultsDeep({}, opt, AXIS_OPTION);
|
|
8
|
+
Object.keys(merged).forEach((key) => {
|
|
9
|
+
this[key] = merged[key];
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
this.units = AXIS_UNITS[this.type];
|
|
15
|
+
|
|
16
|
+
if (!this.position) {
|
|
17
|
+
this.position = type === 'x' ? 'bottom' : 'left';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Calculate axis's min/max label steps
|
|
23
|
+
* @param {string} type axis direction ('x', 'y')
|
|
24
|
+
* @param {object} chartRect chart size information
|
|
25
|
+
* @param {object} labelOffset chart label offset information
|
|
26
|
+
* @param {number} tickSize label's size
|
|
27
|
+
*
|
|
28
|
+
* @returns {object} label range
|
|
29
|
+
*/
|
|
30
|
+
calculateLabelRange(type, chartRect, labelOffset, tickSize) {
|
|
31
|
+
let chartSize;
|
|
32
|
+
let axisOffset;
|
|
33
|
+
let bufferedTickSize;
|
|
34
|
+
|
|
35
|
+
if (type === 'x') {
|
|
36
|
+
chartSize = chartRect.chartWidth;
|
|
37
|
+
bufferedTickSize = Math.floor(tickSize * 1.1);
|
|
38
|
+
axisOffset = [labelOffset.left, labelOffset.right];
|
|
39
|
+
} else {
|
|
40
|
+
chartSize = chartRect.chartHeight;
|
|
41
|
+
axisOffset = [labelOffset.top, labelOffset.bottom];
|
|
42
|
+
bufferedTickSize = tickSize + (Math.floor(chartSize * 0.1));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const drawRange = chartSize - (axisOffset[0] + axisOffset[1]);
|
|
46
|
+
const minSteps = 1;
|
|
47
|
+
const maxSteps = Math.max(Math.floor(drawRange / bufferedTickSize) - 1, 1);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
min: minSteps,
|
|
51
|
+
max: maxSteps,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Calculate min/max value, label and size information for axis
|
|
57
|
+
* @param {object} minMax min/max information
|
|
58
|
+
*
|
|
59
|
+
* @returns {object} min/max value and label
|
|
60
|
+
*/
|
|
61
|
+
calculateScaleRange(minMax) {
|
|
62
|
+
let maxValue;
|
|
63
|
+
let minValue;
|
|
64
|
+
|
|
65
|
+
if (this.range && this.range.length === 2) {
|
|
66
|
+
maxValue = this.range[1];
|
|
67
|
+
minValue = this.range[0];
|
|
68
|
+
} else {
|
|
69
|
+
maxValue = minMax.max;
|
|
70
|
+
minValue = minMax.min;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.autoScaleRatio) {
|
|
74
|
+
maxValue = Math.ceil(maxValue * (this.autoScaleRatio + 1));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (this.startToZero) {
|
|
78
|
+
minValue = 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (maxValue === minValue) {
|
|
82
|
+
maxValue += 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const minLabel = this.getLabelFormat(minValue);
|
|
86
|
+
const maxLabel = this.getLabelFormat(maxValue);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
min: minValue,
|
|
90
|
+
max: maxValue,
|
|
91
|
+
minLabel,
|
|
92
|
+
maxLabel,
|
|
93
|
+
size: Util.calcTextSize(maxLabel, Util.getLabelStyle(this.labelStyle)),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* With range information, calculate how many labels in axis
|
|
99
|
+
* @param {object} range min/max information
|
|
100
|
+
*
|
|
101
|
+
* @returns {object} steps, interval, min/max graph value
|
|
102
|
+
*/
|
|
103
|
+
calculateSteps(range) {
|
|
104
|
+
const { maxValue, minValue } = range;
|
|
105
|
+
let { maxSteps } = range;
|
|
106
|
+
|
|
107
|
+
let interval = this.getInterval(range);
|
|
108
|
+
let increase = minValue;
|
|
109
|
+
let numberOfSteps;
|
|
110
|
+
|
|
111
|
+
while (increase < maxValue) {
|
|
112
|
+
increase += interval;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const graphMax = increase > maxValue ? maxValue : increase;
|
|
116
|
+
const graphMin = minValue;
|
|
117
|
+
const graphRange = graphMax - graphMin;
|
|
118
|
+
|
|
119
|
+
numberOfSteps = Math.round(graphRange / interval);
|
|
120
|
+
|
|
121
|
+
if (maxValue === 1) {
|
|
122
|
+
if (maxSteps > 2) {
|
|
123
|
+
interval = 0.2;
|
|
124
|
+
numberOfSteps = 5;
|
|
125
|
+
maxSteps = 5;
|
|
126
|
+
} else {
|
|
127
|
+
interval = 0.5;
|
|
128
|
+
numberOfSteps = 2;
|
|
129
|
+
maxSteps = 2;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
while (numberOfSteps > maxSteps) {
|
|
134
|
+
interval *= 2;
|
|
135
|
+
numberOfSteps = Math.round(graphRange / interval);
|
|
136
|
+
interval = Math.ceil(graphRange / numberOfSteps);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (graphMax - graphMin > (numberOfSteps * interval)) {
|
|
140
|
+
interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
steps: numberOfSteps,
|
|
145
|
+
interval,
|
|
146
|
+
graphMin,
|
|
147
|
+
graphMax,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Draw axis
|
|
153
|
+
* @param {object} chartRect min/max information
|
|
154
|
+
* @param {object} labelOffset label offset information
|
|
155
|
+
* @param {object} stepInfo label steps information
|
|
156
|
+
*
|
|
157
|
+
* @returns {undefined}
|
|
158
|
+
*/
|
|
159
|
+
draw(chartRect, labelOffset, stepInfo) {
|
|
160
|
+
const ctx = this.ctx;
|
|
161
|
+
const aPos = {
|
|
162
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
163
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
164
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
165
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const steps = stepInfo.steps;
|
|
169
|
+
const axisMin = stepInfo.graphMin;
|
|
170
|
+
const axisMax = stepInfo.graphMax;
|
|
171
|
+
const stepValue = stepInfo.interval;
|
|
172
|
+
|
|
173
|
+
const startPoint = aPos[this.units.rectStart];
|
|
174
|
+
const endPoint = aPos[this.units.rectEnd];
|
|
175
|
+
const offsetPoint = aPos[this.units.rectOffset(this.position)];
|
|
176
|
+
const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
|
|
177
|
+
|
|
178
|
+
let aliasPixel;
|
|
179
|
+
|
|
180
|
+
// label font 설정
|
|
181
|
+
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
182
|
+
ctx.fillStyle = this.labelStyle.color;
|
|
183
|
+
|
|
184
|
+
if (this.type === 'x') {
|
|
185
|
+
ctx.textAlign = 'center';
|
|
186
|
+
ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
|
|
187
|
+
} else {
|
|
188
|
+
ctx.textAlign = this.position === 'left' ? 'right' : 'left';
|
|
189
|
+
ctx.textBaseline = 'middle';
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.showAxis) {
|
|
193
|
+
ctx.lineWidth = 2;
|
|
194
|
+
aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
195
|
+
|
|
196
|
+
ctx.beginPath();
|
|
197
|
+
ctx.strokeStyle = this.axisLineColor;
|
|
198
|
+
|
|
199
|
+
if (this.type === 'x') {
|
|
200
|
+
ctx.moveTo(startPoint, offsetPoint + aliasPixel);
|
|
201
|
+
ctx.lineTo(endPoint, offsetPoint + aliasPixel);
|
|
202
|
+
} else {
|
|
203
|
+
ctx.moveTo(offsetPoint + aliasPixel + 1, startPoint);
|
|
204
|
+
ctx.lineTo(offsetPoint + aliasPixel + 1, endPoint);
|
|
205
|
+
}
|
|
206
|
+
ctx.stroke();
|
|
207
|
+
ctx.closePath();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (steps === 0 || axisMin === null) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const labelGap = (endPoint - startPoint) / steps;
|
|
215
|
+
const ticks = [];
|
|
216
|
+
let labelCenter = null;
|
|
217
|
+
let linePosition = null;
|
|
218
|
+
|
|
219
|
+
ctx.strokeStyle = this.gridLineColor;
|
|
220
|
+
ctx.lineWidth = 1;
|
|
221
|
+
aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
222
|
+
|
|
223
|
+
let labelText;
|
|
224
|
+
for (let ix = 0; ix <= steps; ix++) {
|
|
225
|
+
ctx.beginPath();
|
|
226
|
+
ticks[ix] = axisMin + (ix * stepValue);
|
|
227
|
+
|
|
228
|
+
labelCenter = Math.round(startPoint + (labelGap * ix));
|
|
229
|
+
linePosition = labelCenter + aliasPixel;
|
|
230
|
+
labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
|
|
231
|
+
|
|
232
|
+
let labelPoint;
|
|
233
|
+
|
|
234
|
+
if (this.type === 'x') {
|
|
235
|
+
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
236
|
+
ctx.fillText(labelText, labelCenter, labelPoint);
|
|
237
|
+
|
|
238
|
+
if (this.showIndicator) {
|
|
239
|
+
ctx.moveTo(linePosition, offsetPoint + 6);
|
|
240
|
+
ctx.lineTo(linePosition, offsetPoint);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (ix !== 0 && this.showGrid) {
|
|
244
|
+
ctx.moveTo(linePosition, offsetPoint);
|
|
245
|
+
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
249
|
+
ctx.fillText(labelText, labelPoint, labelCenter);
|
|
250
|
+
|
|
251
|
+
if (ix === steps) {
|
|
252
|
+
linePosition += 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (this.showIndicator) {
|
|
256
|
+
ctx.moveTo(offsetPoint - 6, linePosition);
|
|
257
|
+
ctx.lineTo(offsetPoint, linePosition);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (ix !== 0 && this.showGrid) {
|
|
261
|
+
ctx.moveTo(offsetPoint, linePosition);
|
|
262
|
+
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
ctx.stroke();
|
|
267
|
+
ctx.closePath();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export default Scale;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Scale from './scale';
|
|
2
|
+
import Util from '../helpers/helpers.util';
|
|
3
|
+
|
|
4
|
+
class LinearScale extends Scale {
|
|
5
|
+
/**
|
|
6
|
+
* Transforming label by designated format
|
|
7
|
+
* @param {number} value label value
|
|
8
|
+
*
|
|
9
|
+
* @returns {string} formatted label
|
|
10
|
+
*/
|
|
11
|
+
getLabelFormat(value) {
|
|
12
|
+
return Util.labelSignFormat(value, this.decimalPoint);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Calculate interval
|
|
17
|
+
* @param {object} range range information
|
|
18
|
+
*
|
|
19
|
+
* @returns {number} interval
|
|
20
|
+
*/
|
|
21
|
+
getInterval(range) {
|
|
22
|
+
const max = range.maxValue;
|
|
23
|
+
const min = range.minValue;
|
|
24
|
+
const step = range.maxSteps;
|
|
25
|
+
|
|
26
|
+
return this.interval ? this.interval : Math.ceil((max - min) / step);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default LinearScale;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Scale from './scale';
|
|
2
|
+
import Util from '../helpers/helpers.util';
|
|
3
|
+
|
|
4
|
+
class LogarithmicScale extends Scale {
|
|
5
|
+
/**
|
|
6
|
+
* Calculate min/max value, label and size information for logarithmic scale
|
|
7
|
+
* @param {object} minMax min/max information
|
|
8
|
+
*
|
|
9
|
+
* @returns {object} min/max value and label
|
|
10
|
+
*/
|
|
11
|
+
calculateScaleRange(minMax) {
|
|
12
|
+
let maxValue;
|
|
13
|
+
let minValue;
|
|
14
|
+
if (this.range && this.range.length === 2) {
|
|
15
|
+
maxValue = this.range[1];
|
|
16
|
+
minValue = this.range[0];
|
|
17
|
+
} else {
|
|
18
|
+
maxValue = minMax.max;
|
|
19
|
+
minValue = minMax.min;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rangeMagnitude = Util.calculateMagnitude(maxValue - minValue);
|
|
23
|
+
maxValue = Math.ceil(maxValue / (10 ** rangeMagnitude)) * (10 ** rangeMagnitude);
|
|
24
|
+
|
|
25
|
+
if (this.startToZero) {
|
|
26
|
+
minValue = 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (maxValue === minValue) {
|
|
30
|
+
maxValue += 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const minLabel = this.getLabelFormat(minValue);
|
|
34
|
+
const maxLabel = this.getLabelFormat(maxValue);
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
min: minValue,
|
|
38
|
+
max: maxValue,
|
|
39
|
+
minLabel,
|
|
40
|
+
maxLabel,
|
|
41
|
+
size: Util.calcTextSize(maxLabel, Util.getLabelStyle(this.labelStyle)),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* With range information, calculate how many labels in axis
|
|
47
|
+
* @param {object} range min/max information
|
|
48
|
+
* @param {boolean} skipFitting determines if label skipping job.
|
|
49
|
+
*
|
|
50
|
+
* @returns {object} steps, interval, min/max graph value
|
|
51
|
+
*/
|
|
52
|
+
calculateSteps(range, skipFitting) {
|
|
53
|
+
const maxValue = range.maxValue;
|
|
54
|
+
const minValue = range.minValue;
|
|
55
|
+
const maxSteps = range.maxSteps;
|
|
56
|
+
const rangeMagnitude = Util.calculateMagnitude(maxValue - minValue);
|
|
57
|
+
|
|
58
|
+
let interval = this.getInterval(range);
|
|
59
|
+
let numberOfSteps;
|
|
60
|
+
|
|
61
|
+
const graphMax = maxValue;
|
|
62
|
+
const graphMin = minValue;
|
|
63
|
+
const graphRange = graphMax - graphMin;
|
|
64
|
+
|
|
65
|
+
numberOfSteps = Math.round(graphRange / interval);
|
|
66
|
+
|
|
67
|
+
if (maxValue === 1) {
|
|
68
|
+
interval = 0.2;
|
|
69
|
+
numberOfSteps = 5;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
while ((numberOfSteps > maxSteps || (numberOfSteps * 2) < maxSteps) && !skipFitting) {
|
|
73
|
+
if (numberOfSteps > maxSteps) {
|
|
74
|
+
interval *= 2;
|
|
75
|
+
numberOfSteps = Math.ceil(graphRange / interval);
|
|
76
|
+
} else if (rangeMagnitude >= 0) {
|
|
77
|
+
if ((interval / 2) % 1 === 0) {
|
|
78
|
+
interval /= 2;
|
|
79
|
+
numberOfSteps = Math.ceil(graphRange / interval);
|
|
80
|
+
} else {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
interval /= 2;
|
|
85
|
+
numberOfSteps = Math.ceil(graphRange / interval);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
steps: numberOfSteps,
|
|
91
|
+
interval,
|
|
92
|
+
graphMin,
|
|
93
|
+
graphMax: Math.ceil(graphMin + (numberOfSteps * interval)),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Transforming label by designated format
|
|
99
|
+
* @param {any} value label value
|
|
100
|
+
*
|
|
101
|
+
* @returns {string} formatted label
|
|
102
|
+
*/
|
|
103
|
+
getLabelFormat(value) {
|
|
104
|
+
return Util.labelSignFormat(value, this.decimalPoint);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Calculate interval
|
|
109
|
+
* @param {object} range range information
|
|
110
|
+
*
|
|
111
|
+
* @returns {number} interval
|
|
112
|
+
*/
|
|
113
|
+
getInterval(range) {
|
|
114
|
+
const max = range.maxValue;
|
|
115
|
+
const min = range.minValue;
|
|
116
|
+
return 10 ** Util.calculateMagnitude(max - min);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default LogarithmicScale;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import Scale from './scale';
|
|
2
|
+
import Util from '../helpers/helpers.util';
|
|
3
|
+
|
|
4
|
+
class StepScale extends Scale {
|
|
5
|
+
constructor(type, opt, ctx, labels) {
|
|
6
|
+
super(type, opt, ctx);
|
|
7
|
+
this.labels = labels;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Calculate min/max value, label and size information for step scale
|
|
12
|
+
* @param {object} minMax min/max information (unused on step scale)
|
|
13
|
+
* @param {object} chartRect chart size information
|
|
14
|
+
*
|
|
15
|
+
* @returns {object} min/max value and label
|
|
16
|
+
*/
|
|
17
|
+
calculateScaleRange(minMax, chartRect) {
|
|
18
|
+
const stepMinMax = Util.getStringMinMax(this.labels);
|
|
19
|
+
const maxValue = stepMinMax.max;
|
|
20
|
+
const minValue = stepMinMax.min;
|
|
21
|
+
const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
min: minValue,
|
|
25
|
+
max: maxValue,
|
|
26
|
+
minLabel: this.getLabelFormat(minValue, maxWidth),
|
|
27
|
+
maxLabel: this.getLabelFormat(maxValue, maxWidth),
|
|
28
|
+
size: Util.calcTextSize(
|
|
29
|
+
this.getLabelFormat(maxValue, maxWidth),
|
|
30
|
+
Util.getLabelStyle(this.labelStyle),
|
|
31
|
+
),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* With range information, calculate how many labels in axis
|
|
37
|
+
* @param {object} range min/max information
|
|
38
|
+
*
|
|
39
|
+
* @returns {object} steps, interval, min/max graph value
|
|
40
|
+
*/
|
|
41
|
+
calculateSteps(range) {
|
|
42
|
+
return {
|
|
43
|
+
steps: this.labels.length,
|
|
44
|
+
interval: 1,
|
|
45
|
+
graphMin: range.minValue,
|
|
46
|
+
graphMax: range.maxValue,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Draw axis
|
|
52
|
+
* @param {object} chartRect min/max information
|
|
53
|
+
* @param {object} labelOffset label offset information
|
|
54
|
+
* @param {object} stepInfo label steps information
|
|
55
|
+
*
|
|
56
|
+
* @returns {undefined}
|
|
57
|
+
*/
|
|
58
|
+
draw(chartRect, labelOffset, stepInfo) {
|
|
59
|
+
const ctx = this.ctx;
|
|
60
|
+
const labels = this.labels;
|
|
61
|
+
const aPos = {
|
|
62
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
63
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
64
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
65
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const steps = stepInfo.steps;
|
|
69
|
+
|
|
70
|
+
const startPoint = aPos[this.units.rectStart];
|
|
71
|
+
const endPoint = aPos[this.units.rectEnd];
|
|
72
|
+
const offsetPoint = aPos[this.units.rectOffset(this.position)];
|
|
73
|
+
const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
|
|
74
|
+
const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
|
|
75
|
+
|
|
76
|
+
// label font 설정
|
|
77
|
+
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
78
|
+
|
|
79
|
+
if (this.type === 'x') {
|
|
80
|
+
ctx.textAlign = 'center';
|
|
81
|
+
ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
|
|
82
|
+
} else {
|
|
83
|
+
ctx.textAlign = this.position === 'left' ? 'right' : 'left';
|
|
84
|
+
ctx.textBaseline = 'middle';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ctx.fillStyle = this.labelStyle.color;
|
|
88
|
+
ctx.lineWidth = 1;
|
|
89
|
+
const aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
90
|
+
|
|
91
|
+
ctx.beginPath();
|
|
92
|
+
ctx.strokeStyle = this.axisLineColor;
|
|
93
|
+
if (this.type === 'x') {
|
|
94
|
+
ctx.moveTo(startPoint, offsetPoint + aliasPixel);
|
|
95
|
+
ctx.lineTo(endPoint, offsetPoint + aliasPixel);
|
|
96
|
+
} else {
|
|
97
|
+
ctx.moveTo(offsetPoint + aliasPixel, startPoint);
|
|
98
|
+
ctx.lineTo(offsetPoint + aliasPixel, endPoint);
|
|
99
|
+
}
|
|
100
|
+
ctx.stroke();
|
|
101
|
+
|
|
102
|
+
if (steps === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const labelGap = (endPoint - startPoint) / labels.length;
|
|
107
|
+
let labelCenter = null;
|
|
108
|
+
let linePosition = null;
|
|
109
|
+
|
|
110
|
+
ctx.beginPath();
|
|
111
|
+
ctx.strokeStyle = this.gridLineColor;
|
|
112
|
+
|
|
113
|
+
let labelText;
|
|
114
|
+
let labelPoint;
|
|
115
|
+
|
|
116
|
+
labels.forEach((item, index) => {
|
|
117
|
+
labelCenter = Math.round(startPoint + (labelGap * index));
|
|
118
|
+
linePosition = labelCenter + aliasPixel;
|
|
119
|
+
labelText = this.getLabelFormat(item, maxWidth);
|
|
120
|
+
|
|
121
|
+
if (this.type === 'x') {
|
|
122
|
+
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
123
|
+
ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
|
|
124
|
+
|
|
125
|
+
if (index > 0 && this.showGrid) {
|
|
126
|
+
ctx.moveTo(linePosition, offsetPoint);
|
|
127
|
+
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
131
|
+
ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
|
|
132
|
+
|
|
133
|
+
if (index > 0 && this.showGrid) {
|
|
134
|
+
ctx.moveTo(offsetPoint, linePosition);
|
|
135
|
+
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
ctx.stroke();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
ctx.closePath();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Transforming label by designated format
|
|
146
|
+
* @param {string} value label value
|
|
147
|
+
* @param {number} maxWidth max width for each label
|
|
148
|
+
*
|
|
149
|
+
* @returns {string} formatted label
|
|
150
|
+
*/
|
|
151
|
+
getLabelFormat(value, maxWidth) {
|
|
152
|
+
return this.labelStyle.fitWidth ? this.fittingString(value, maxWidth) : value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Transforming ellipsis label by designated format and specific width
|
|
157
|
+
* @param {string} value label value
|
|
158
|
+
* @param {number} maxWidth max width for each label
|
|
159
|
+
*
|
|
160
|
+
* @returns {string} formatted label
|
|
161
|
+
*/
|
|
162
|
+
fittingString(value, maxWidth) {
|
|
163
|
+
if (!value) {
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!maxWidth) {
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const ctx = this.ctx;
|
|
172
|
+
|
|
173
|
+
ctx.save();
|
|
174
|
+
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
175
|
+
const dir = this.labelStyle.fitDir;
|
|
176
|
+
|
|
177
|
+
const ellipsis = '…';
|
|
178
|
+
const ellipsisWidth = ctx.measureText(ellipsis).width;
|
|
179
|
+
|
|
180
|
+
let str = value;
|
|
181
|
+
let width = ctx.measureText(str).width;
|
|
182
|
+
|
|
183
|
+
if (width <= maxWidth || width <= ellipsisWidth) {
|
|
184
|
+
return str;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let len = str.length;
|
|
188
|
+
while (width >= maxWidth - ellipsisWidth && len-- > 0) {
|
|
189
|
+
str = dir === 'right' ? str.substring(0, len) : str.substring(1, str.length);
|
|
190
|
+
width = ctx.measureText(str).width;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return dir === 'right' ? str + ellipsis : ellipsis + str;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default StepScale;
|