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
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { numberWithComma } from '@/common/utils';
|
|
2
|
+
import Canvas from '../helpers/helpers.canvas';
|
|
3
|
+
|
|
4
|
+
const modules = {
|
|
5
|
+
/**
|
|
6
|
+
* Draw TextTip with hitInfo
|
|
7
|
+
* @param {object} [hitInfo=undefined] mouse hit information
|
|
8
|
+
*
|
|
9
|
+
* @returns {undefined}
|
|
10
|
+
*/
|
|
11
|
+
drawTip(hitInfo) {
|
|
12
|
+
const opt = this.options;
|
|
13
|
+
const isHorizontal = !!opt.horizontal;
|
|
14
|
+
const maxTipOpt = opt.maxTip;
|
|
15
|
+
const selectItemOpt = opt.selectItem;
|
|
16
|
+
|
|
17
|
+
if (maxTipOpt.use || selectItemOpt.use) {
|
|
18
|
+
const maxSID = this.minMax[isHorizontal ? 'x' : 'y'][0].maxSID;
|
|
19
|
+
const selSID = hitInfo && hitInfo.sId ? hitInfo.sId : maxSID;
|
|
20
|
+
|
|
21
|
+
const maxArgs = this.calculateTipInfo(this.seriesList[maxSID], 'max', null);
|
|
22
|
+
const selArgs = this.calculateTipInfo(this.seriesList[selSID], 'sel', hitInfo);
|
|
23
|
+
|
|
24
|
+
if (maxTipOpt.use && maxArgs) {
|
|
25
|
+
this.drawTextTip({ opt: maxTipOpt, tipType: 'max', ...maxArgs });
|
|
26
|
+
|
|
27
|
+
if (maxTipOpt.showIndicator) {
|
|
28
|
+
this.drawFixedIndicator({ opt: maxTipOpt, ...maxArgs });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (selectItemOpt.use && selArgs) {
|
|
33
|
+
let isSamePos = false;
|
|
34
|
+
|
|
35
|
+
if (maxTipOpt.use && maxArgs && maxArgs.dp === selArgs.dp) {
|
|
36
|
+
isSamePos = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (selectItemOpt.showTextTip || selectItemOpt.showTip) {
|
|
40
|
+
this.drawTextTip({ opt: selectItemOpt, tipType: 'sel', isSamePos, ...selArgs });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (selectItemOpt.showIndicator) {
|
|
44
|
+
this.drawFixedIndicator({ opt: selectItemOpt, ...selArgs });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Calculate tip size and contents
|
|
52
|
+
* @param {object} series series information (max series or selected series)
|
|
53
|
+
* @param {string} tipType tip type [sel = user select, max = max value]
|
|
54
|
+
* @param {object} hitInfo mouse hit information
|
|
55
|
+
*
|
|
56
|
+
* @returns {object} size and tip contents
|
|
57
|
+
*/
|
|
58
|
+
calculateTipInfo(series, tipType, hitInfo) {
|
|
59
|
+
if (!series) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const isHorizontal = !!this.options.horizontal;
|
|
64
|
+
const lastTip = this.lastTip;
|
|
65
|
+
const chartRect = this.chartRect;
|
|
66
|
+
const labelOffset = this.labelOffset;
|
|
67
|
+
const graphPos = {
|
|
68
|
+
x1: chartRect.x1 + labelOffset.left,
|
|
69
|
+
x2: chartRect.x2 - labelOffset.right,
|
|
70
|
+
y1: chartRect.y1 + labelOffset.top,
|
|
71
|
+
y2: chartRect.y2 - labelOffset.bottom,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const yArea = chartRect.chartHeight - (labelOffset.top + labelOffset.bottom);
|
|
75
|
+
const xArea = chartRect.chartWidth - (labelOffset.left + labelOffset.right);
|
|
76
|
+
|
|
77
|
+
const graphX = this.axesSteps.x[series.xAxisIndex];
|
|
78
|
+
const graphY = this.axesSteps.y[series.yAxisIndex];
|
|
79
|
+
|
|
80
|
+
const xsp = graphPos.x1;
|
|
81
|
+
const xep = graphPos.x2;
|
|
82
|
+
const ysp = graphPos.y2;
|
|
83
|
+
|
|
84
|
+
const { type, size } = series;
|
|
85
|
+
const { maxDomain, maxDomainIndex } = series.minMax;
|
|
86
|
+
const seriesMaxY = series.minMax.maxY;
|
|
87
|
+
|
|
88
|
+
if (maxDomain === null || maxDomainIndex < 0) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let ldata = type === 'bar' ? maxDomainIndex : maxDomain;
|
|
93
|
+
|
|
94
|
+
if (tipType === 'sel') {
|
|
95
|
+
if (hitInfo && hitInfo.label !== null) {
|
|
96
|
+
lastTip.pos = type === 'bar' ? hitInfo.maxIndex : hitInfo.label;
|
|
97
|
+
ldata = lastTip.pos;
|
|
98
|
+
} else if (lastTip.pos !== null) {
|
|
99
|
+
ldata = lastTip.pos;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let value = seriesMaxY;
|
|
104
|
+
|
|
105
|
+
if (tipType === 'sel') {
|
|
106
|
+
if (hitInfo && hitInfo.value !== null) {
|
|
107
|
+
value = hitInfo.useStack ? hitInfo.acc : hitInfo.value;
|
|
108
|
+
lastTip.value = value;
|
|
109
|
+
} else if (lastTip.value !== null) {
|
|
110
|
+
value = lastTip.value;
|
|
111
|
+
} else if (lastTip.pos !== null) {
|
|
112
|
+
const item = type === 'bar'
|
|
113
|
+
? this.getItemByLabelIndex(lastTip.pos) : this.getItemByLabel(lastTip.pos);
|
|
114
|
+
|
|
115
|
+
value = item.useStack ? item.acc : item.value;
|
|
116
|
+
lastTip.value = value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let cp;
|
|
121
|
+
let halfBarSize;
|
|
122
|
+
let dp;
|
|
123
|
+
|
|
124
|
+
if (type === 'bar') {
|
|
125
|
+
if (isHorizontal) {
|
|
126
|
+
halfBarSize = Math.round(size.h / 2);
|
|
127
|
+
cp = ysp - (size.cat * ldata) - size.cPad;
|
|
128
|
+
dp = (cp - ((size.bar * size.ix) - (size.h + size.bPad))) + halfBarSize;
|
|
129
|
+
} else {
|
|
130
|
+
halfBarSize = Math.round(size.w / 2);
|
|
131
|
+
cp = xsp + (size.cat * ldata) + size.cPad;
|
|
132
|
+
dp = cp + ((size.bar * size.ix) - (size.w + size.bPad)) + halfBarSize;
|
|
133
|
+
}
|
|
134
|
+
} else if (type === 'line') {
|
|
135
|
+
dp = Canvas.calculateX(
|
|
136
|
+
ldata,
|
|
137
|
+
graphX.graphMin,
|
|
138
|
+
graphX.graphMax,
|
|
139
|
+
xArea - size.comboOffset,
|
|
140
|
+
xsp + (size.comboOffset / 2),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const sizeObj = { xArea, yArea, graphX, graphY, xsp, xep, ysp };
|
|
145
|
+
const dataObj = { dp, value, text: numberWithComma(value), type };
|
|
146
|
+
|
|
147
|
+
return { ...sizeObj, ...dataObj };
|
|
148
|
+
},
|
|
149
|
+
drawFixedIndicator(param) {
|
|
150
|
+
const isHorizontal = !!this.options.horizontal;
|
|
151
|
+
const ctx = this.bufferCtx;
|
|
152
|
+
const { graphX, graphY, xArea, yArea, xsp, ysp, dp, type, value, opt } = param;
|
|
153
|
+
const offset = type === 'bar' ? 0 : 3;
|
|
154
|
+
|
|
155
|
+
let gp;
|
|
156
|
+
|
|
157
|
+
if (opt.fixedPosTop) {
|
|
158
|
+
if (isHorizontal) {
|
|
159
|
+
gp = Canvas.calculateX(graphX.graphMax, graphX.graphMin, graphX.graphMax, xArea, xsp);
|
|
160
|
+
} else {
|
|
161
|
+
gp = Canvas.calculateY(graphY.graphMax, graphY.graphMin, graphY.graphMax, yArea, ysp);
|
|
162
|
+
gp -= offset;
|
|
163
|
+
}
|
|
164
|
+
} else if (isHorizontal) {
|
|
165
|
+
gp = Canvas.calculateX(value, graphX.graphMin, graphX.graphMax, xArea, xsp);
|
|
166
|
+
} else {
|
|
167
|
+
gp = Canvas.calculateY(value, graphY.graphMin, graphY.graphMax, yArea, ysp);
|
|
168
|
+
gp -= offset;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (dp === null || dp < xsp) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
ctx.beginPath();
|
|
176
|
+
ctx.save();
|
|
177
|
+
ctx.strokeStyle = opt.indicatorColor;
|
|
178
|
+
ctx.lineWidth = 2;
|
|
179
|
+
|
|
180
|
+
if (isHorizontal) {
|
|
181
|
+
ctx.moveTo(xsp, dp);
|
|
182
|
+
ctx.lineTo(gp, dp);
|
|
183
|
+
} else {
|
|
184
|
+
ctx.moveTo(dp, ysp);
|
|
185
|
+
ctx.lineTo(dp, gp);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
ctx.stroke();
|
|
189
|
+
ctx.restore();
|
|
190
|
+
ctx.closePath();
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Calculate x, y position to draw text tip
|
|
195
|
+
* @param {object} param object for drawing text tip
|
|
196
|
+
*
|
|
197
|
+
* @returns {undefined}
|
|
198
|
+
*/
|
|
199
|
+
drawTextTip(param) {
|
|
200
|
+
const isHorizontal = !!this.options.horizontal;
|
|
201
|
+
const ctx = this.bufferCtx;
|
|
202
|
+
const { graphX, graphY, xArea, yArea, xsp, xep, ysp } = param;
|
|
203
|
+
const { dp, value, text, opt, type, tipType, isSamePos } = param;
|
|
204
|
+
|
|
205
|
+
const arrowSize = 4;
|
|
206
|
+
const maxTipHeight = 20;
|
|
207
|
+
const borderRadius = 4;
|
|
208
|
+
const offset = type === 'bar' ? 4 : 6;
|
|
209
|
+
|
|
210
|
+
let gp;
|
|
211
|
+
let tdp = dp;
|
|
212
|
+
|
|
213
|
+
if (opt.fixedPosTop) {
|
|
214
|
+
if (isHorizontal) {
|
|
215
|
+
gp = Canvas.calculateX(graphX.graphMax, graphX.graphMin, graphX.graphMax, xArea, xsp);
|
|
216
|
+
gp += offset;
|
|
217
|
+
} else {
|
|
218
|
+
gp = Canvas.calculateY(graphY.graphMax, graphY.graphMin, graphY.graphMax, yArea, ysp);
|
|
219
|
+
gp -= offset;
|
|
220
|
+
}
|
|
221
|
+
} else if (isHorizontal) {
|
|
222
|
+
gp = Canvas.calculateX(value, graphX.graphMin, graphX.graphMax, xArea, xsp);
|
|
223
|
+
gp += offset;
|
|
224
|
+
} else {
|
|
225
|
+
gp = Canvas.calculateY(value, graphY.graphMin, graphY.graphMax, yArea, ysp);
|
|
226
|
+
gp -= offset;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
let maxTipType = 'center';
|
|
230
|
+
|
|
231
|
+
ctx.save();
|
|
232
|
+
ctx.font = 'normal normal bold 14px Roboto';
|
|
233
|
+
const maxTipWidth = Math.round(Math.max(ctx.measureText(text).width + 12, 40));
|
|
234
|
+
|
|
235
|
+
if (dp + (maxTipWidth / 2) > xep - 10) {
|
|
236
|
+
maxTipType = 'right';
|
|
237
|
+
tdp -= (maxTipWidth / 2) - (arrowSize * 2);
|
|
238
|
+
} else if (dp - (maxTipWidth / 2) < xsp + 10) {
|
|
239
|
+
maxTipType = 'left';
|
|
240
|
+
tdp += (maxTipWidth / 2) - (arrowSize * 2);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
ctx.restore();
|
|
244
|
+
|
|
245
|
+
if (opt.showTextTip || tipType === 'max') {
|
|
246
|
+
this.showTextTip({
|
|
247
|
+
context: ctx,
|
|
248
|
+
type: maxTipType,
|
|
249
|
+
width: maxTipWidth,
|
|
250
|
+
height: maxTipHeight,
|
|
251
|
+
x: tdp,
|
|
252
|
+
y: gp,
|
|
253
|
+
opt,
|
|
254
|
+
arrowSize,
|
|
255
|
+
borderRadius,
|
|
256
|
+
text,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (opt.showTip && tipType === 'sel') {
|
|
261
|
+
this.showTip({
|
|
262
|
+
context: ctx,
|
|
263
|
+
x: dp,
|
|
264
|
+
y: gp,
|
|
265
|
+
opt,
|
|
266
|
+
arrowSize,
|
|
267
|
+
isSamePos,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Draw text tip
|
|
274
|
+
* @param {object} param object for drawing text tip
|
|
275
|
+
*
|
|
276
|
+
* @returns {undefined}
|
|
277
|
+
*/
|
|
278
|
+
showTextTip(param) {
|
|
279
|
+
const { type, width, height, x, y, arrowSize, borderRadius, text, opt } = param;
|
|
280
|
+
const ctx = param.context;
|
|
281
|
+
|
|
282
|
+
const sx = x - (width / 2);
|
|
283
|
+
const ex = x + (width / 2);
|
|
284
|
+
const sy = y - height;
|
|
285
|
+
const ey = y;
|
|
286
|
+
|
|
287
|
+
ctx.save();
|
|
288
|
+
ctx.font = 'normal normal bold 14px Roboto';
|
|
289
|
+
|
|
290
|
+
ctx.fillStyle = opt.tipBackground;
|
|
291
|
+
ctx.shadowBlur = 0;
|
|
292
|
+
|
|
293
|
+
ctx.beginPath();
|
|
294
|
+
ctx.moveTo(sx + borderRadius, sy);
|
|
295
|
+
ctx.quadraticCurveTo(sx, sy, sx, sy + borderRadius);
|
|
296
|
+
ctx.lineTo(sx, ey - borderRadius);
|
|
297
|
+
ctx.quadraticCurveTo(sx, ey, sx + borderRadius, ey);
|
|
298
|
+
|
|
299
|
+
if (type === 'left') {
|
|
300
|
+
ctx.lineTo(sx + borderRadius + arrowSize, ey + arrowSize);
|
|
301
|
+
ctx.lineTo(sx + borderRadius + (arrowSize * 2), ey);
|
|
302
|
+
ctx.lineTo(ex - borderRadius, ey);
|
|
303
|
+
} else if (type === 'right') {
|
|
304
|
+
ctx.lineTo(ex - (arrowSize * 2) - borderRadius, ey);
|
|
305
|
+
ctx.lineTo(ex - arrowSize - borderRadius, ey + arrowSize);
|
|
306
|
+
ctx.lineTo(ex - borderRadius, ey);
|
|
307
|
+
} else {
|
|
308
|
+
ctx.lineTo(x - arrowSize, ey);
|
|
309
|
+
ctx.lineTo(x, ey + arrowSize);
|
|
310
|
+
ctx.lineTo(x + arrowSize, ey);
|
|
311
|
+
ctx.lineTo(ex - borderRadius, ey);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
ctx.quadraticCurveTo(ex, ey, ex, ey - borderRadius);
|
|
315
|
+
ctx.lineTo(ex, sy + borderRadius);
|
|
316
|
+
ctx.quadraticCurveTo(ex, sy, ex - borderRadius, sy);
|
|
317
|
+
ctx.lineTo(sx + borderRadius, sy);
|
|
318
|
+
ctx.closePath();
|
|
319
|
+
ctx.fill();
|
|
320
|
+
ctx.restore();
|
|
321
|
+
ctx.save();
|
|
322
|
+
ctx.font = 'normal normal bold 14px Roboto';
|
|
323
|
+
ctx.fillStyle = opt.tipTextColor;
|
|
324
|
+
ctx.textBaseline = 'middle';
|
|
325
|
+
ctx.textAlign = 'center';
|
|
326
|
+
ctx.fillText(`${text}`, x, sy + (height / 2));
|
|
327
|
+
ctx.restore();
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Draw arrow tip
|
|
332
|
+
* @param {object} param object for drawing arrow tip
|
|
333
|
+
*
|
|
334
|
+
* @returns {undefined}
|
|
335
|
+
*/
|
|
336
|
+
showTip(param) {
|
|
337
|
+
const { x, y, opt, isSamePos } = param;
|
|
338
|
+
const ctx = param.context;
|
|
339
|
+
const offset = isSamePos ? 24 : 0;
|
|
340
|
+
const cy = y - offset;
|
|
341
|
+
ctx.save();
|
|
342
|
+
|
|
343
|
+
ctx.fillStyle = opt.tipBackground;
|
|
344
|
+
ctx.beginPath();
|
|
345
|
+
ctx.moveTo(x, cy);
|
|
346
|
+
ctx.lineTo(x + 6, cy - 6);
|
|
347
|
+
ctx.lineTo(x - 6, cy - 6);
|
|
348
|
+
ctx.lineTo(x, cy);
|
|
349
|
+
ctx.closePath();
|
|
350
|
+
ctx.fill();
|
|
351
|
+
|
|
352
|
+
ctx.restore();
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export default modules;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
/**
|
|
3
|
+
* Calculate X position
|
|
4
|
+
* @param {any} value graph value
|
|
5
|
+
* @param {number} min min value
|
|
6
|
+
* @param {number} max max value
|
|
7
|
+
* @param {number} area height for axis
|
|
8
|
+
* @param {number} startPoint startPoint
|
|
9
|
+
*
|
|
10
|
+
* @returns {any} position
|
|
11
|
+
*/
|
|
2
12
|
calculateX(value, min, max, area, startPoint = 0) {
|
|
3
13
|
if (value === null) {
|
|
4
14
|
return null;
|
|
@@ -12,6 +22,35 @@ export default {
|
|
|
12
22
|
return Math.ceil(startPoint + (scalingFactor * (value - min)));
|
|
13
23
|
},
|
|
14
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Calculate X position (for timebar)
|
|
27
|
+
* @param {any} value graph value
|
|
28
|
+
* @param {number} min min value
|
|
29
|
+
* @param {number} max max value
|
|
30
|
+
* @param {number} area height for axis
|
|
31
|
+
* @param {number} startPoint startPoint
|
|
32
|
+
*
|
|
33
|
+
* @returns {any} position
|
|
34
|
+
*/
|
|
35
|
+
calculateSubX(value, min, max, area, startPoint = 0) {
|
|
36
|
+
if (value === null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const scalingFactor = area / (max - min);
|
|
41
|
+
return Math.ceil(startPoint + (scalingFactor * (value - min)));
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Calculate Y position
|
|
46
|
+
* @param {any} value graph value
|
|
47
|
+
* @param {number} min min value
|
|
48
|
+
* @param {number} max max value
|
|
49
|
+
* @param {number} area height for axis
|
|
50
|
+
* @param {number} startPoint startPoint
|
|
51
|
+
*
|
|
52
|
+
* @returns {any} position
|
|
53
|
+
*/
|
|
15
54
|
calculateY(value, min, max, area, startPoint = 0) {
|
|
16
55
|
let calcY;
|
|
17
56
|
|
|
@@ -32,6 +71,16 @@ export default {
|
|
|
32
71
|
return Math.floor(calcY);
|
|
33
72
|
},
|
|
34
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Draw point for chart
|
|
76
|
+
* @param {object} ctx canvas context
|
|
77
|
+
* @param {string} style point style
|
|
78
|
+
* @param {number} radius radius
|
|
79
|
+
* @param {number} x x position
|
|
80
|
+
* @param {number} y y position
|
|
81
|
+
*
|
|
82
|
+
* @returns {undefined}
|
|
83
|
+
*/
|
|
35
84
|
drawPoint(ctx, style, radius, x, y) {
|
|
36
85
|
let edgeLength;
|
|
37
86
|
let xOffset;
|
|
@@ -140,4 +189,49 @@ export default {
|
|
|
140
189
|
|
|
141
190
|
ctx.stroke();
|
|
142
191
|
},
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Draw roundedRect point for chart
|
|
195
|
+
* @param {object} ctx canvas context
|
|
196
|
+
* @param {number} x x position
|
|
197
|
+
* @param {number} y y position
|
|
198
|
+
* @param {string} width width
|
|
199
|
+
* @param {number} height height
|
|
200
|
+
* @param {number} radius radius
|
|
201
|
+
*
|
|
202
|
+
* @returns {undefined}
|
|
203
|
+
*/
|
|
204
|
+
roundedRect(ctx, x, y, width, height, radius) {
|
|
205
|
+
const pi = Math.PI;
|
|
206
|
+
const halfPi = pi / 2;
|
|
207
|
+
|
|
208
|
+
if (radius) {
|
|
209
|
+
const r = Math.min(radius, height / 2, width / 2);
|
|
210
|
+
const left = x + r;
|
|
211
|
+
const top = y + r;
|
|
212
|
+
const right = (x + width) - r;
|
|
213
|
+
const bottom = (y + height) - r;
|
|
214
|
+
|
|
215
|
+
ctx.moveTo(x, top);
|
|
216
|
+
if (left < right && top < bottom) {
|
|
217
|
+
ctx.arc(left, top, r, -pi, -halfPi);
|
|
218
|
+
ctx.arc(right, top, r, -halfPi, 0);
|
|
219
|
+
ctx.arc(right, bottom, r, 0, halfPi);
|
|
220
|
+
ctx.arc(left, bottom, r, halfPi, pi);
|
|
221
|
+
} else if (left < right) {
|
|
222
|
+
ctx.moveTo(left, y);
|
|
223
|
+
ctx.arc(right, top, r, -halfPi, halfPi);
|
|
224
|
+
ctx.arc(left, top, r, halfPi, pi + halfPi);
|
|
225
|
+
} else if (top < bottom) {
|
|
226
|
+
ctx.arc(left, top, r, -pi, 0);
|
|
227
|
+
ctx.arc(left, bottom, r, 0, pi);
|
|
228
|
+
} else {
|
|
229
|
+
ctx.arc(left, top, r, -pi, pi);
|
|
230
|
+
}
|
|
231
|
+
ctx.closePath();
|
|
232
|
+
ctx.moveTo(x, y);
|
|
233
|
+
} else {
|
|
234
|
+
ctx.rect(x, y, width, height);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
143
237
|
};
|
|
@@ -29,16 +29,20 @@ export const COLOR = [
|
|
|
29
29
|
export const LINE_OPTION = {
|
|
30
30
|
show: true,
|
|
31
31
|
highlight: {
|
|
32
|
-
|
|
32
|
+
defaultSize: 4,
|
|
33
|
+
maxSize: 6,
|
|
34
|
+
maxShadowSize: 10,
|
|
35
|
+
maxShadowOpacity: 0.4,
|
|
33
36
|
},
|
|
34
37
|
xAxisIndex: 0,
|
|
35
38
|
yAxisIndex: 0,
|
|
36
39
|
point: true,
|
|
37
|
-
pointSize:
|
|
40
|
+
pointSize: 3,
|
|
38
41
|
pointStyle: '',
|
|
39
42
|
lineWidth: 2,
|
|
40
43
|
fill: false,
|
|
41
44
|
fillOpacity: 0.4,
|
|
45
|
+
showLegend: true,
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
export const BAR_OPTION = {
|
|
@@ -49,25 +53,40 @@ export const BAR_OPTION = {
|
|
|
49
53
|
xAxisIndex: 0,
|
|
50
54
|
yAxisIndex: 0,
|
|
51
55
|
category: true,
|
|
56
|
+
showLegend: true,
|
|
57
|
+
showValue: {
|
|
58
|
+
use: false,
|
|
59
|
+
fontSize: 12,
|
|
60
|
+
textColor: '#000000',
|
|
61
|
+
},
|
|
52
62
|
};
|
|
53
63
|
|
|
64
|
+
export const PIE_OPTION = {
|
|
65
|
+
show: true,
|
|
66
|
+
showLegend: true,
|
|
67
|
+
};
|
|
54
68
|
|
|
55
69
|
export const AXIS_OPTION = {
|
|
56
70
|
min: null,
|
|
57
71
|
max: null,
|
|
58
72
|
autoScaleRatio: null,
|
|
59
73
|
startToZero: false,
|
|
74
|
+
showAxis: true,
|
|
75
|
+
axisLineColor: '#C9CFDC',
|
|
60
76
|
showGrid: true,
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
gridLineColor: '#C9CFDC',
|
|
78
|
+
showIndicator: false,
|
|
63
79
|
timeFormat: 'mm:ss',
|
|
64
80
|
range: null,
|
|
65
81
|
interval: null,
|
|
66
82
|
decimalPoint: null,
|
|
67
83
|
labelStyle: {
|
|
68
84
|
fontSize: 12,
|
|
69
|
-
color: '#
|
|
70
|
-
fontFamily: '
|
|
85
|
+
color: '#25262E',
|
|
86
|
+
fontFamily: 'Roboto',
|
|
87
|
+
fontWeight: 400,
|
|
88
|
+
fitWidth: false,
|
|
89
|
+
fitDir: 'right',
|
|
71
90
|
},
|
|
72
91
|
};
|
|
73
92
|
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
billions,
|
|
3
|
+
millions,
|
|
4
|
+
quadrillion,
|
|
5
|
+
trillion,
|
|
6
|
+
truthy,
|
|
7
|
+
} from '@/common/utils';
|
|
8
|
+
|
|
1
9
|
export default {
|
|
10
|
+
/**
|
|
11
|
+
* Transforming hex to rgb code
|
|
12
|
+
* @param {string} hex hex color code
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} rgb code
|
|
15
|
+
*/
|
|
2
16
|
hexToRgb(hex) {
|
|
3
17
|
if (!hex) {
|
|
4
18
|
return false;
|
|
@@ -13,63 +27,88 @@ export default {
|
|
|
13
27
|
return `${r},${g},${b}`;
|
|
14
28
|
},
|
|
15
29
|
|
|
30
|
+
/**
|
|
31
|
+
* To logarithmic scale, compute log value
|
|
32
|
+
* @param {number} value graph value
|
|
33
|
+
*
|
|
34
|
+
* @returns {number} computed value
|
|
35
|
+
*/
|
|
16
36
|
calculateMagnitude(value) {
|
|
17
37
|
return Math.floor(Math.log(value) / Math.LN10);
|
|
18
38
|
},
|
|
19
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Set alias pixel to deal with anti-aliasing
|
|
42
|
+
* @param {number} width line width
|
|
43
|
+
*
|
|
44
|
+
* @returns {number} computed value
|
|
45
|
+
*/
|
|
20
46
|
aliasPixel(width) {
|
|
21
|
-
return
|
|
47
|
+
return width % 2 === 0 ? 0 : 0.5;
|
|
22
48
|
},
|
|
23
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Create string for canvas font style
|
|
52
|
+
* @param {object} style style object by user
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} computed value
|
|
55
|
+
*/
|
|
24
56
|
getLabelStyle(style) {
|
|
25
|
-
return `normal ${style.fontSize}px ${style.fontFamily}`;
|
|
57
|
+
return `normal normal ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;
|
|
26
58
|
},
|
|
27
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Create sign format with number
|
|
62
|
+
* @param {number} value graph value
|
|
63
|
+
* @param {string} decimalPoint decimal point
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} signed value
|
|
66
|
+
*/
|
|
28
67
|
labelSignFormat(value, decimalPoint) {
|
|
68
|
+
const quad = quadrillion(1);
|
|
69
|
+
const trill = trillion(1);
|
|
70
|
+
const billi = billions(1);
|
|
71
|
+
const milli = millions(1);
|
|
72
|
+
const killo = 1000;
|
|
73
|
+
|
|
29
74
|
let label;
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
} else if (value >= 1000000000000) {
|
|
38
|
-
if (value % 1000000000000 === 0) {
|
|
39
|
-
label = `${(value / 1000000000000).toFixed(decimalPoint)}T`;
|
|
40
|
-
} else {
|
|
41
|
-
label = `${(value / 1000000000000).toFixed(1)}T`;
|
|
42
|
-
}
|
|
43
|
-
} else if (value >= 1000000000) {
|
|
44
|
-
if (value % 1000000000 === 0) {
|
|
45
|
-
label = `${(value / 1000000000).toFixed(decimalPoint)}G`;
|
|
46
|
-
} else {
|
|
47
|
-
label = `${(value / 1000000000).toFixed(1)}G`;
|
|
48
|
-
}
|
|
49
|
-
} else if (value >= 1000000) {
|
|
50
|
-
if (value % 1000000 === 0) {
|
|
51
|
-
label = `${(value / 1000000).toFixed(decimalPoint)}M`;
|
|
52
|
-
} else {
|
|
53
|
-
label = `${(value / 1000000).toFixed(1)}M`;
|
|
54
|
-
}
|
|
55
|
-
} else if (value >= 1000) {
|
|
56
|
-
if (value % 1000 === 0) {
|
|
57
|
-
label = `${(value / 1000).toFixed(decimalPoint)}K`;
|
|
58
|
-
} else {
|
|
59
|
-
label = `${(value / 1000).toFixed(1)}K`;
|
|
60
|
-
}
|
|
61
|
-
} else if (value < 1 && value > 0) {
|
|
62
|
-
label = value.toFixed(1);
|
|
63
|
-
} else {
|
|
64
|
-
label = value.toFixed(decimalPoint);
|
|
75
|
+
if (!truthy(value)) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const assignLabelWith = (v, target, lb) => {
|
|
80
|
+
if (v % target === 0) {
|
|
81
|
+
return `${(v / target).toFixed(decimalPoint)}${lb}`;
|
|
65
82
|
}
|
|
83
|
+
return `${(v / target).toFixed(1)}${lb}`;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (value >= quad) {
|
|
87
|
+
label = assignLabelWith(value, quad, 'P');
|
|
88
|
+
} else if (value >= trill) {
|
|
89
|
+
label = assignLabelWith(value, trill, 'T');
|
|
90
|
+
} else if (value >= billi) {
|
|
91
|
+
label = assignLabelWith(value, billi, 'G');
|
|
92
|
+
} else if (value >= milli) {
|
|
93
|
+
label = assignLabelWith(value, milli, 'M');
|
|
94
|
+
} else if (value >= killo) {
|
|
95
|
+
label = assignLabelWith(value, 1000, 'K');
|
|
96
|
+
} else if (value < 1 && value > 0) {
|
|
97
|
+
label = value.toFixed(1);
|
|
66
98
|
} else {
|
|
67
|
-
label = value;
|
|
99
|
+
label = value.toFixed(decimalPoint);
|
|
68
100
|
}
|
|
69
101
|
|
|
70
102
|
return label;
|
|
71
103
|
},
|
|
72
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Calculate text size with html
|
|
107
|
+
* @param {string} text text is needed to check size
|
|
108
|
+
* @param {string} fontStyle text font style
|
|
109
|
+
*
|
|
110
|
+
* @returns {object} text size information
|
|
111
|
+
*/
|
|
73
112
|
calcTextSize(text, fontStyle) {
|
|
74
113
|
const calc = document.createElement('span');
|
|
75
114
|
const style = `visibility:hidden; position:absolute; top:-10000px; font: ${fontStyle};`;
|
|
@@ -88,6 +127,12 @@ export default {
|
|
|
88
127
|
return { width, height };
|
|
89
128
|
},
|
|
90
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Comparing strings
|
|
132
|
+
* @param {array} array compared array
|
|
133
|
+
*
|
|
134
|
+
* @returns {object} min/max information
|
|
135
|
+
*/
|
|
91
136
|
getStringMinMax(array) {
|
|
92
137
|
const minMax = {
|
|
93
138
|
min: array[0],
|