evui 2.0.9 → 2.1.2
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/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/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/38c6d8bab26db77d8c806813e1497763.woff2 +0 -0
- package/dist/4.evui.min.js +2 -0
- package/dist/4.evui.min.js.map +1 -0
- package/dist/425399f81e4ce7cbd967685402ba0260.woff +0 -0
- package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
- package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
- package/dist/5367103510b27b78482794590e1ce3b0.ttf +0 -0
- package/dist/57e963e3d6dd0a9cf05150b40eebf69b.svg +1008 -0
- package/dist/65a2fb6d9aaa164b41a039302093995b.ttf +0 -0
- package/dist/687a4990ea22bb1a49d469a5d9319790.woff2 +0 -0
- package/dist/6c1d906bf5ba48676f65b2d65e935e1a.ttf +0 -0
- package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
- package/dist/752905fa5edf21fc52a10a0c1ca9c7a4.eot +0 -0
- package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
- package/dist/7d62eb50e7bb05eedb2a4656f7fe8f3b.svg +366 -0
- package/dist/a01e3f2d6c83dc3aee175e2482b3f777.eot +0 -0
- package/dist/b30fd8419d7e6d5918856c7531d33482.svg +1518 -0
- package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
- package/dist/c656b8caa454ed19b9a2ef7f4f5b8fea.ttf +0 -0
- package/dist/cac87dc00c87a5d74711d0276713808a.woff +0 -0
- package/dist/d68fa3e67dbb653a13cec44b1bcabcfe.eot +0 -0
- package/dist/ddae9b1ba9b0b42f58809904b0b21349.woff +0 -0
- package/dist/evui.min.js +19 -0
- package/dist/evui.min.js.gz +0 -0
- package/dist/evui.min.js.map +1 -0
- package/dist/main.css +85 -0
- package/dist/main.css.gz +0 -0
- package/dist/main.css.map +1 -0
- package/package.json +56 -76
- 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 +317 -241
- package/src/components/chart/chart.core.js +378 -85
- package/src/components/chart/chart.vue +133 -115
- package/src/components/chart/element/element.bar.js +219 -25
- package/src/components/chart/element/element.bar.time.js +115 -0
- package/src/components/chart/element/element.line.js +172 -21
- package/src/components/chart/element/element.pie.js +86 -0
- package/src/components/chart/element/element.scatter.js +9 -2
- package/src/components/chart/element/element.tip.js +356 -0
- package/src/components/chart/helpers/helpers.canvas.js +94 -0
- package/src/components/chart/helpers/helpers.constant.js +25 -6
- package/src/components/chart/helpers/helpers.util.js +83 -38
- package/src/components/chart/index.js +0 -1
- package/src/components/chart/model/model.series.js +43 -14
- package/src/components/chart/model/model.store.js +440 -46
- package/src/components/chart/plugins/plugins.interaction.js +324 -0
- package/src/components/chart/plugins/plugins.legend.js +233 -91
- package/src/components/chart/plugins/plugins.pie.js +179 -0
- package/src/components/chart/plugins/plugins.title.js +25 -2
- package/src/components/chart/plugins/plugins.tooltip.js +384 -0
- package/src/components/chart/scale/scale.js +91 -29
- package/src/components/chart/scale/scale.linear.js +12 -0
- package/src/components/chart/scale/scale.logarithmic.js +25 -0
- package/src/components/chart/scale/scale.step.js +89 -52
- package/src/components/chart/scale/scale.time.category.js +204 -0
- package/src/components/chart/scale/scale.time.js +19 -1
- package/src/components/checkbox/checkbox-group.vue +15 -11
- package/src/components/checkbox/checkbox.vue +210 -138
- 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 +588 -492
- package/src/components/datepicker/calendar.vue +0 -3
- package/src/components/datepicker/datepicker.vue +43 -15
- 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 +23 -7
- package/src/components/input/input.number.vue +309 -277
- package/src/components/label/label.vue +2 -2
- package/src/components/loadingmask/loadingmask.vue +6 -13
- package/src/components/loginfield/loginfield.vue +46 -37
- 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 +299 -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 +6 -2
- package/src/components/radio/radio.vue +156 -76
- package/src/components/selectbox/dropdown.vue +86 -40
- package/src/components/selectbox/listbox.vue +47 -18
- package/src/components/selectbox/option.vue +1 -1
- package/src/components/selectbox/selectbox.vue +304 -316
- package/src/components/slider/slider-tooltip.vue +7 -7
- package/src/components/slider/slider.vue +20 -25
- package/src/components/splitter/splitter.vue +104 -94
- package/src/components/table/table.black.css +1 -1
- package/src/components/table/table.filter.lite.vue +7 -7
- 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 +55 -48
- package/src/components/tabs/tab-panel.vue +19 -5
- package/src/components/tabs/tabs.vue +182 -87
- package/src/components/textfield/textfield.vue +110 -87
- 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 +148 -109
- 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 +0 -0
- package/src/components/{tree → tree-table}/tree.table.vue +36 -41
- package/src/components/{tree → tree-table}/tree.util.js +0 -0
- package/src/components/window/window.vue +238 -191
- package/src/index.js +25 -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/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 -116
- 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/styles/evui.css +0 -386
- package/src/styles/icon.css +0 -557
|
@@ -1,54 +1,63 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
1
|
import Scale from './scale';
|
|
3
2
|
import Util from '../helpers/helpers.util';
|
|
4
3
|
|
|
5
4
|
class StepScale extends Scale {
|
|
6
5
|
constructor(type, opt, ctx, labels) {
|
|
7
6
|
super(type, opt, ctx);
|
|
8
|
-
this.
|
|
7
|
+
this.labels = labels;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
13
19
|
const maxValue = stepMinMax.max;
|
|
14
20
|
const minValue = stepMinMax.min;
|
|
21
|
+
const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
|
|
15
22
|
|
|
16
23
|
return {
|
|
17
24
|
min: minValue,
|
|
18
25
|
max: maxValue,
|
|
19
|
-
minLabel: this.getLabelFormat(minValue),
|
|
20
|
-
maxLabel: this.getLabelFormat(maxValue),
|
|
21
|
-
size: Util.calcTextSize(
|
|
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
|
+
),
|
|
22
32
|
};
|
|
23
33
|
}
|
|
24
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
|
+
*/
|
|
25
41
|
calculateSteps(range) {
|
|
26
|
-
const labels = this.integratedLabels;
|
|
27
|
-
const maxSteps = range.maxSteps;
|
|
28
|
-
|
|
29
|
-
let interval = 1;
|
|
30
|
-
let numberOfSteps;
|
|
31
|
-
|
|
32
|
-
const graphRange = labels.length;
|
|
33
|
-
|
|
34
|
-
numberOfSteps = Math.round(graphRange / interval);
|
|
35
|
-
|
|
36
|
-
while (numberOfSteps > maxSteps) {
|
|
37
|
-
interval *= 2;
|
|
38
|
-
numberOfSteps = Math.round(graphRange / interval);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
42
|
return {
|
|
42
|
-
steps:
|
|
43
|
-
interval,
|
|
43
|
+
steps: this.labels.length,
|
|
44
|
+
interval: 1,
|
|
44
45
|
graphMin: range.minValue,
|
|
45
46
|
graphMax: range.maxValue,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
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
|
+
*/
|
|
49
58
|
draw(chartRect, labelOffset, stepInfo) {
|
|
50
59
|
const ctx = this.ctx;
|
|
51
|
-
const labels = this.
|
|
60
|
+
const labels = this.labels;
|
|
52
61
|
const aPos = {
|
|
53
62
|
x1: chartRect.x1 + labelOffset.left,
|
|
54
63
|
x2: chartRect.x2 - labelOffset.right,
|
|
@@ -57,12 +66,12 @@ class StepScale extends Scale {
|
|
|
57
66
|
};
|
|
58
67
|
|
|
59
68
|
const steps = stepInfo.steps;
|
|
60
|
-
const interval = stepInfo.interval;
|
|
61
69
|
|
|
62
70
|
const startPoint = aPos[this.units.rectStart];
|
|
63
71
|
const endPoint = aPos[this.units.rectEnd];
|
|
64
72
|
const offsetPoint = aPos[this.units.rectOffset(this.position)];
|
|
65
73
|
const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
|
|
74
|
+
const maxWidth = chartRect.chartWidth / (this.labels.length + 2);
|
|
66
75
|
|
|
67
76
|
// label font 설정
|
|
68
77
|
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
@@ -103,23 +112,15 @@ class StepScale extends Scale {
|
|
|
103
112
|
|
|
104
113
|
let labelText;
|
|
105
114
|
let labelPoint;
|
|
106
|
-
let prevIndex = 0;
|
|
107
115
|
|
|
108
|
-
labels.
|
|
116
|
+
labels.forEach((item, index) => {
|
|
109
117
|
labelCenter = Math.round(startPoint + (labelGap * index));
|
|
110
118
|
linePosition = labelCenter + aliasPixel;
|
|
111
|
-
labelText = this.getLabelFormat(
|
|
119
|
+
labelText = this.getLabelFormat(item, maxWidth);
|
|
112
120
|
|
|
113
121
|
if (this.type === 'x') {
|
|
114
122
|
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
115
|
-
|
|
116
|
-
if (prev.label !== labelText && (index === 0 || index - prev.index > interval)) {
|
|
117
|
-
prevIndex = index;
|
|
118
|
-
ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
|
|
122
|
-
}
|
|
123
|
+
ctx.fillText(labelText, labelCenter + (labelGap / 2), labelPoint);
|
|
123
124
|
|
|
124
125
|
if (index > 0 && this.showGrid) {
|
|
125
126
|
ctx.moveTo(linePosition, offsetPoint);
|
|
@@ -127,14 +128,7 @@ class StepScale extends Scale {
|
|
|
127
128
|
}
|
|
128
129
|
} else {
|
|
129
130
|
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
130
|
-
|
|
131
|
-
if (prev.label !== labelText && (index === 0 || index - prev.index > interval)) {
|
|
132
|
-
prevIndex = index;
|
|
133
|
-
ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
|
|
137
|
-
}
|
|
131
|
+
ctx.fillText(labelText, labelPoint, labelCenter + (labelGap / 2));
|
|
138
132
|
|
|
139
133
|
if (index > 0 && this.showGrid) {
|
|
140
134
|
ctx.moveTo(offsetPoint, linePosition);
|
|
@@ -142,18 +136,61 @@ class StepScale extends Scale {
|
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
ctx.stroke();
|
|
145
|
-
|
|
146
|
-
return { label: labelText, index: prevIndex };
|
|
147
|
-
}, { label: '', index: prevIndex });
|
|
139
|
+
});
|
|
148
140
|
|
|
149
141
|
ctx.closePath();
|
|
150
142
|
}
|
|
151
143
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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;
|
|
155
185
|
}
|
|
156
|
-
|
|
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;
|
|
157
194
|
}
|
|
158
195
|
}
|
|
159
196
|
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { TIME_INTERVALS } from '../helpers/helpers.constant';
|
|
3
|
+
import Scale from './scale';
|
|
4
|
+
import Util from '../helpers/helpers.util';
|
|
5
|
+
|
|
6
|
+
class TimeCategoryScale extends Scale {
|
|
7
|
+
constructor(type, opt, ctx, labels) {
|
|
8
|
+
super(type, opt, ctx);
|
|
9
|
+
this.labels = labels;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Transforming label by designated format
|
|
14
|
+
* @param {number} value label value
|
|
15
|
+
*
|
|
16
|
+
* @returns {string} formatted label
|
|
17
|
+
*/
|
|
18
|
+
getLabelFormat(value) {
|
|
19
|
+
return moment(value).format(this.timeFormat);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Calculate interval
|
|
24
|
+
* @param {object} range range information
|
|
25
|
+
*
|
|
26
|
+
* @returns {number} interval
|
|
27
|
+
*/
|
|
28
|
+
getInterval(range) {
|
|
29
|
+
const max = range.maxValue;
|
|
30
|
+
const min = range.minValue;
|
|
31
|
+
const step = range.maxSteps;
|
|
32
|
+
|
|
33
|
+
if (this.interval) {
|
|
34
|
+
if (typeof this.interval === 'string') {
|
|
35
|
+
return TIME_INTERVALS[this.interval].size;
|
|
36
|
+
} else if (typeof this.interval === 'object') {
|
|
37
|
+
return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
|
|
38
|
+
} else if (typeof this.interval === 'number') {
|
|
39
|
+
return this.interval;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return Math.ceil((max - min) / step);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* With range information, calculate how many labels in axis
|
|
47
|
+
* @param {object} range min/max information
|
|
48
|
+
*
|
|
49
|
+
* @returns {object} steps, interval, min/max graph value
|
|
50
|
+
*/
|
|
51
|
+
calculateSteps(range) {
|
|
52
|
+
const { maxValue, minValue, maxSteps } = range;
|
|
53
|
+
const rawInterval = this.getInterval(range);
|
|
54
|
+
|
|
55
|
+
let interval = rawInterval;
|
|
56
|
+
let increase = minValue;
|
|
57
|
+
let numberOfSteps;
|
|
58
|
+
|
|
59
|
+
while (increase < maxValue) {
|
|
60
|
+
increase += interval;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const graphMax = increase > maxValue ? maxValue : increase;
|
|
64
|
+
const graphMin = minValue;
|
|
65
|
+
const graphRange = graphMax - graphMin;
|
|
66
|
+
|
|
67
|
+
numberOfSteps = Math.round(graphRange / interval) + 1;
|
|
68
|
+
const oriSteps = numberOfSteps;
|
|
69
|
+
|
|
70
|
+
if (maxValue === 1) {
|
|
71
|
+
interval = 0.2;
|
|
72
|
+
numberOfSteps = 5;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
while (numberOfSteps > maxSteps) {
|
|
76
|
+
interval *= 2;
|
|
77
|
+
numberOfSteps = Math.round(graphRange / interval);
|
|
78
|
+
interval = Math.ceil(graphRange / numberOfSteps);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (graphMax - graphMin > (numberOfSteps * interval)) {
|
|
82
|
+
interval = Math.ceil((graphMax - graphMin) / numberOfSteps);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
steps: numberOfSteps,
|
|
88
|
+
oriSteps,
|
|
89
|
+
interval,
|
|
90
|
+
rawInterval,
|
|
91
|
+
graphMin,
|
|
92
|
+
graphMax,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Draw axis
|
|
98
|
+
* @param {object} chartRect min/max information
|
|
99
|
+
* @param {object} labelOffset label offset information
|
|
100
|
+
* @param {object} stepInfo label steps information
|
|
101
|
+
*
|
|
102
|
+
* @returns {undefined}
|
|
103
|
+
*/
|
|
104
|
+
draw(chartRect, labelOffset, stepInfo) {
|
|
105
|
+
const ctx = this.ctx;
|
|
106
|
+
const labels = this.labels;
|
|
107
|
+
const aPos = {
|
|
108
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
109
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
110
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
111
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const steps = stepInfo.steps;
|
|
115
|
+
const axisMin = stepInfo.graphMin;
|
|
116
|
+
const axisMax = stepInfo.graphMax;
|
|
117
|
+
const stepValue = stepInfo.rawInterval;
|
|
118
|
+
const oriSteps = stepInfo.oriSteps;
|
|
119
|
+
const count = Math.round(oriSteps / steps);
|
|
120
|
+
|
|
121
|
+
let startPoint = aPos[this.units.rectStart];
|
|
122
|
+
const endPoint = aPos[this.units.rectEnd];
|
|
123
|
+
const offsetPoint = aPos[this.units.rectOffset(this.position)];
|
|
124
|
+
const offsetCounterPoint = aPos[this.units.rectOffsetCounter(this.position)];
|
|
125
|
+
|
|
126
|
+
// label font 설정
|
|
127
|
+
ctx.font = Util.getLabelStyle(this.labelStyle);
|
|
128
|
+
|
|
129
|
+
if (this.type === 'x') {
|
|
130
|
+
ctx.textAlign = 'center';
|
|
131
|
+
ctx.textBaseline = this.position === 'top' ? 'bottom' : 'top';
|
|
132
|
+
} else {
|
|
133
|
+
ctx.textAlign = this.position === 'left' ? 'right' : 'left';
|
|
134
|
+
ctx.textBaseline = 'middle';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ctx.fillStyle = this.labelStyle.color;
|
|
138
|
+
ctx.lineWidth = 1;
|
|
139
|
+
const aliasPixel = Util.aliasPixel(ctx.lineWidth);
|
|
140
|
+
|
|
141
|
+
ctx.beginPath();
|
|
142
|
+
ctx.strokeStyle = this.axisLineColor;
|
|
143
|
+
if (this.type === 'x') {
|
|
144
|
+
ctx.moveTo(startPoint, offsetPoint + aliasPixel);
|
|
145
|
+
ctx.lineTo(endPoint, offsetPoint + aliasPixel);
|
|
146
|
+
} else {
|
|
147
|
+
ctx.moveTo(offsetPoint + aliasPixel, startPoint);
|
|
148
|
+
ctx.lineTo(offsetPoint + aliasPixel, endPoint);
|
|
149
|
+
}
|
|
150
|
+
ctx.stroke();
|
|
151
|
+
ctx.closePath();
|
|
152
|
+
|
|
153
|
+
if (steps === 0 || axisMin === null) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const graphGap = (endPoint - startPoint) / (labels.length || 1);
|
|
158
|
+
if (this.categoryMode) {
|
|
159
|
+
startPoint += Math.ceil(graphGap / 2) - 2;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const ticks = [];
|
|
163
|
+
let labelCenter = null;
|
|
164
|
+
let linePosition = null;
|
|
165
|
+
|
|
166
|
+
ctx.beginPath();
|
|
167
|
+
ctx.strokeStyle = this.gridLineColor;
|
|
168
|
+
|
|
169
|
+
let labelText;
|
|
170
|
+
for (let ix = 0; ix < oriSteps; ix += count) {
|
|
171
|
+
ticks[ix] = axisMin + (ix * stepValue);
|
|
172
|
+
|
|
173
|
+
labelCenter = Math.round(startPoint + (graphGap * ix));
|
|
174
|
+
linePosition = labelCenter + aliasPixel;
|
|
175
|
+
labelText = this.getLabelFormat(Math.min(axisMax, ticks[ix]));
|
|
176
|
+
|
|
177
|
+
let labelPoint;
|
|
178
|
+
|
|
179
|
+
if (this.type === 'x') {
|
|
180
|
+
labelPoint = this.position === 'top' ? offsetPoint - 10 : offsetPoint + 10;
|
|
181
|
+
ctx.fillText(labelText, labelCenter, labelPoint);
|
|
182
|
+
|
|
183
|
+
if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
|
|
184
|
+
ctx.moveTo(linePosition, offsetPoint);
|
|
185
|
+
ctx.lineTo(linePosition, offsetCounterPoint);
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
labelPoint = this.position === 'left' ? offsetPoint - 10 : offsetPoint + 10;
|
|
189
|
+
ctx.fillText(labelText, labelPoint, labelCenter);
|
|
190
|
+
|
|
191
|
+
if ((ix !== 0 && ix < oriSteps && this.showGrid)) {
|
|
192
|
+
ctx.moveTo(offsetPoint, linePosition);
|
|
193
|
+
ctx.lineTo(offsetCounterPoint, linePosition);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
ctx.stroke();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
ctx.closePath();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default TimeCategoryScale;
|
|
@@ -3,17 +3,35 @@ import { TIME_INTERVALS } from '../helpers/helpers.constant';
|
|
|
3
3
|
import Scale from './scale';
|
|
4
4
|
|
|
5
5
|
class TimeScale extends Scale {
|
|
6
|
+
/**
|
|
7
|
+
* Transforming label by designated format
|
|
8
|
+
* @param {number} value label value
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} formatted label
|
|
11
|
+
*/
|
|
6
12
|
getLabelFormat(value) {
|
|
7
13
|
return moment(value).format(this.timeFormat);
|
|
8
14
|
}
|
|
9
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Calculate interval
|
|
18
|
+
* @param {object} range range information
|
|
19
|
+
*
|
|
20
|
+
* @returns {number} interval
|
|
21
|
+
*/
|
|
10
22
|
getInterval(range) {
|
|
11
23
|
const max = range.maxValue;
|
|
12
24
|
const min = range.minValue;
|
|
13
25
|
const step = range.maxSteps;
|
|
14
26
|
|
|
15
27
|
if (this.interval) {
|
|
16
|
-
|
|
28
|
+
if (typeof this.interval === 'string') {
|
|
29
|
+
return TIME_INTERVALS[this.interval].size;
|
|
30
|
+
} else if (typeof this.interval === 'object') {
|
|
31
|
+
return this.interval.time * TIME_INTERVALS[this.interval.unit].size;
|
|
32
|
+
} else if (typeof this.interval === 'number') {
|
|
33
|
+
return this.interval;
|
|
34
|
+
}
|
|
17
35
|
}
|
|
18
36
|
return Math.ceil((max - min) / step);
|
|
19
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<slot/>
|
|
3
|
+
<slot />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
@@ -41,16 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
mounted() {
|
|
43
43
|
this.initValue();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
bindValue.push(targetValue);
|
|
49
|
-
} else if (!e.currentTarget.checked && bindValue.indexOf(targetValue) > -1) {
|
|
50
|
-
bindValue.splice(bindValue.indexOf(targetValue), 1);
|
|
51
|
-
}
|
|
52
|
-
this.$parent.$emit('input', bindValue);
|
|
53
|
-
});
|
|
44
|
+
this.$on('on-change', this.onChange);
|
|
45
|
+
},
|
|
46
|
+
beforeDestroy() {
|
|
47
|
+
this.$off('on-change', this.onChange);
|
|
54
48
|
},
|
|
55
49
|
methods: {
|
|
56
50
|
initValue(array) {
|
|
@@ -64,6 +58,16 @@
|
|
|
64
58
|
});
|
|
65
59
|
}
|
|
66
60
|
},
|
|
61
|
+
onChange(e) {
|
|
62
|
+
const bindValue = this.bindValue;
|
|
63
|
+
const targetValue = e.target.value;
|
|
64
|
+
if (e.currentTarget.checked && bindValue.indexOf(targetValue) === -1) {
|
|
65
|
+
bindValue.push(targetValue);
|
|
66
|
+
} else if (!e.currentTarget.checked && bindValue.indexOf(targetValue) > -1) {
|
|
67
|
+
bindValue.splice(bindValue.indexOf(targetValue), 1);
|
|
68
|
+
}
|
|
69
|
+
this.$parent.$emit('input', bindValue);
|
|
70
|
+
},
|
|
67
71
|
},
|
|
68
72
|
};
|
|
69
73
|
</script>
|