@opentinyvue/vue-huicharts-boxplot 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/index.d.ts +3 -0
- package/lib/index.js +258 -0
- package/package.json +19 -0
- package/src/boxplot.d.ts +18 -0
- package/src/chart-boxplot.vue.d.ts +7 -0
- package/src/types.d.ts +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 - present TinyVue Authors.
|
|
4
|
+
Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import Core, { itemPoint, itemLabel, itemContent, htmlHandler, getFormatted } from '@opentinyvue/vue-huicharts-core';
|
|
2
|
+
import { prepareBoxplotData } from 'echarts/extension/dataTool';
|
|
3
|
+
import { $prefix } from '@opentinyvue/vue-common';
|
|
4
|
+
|
|
5
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
6
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
7
|
+
if (render) {
|
|
8
|
+
options.render = render;
|
|
9
|
+
options.staticRenderFns = staticRenderFns;
|
|
10
|
+
options._compiled = true;
|
|
11
|
+
}
|
|
12
|
+
var hook;
|
|
13
|
+
if (injectStyles) {
|
|
14
|
+
hook = injectStyles;
|
|
15
|
+
}
|
|
16
|
+
if (hook) {
|
|
17
|
+
if (options.functional) {
|
|
18
|
+
options._injectStyles = hook;
|
|
19
|
+
var originalRender = options.render;
|
|
20
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
21
|
+
hook.call(context);
|
|
22
|
+
return originalRender(h, context);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
var existing = options.beforeCreate;
|
|
26
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
exports: scriptExports,
|
|
31
|
+
options
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _extends() {
|
|
36
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
37
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
38
|
+
var t = arguments[e];
|
|
39
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
40
|
+
}
|
|
41
|
+
return n;
|
|
42
|
+
}, _extends.apply(null, arguments);
|
|
43
|
+
}
|
|
44
|
+
var getXAxis = function getXAxis2(args) {
|
|
45
|
+
var columns = args.columns, xAxisName = args.xAxisName, axisVisible = args.axisVisible, xAxisType = args.xAxisType;
|
|
46
|
+
return [{
|
|
47
|
+
type: xAxisType,
|
|
48
|
+
nameLocation: "middle",
|
|
49
|
+
nameGap: 22,
|
|
50
|
+
name: xAxisName || "",
|
|
51
|
+
axisTick: {
|
|
52
|
+
show: true,
|
|
53
|
+
lineStyle: {
|
|
54
|
+
color: "#eee"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
data: columns,
|
|
58
|
+
show: axisVisible
|
|
59
|
+
}];
|
|
60
|
+
};
|
|
61
|
+
var getSeries = function getSeries2(args) {
|
|
62
|
+
var area = args.area, areaStyle = args.areaStyle, itemStyle = args.itemStyle, label = args.label, lineStyle = args.lineStyle, _args$outliers = args.outliers, outliers = _args$outliers === void 0 ? [] : _args$outliers, rows = args.rows;
|
|
63
|
+
var _ref = {}, _ref$series = _ref.series, series = _ref$series === void 0 ? [] : _ref$series, _ref$arr = _ref.arr, arr = _ref$arr === void 0 ? ["boxplot", "scatter"] : _ref$arr;
|
|
64
|
+
arr.forEach(function(item) {
|
|
65
|
+
if (item === "scatter" && !outliers.length) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var data2 = item === "boxplot" ? rows : outliers;
|
|
69
|
+
var seriesItem = {
|
|
70
|
+
name: "",
|
|
71
|
+
type: item,
|
|
72
|
+
data: data2
|
|
73
|
+
};
|
|
74
|
+
area && (seriesItem.areaStyle = {});
|
|
75
|
+
label && (seriesItem.label = label);
|
|
76
|
+
lineStyle && (seriesItem.lineStyle = lineStyle);
|
|
77
|
+
itemStyle && (seriesItem.itemStyle = itemStyle);
|
|
78
|
+
areaStyle && (seriesItem.areaStyle = areaStyle);
|
|
79
|
+
series.push(seriesItem);
|
|
80
|
+
});
|
|
81
|
+
return series;
|
|
82
|
+
};
|
|
83
|
+
var factoryFmt = function factoryFmt2(_ref2) {
|
|
84
|
+
var yAxisType = _ref2.yAxisType, i = _ref2.i, digit = _ref2.digit;
|
|
85
|
+
return function(val) {
|
|
86
|
+
return getFormatted(val, yAxisType[i], digit);
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var getYAxis = function getYAxis2(args) {
|
|
90
|
+
var axisVisible = args.axisVisible, digit = args.digit, max = args.max, min = args.min, scale = args.scale, yAxisName = args.yAxisName, yAxisType = args.yAxisType;
|
|
91
|
+
var yAxisBase = {
|
|
92
|
+
type: "value",
|
|
93
|
+
axisTick: {
|
|
94
|
+
show: false
|
|
95
|
+
},
|
|
96
|
+
show: axisVisible
|
|
97
|
+
};
|
|
98
|
+
var _ref3 = {}, _ref3$yAxis = _ref3.yAxis, yAxis = _ref3$yAxis === void 0 ? [] : _ref3$yAxis, _ref3$len = _ref3.len, len = _ref3$len === void 0 ? yAxisType.length >= 2 ? 2 : 1 : _ref3$len, _ref3$i = _ref3.i, i = _ref3$i === void 0 ? 0 : _ref3$i;
|
|
99
|
+
for (; i < len; i++) {
|
|
100
|
+
if (!yAxisType[i]) {
|
|
101
|
+
yAxis[i] = _extends({}, yAxisBase);
|
|
102
|
+
} else {
|
|
103
|
+
var formatter = factoryFmt({
|
|
104
|
+
yAxisType,
|
|
105
|
+
i,
|
|
106
|
+
digit
|
|
107
|
+
});
|
|
108
|
+
var yAxisAdv = {
|
|
109
|
+
axisLabel: {
|
|
110
|
+
formatter
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
yAxis[i] = _extends({}, yAxisBase, yAxisAdv);
|
|
114
|
+
var name = yAxisName[i] || "";
|
|
115
|
+
Object.assign(yAxis[i], {
|
|
116
|
+
name,
|
|
117
|
+
scale: scale[i] || false,
|
|
118
|
+
min: min[i] || null,
|
|
119
|
+
max: max[i] || null
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return yAxis;
|
|
124
|
+
};
|
|
125
|
+
var getTooltip = function getTooltip2() {
|
|
126
|
+
return {
|
|
127
|
+
trigger: "item",
|
|
128
|
+
formatter: function formatter(item) {
|
|
129
|
+
var tpl = [];
|
|
130
|
+
var name = item.name, value = item.value, color = item.color, dataType = item.dataType;
|
|
131
|
+
color && tpl.push(itemPoint(color));
|
|
132
|
+
tpl.push(itemLabel("" + name, !value));
|
|
133
|
+
if (dataType === "node") {
|
|
134
|
+
value && tpl.push(itemContent(value) + "<br />");
|
|
135
|
+
}
|
|
136
|
+
return tpl.join("");
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
var boxplot = function boxplot2(columns, rows, settings, extra) {
|
|
141
|
+
rows = Array.isArray(rows) ? rows : [];
|
|
142
|
+
columns = Array.isArray(columns) ? columns : [];
|
|
143
|
+
var _settings$axisSite = settings.axisSite, axisSite = _settings$axisSite === void 0 ? {} : _settings$axisSite, _settings$yAxisType = settings.yAxisType, yAxisType = _settings$yAxisType === void 0 ? ["normal"] : _settings$yAxisType, _settings$xAxisType = settings.xAxisType, xAxisType = _settings$xAxisType === void 0 ? "category" : _settings$xAxisType, _settings$yAxisName = settings.yAxisName, yAxisName = _settings$yAxisName === void 0 ? "" : _settings$yAxisName, _settings$xAxisName = settings.xAxisName, xAxisName = _settings$xAxisName === void 0 ? "" : _settings$xAxisName;
|
|
144
|
+
var _settings$axisVisible = settings.axisVisible, axisVisible = _settings$axisVisible === void 0 ? true : _settings$axisVisible, area = settings.area, _settings$scale = settings.scale, scale = _settings$scale === void 0 ? [false, false] : _settings$scale, _settings$min = settings.min, min = _settings$min === void 0 ? [null, null] : _settings$min, _settings$max = settings.max, max = _settings$max === void 0 ? [null, null] : _settings$max;
|
|
145
|
+
var _settings$nullAddZero = settings.nullAddZero, nullAddZero = _settings$nullAddZero === void 0 ? false : _settings$nullAddZero, _settings$digit = settings.digit, digit = _settings$digit === void 0 ? 2 : _settings$digit; settings.legendName; var _settings$labelMap = settings.labelMap, labelMap = _settings$labelMap === void 0 ? {} : _settings$labelMap, label = settings.label, itemStyle = settings.itemStyle;
|
|
146
|
+
var lineStyle = settings.lineStyle, areaStyle = settings.areaStyle, _settings$tooltipLabe = settings.tooltipLabel, tooltipLabel = _settings$tooltipLabe === void 0 ? ["lower", "Q1", "median", "Q3", "upper"] : _settings$tooltipLabe;
|
|
147
|
+
extra.legendVisible; var outliers = extra.outliers, tooltipFormatter = extra.tooltipFormatter, tooltipVisible = extra.tooltipVisible;
|
|
148
|
+
var metrics = columns.slice();
|
|
149
|
+
if (axisSite.right && axisSite.left) {
|
|
150
|
+
metrics = axisSite.left.concat(axisSite.right);
|
|
151
|
+
} else if (!axisSite.right && axisSite.left) {
|
|
152
|
+
metrics = axisSite.left;
|
|
153
|
+
} else if (settings.metrics) {
|
|
154
|
+
metrics = settings.metrics;
|
|
155
|
+
}
|
|
156
|
+
var getParams = function getParams2() {
|
|
157
|
+
return {
|
|
158
|
+
tooltipFormatter,
|
|
159
|
+
tooltipLabel: htmlHandler(tooltipLabel),
|
|
160
|
+
digit
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
tooltipVisible && getTooltip(getParams());
|
|
164
|
+
var xAxis = getXAxis({
|
|
165
|
+
columns,
|
|
166
|
+
xAxisName,
|
|
167
|
+
axisVisible,
|
|
168
|
+
xAxisType
|
|
169
|
+
});
|
|
170
|
+
var yAxisParams = {
|
|
171
|
+
yAxisName,
|
|
172
|
+
yAxisType,
|
|
173
|
+
axisVisible
|
|
174
|
+
};
|
|
175
|
+
Object.assign(yAxisParams, {
|
|
176
|
+
scale,
|
|
177
|
+
min,
|
|
178
|
+
max,
|
|
179
|
+
digit
|
|
180
|
+
});
|
|
181
|
+
var yAxis = getYAxis(yAxisParams);
|
|
182
|
+
var seriesParams = {
|
|
183
|
+
rows,
|
|
184
|
+
axisSite,
|
|
185
|
+
metrics,
|
|
186
|
+
area,
|
|
187
|
+
nullAddZero,
|
|
188
|
+
labelMap,
|
|
189
|
+
label
|
|
190
|
+
};
|
|
191
|
+
Object.assign(seriesParams, {
|
|
192
|
+
itemStyle,
|
|
193
|
+
lineStyle,
|
|
194
|
+
areaStyle,
|
|
195
|
+
xAxisType,
|
|
196
|
+
outliers
|
|
197
|
+
});
|
|
198
|
+
getSeries(seriesParams);
|
|
199
|
+
return {
|
|
200
|
+
xAxis,
|
|
201
|
+
yAxis,
|
|
202
|
+
data: extra.data
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
var render = function render2() {
|
|
206
|
+
var _vm = this;
|
|
207
|
+
var _h = _vm.$createElement;
|
|
208
|
+
var _c = _vm._self._c || _h;
|
|
209
|
+
return _c("div", {
|
|
210
|
+
staticClass: "hui-chart chart-box"
|
|
211
|
+
}, [_c("div", {
|
|
212
|
+
ref: "chartRef",
|
|
213
|
+
style: {
|
|
214
|
+
width: _vm.width,
|
|
215
|
+
height: _vm.height
|
|
216
|
+
}
|
|
217
|
+
}), _vm._t("default")], 2);
|
|
218
|
+
};
|
|
219
|
+
var staticRenderFns = [];
|
|
220
|
+
var __vue2_script = {
|
|
221
|
+
name: $prefix + "ChartBoxplot",
|
|
222
|
+
mixins: [Core],
|
|
223
|
+
data: function data() {
|
|
224
|
+
return {
|
|
225
|
+
iChartName: "BoxplotChart"
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
methods: {
|
|
229
|
+
updateChart: function updateChart(data2) {
|
|
230
|
+
var _data$columns = data2.columns, columns = _data$columns === void 0 ? [] : _data$columns, _data$rows = data2.rows, rows = _data$rows === void 0 ? [] : _data$rows;
|
|
231
|
+
var extra = {
|
|
232
|
+
tooltipVisible: this.tooltipVisible,
|
|
233
|
+
extend: this.extend,
|
|
234
|
+
data: prepareBoxplotData && Array.isArray(data2) ? data2 : null
|
|
235
|
+
};
|
|
236
|
+
var option = boxplot(columns, rows, this.settings, extra);
|
|
237
|
+
this.huiChartOption = _extends({}, option);
|
|
238
|
+
},
|
|
239
|
+
prepareBoxplotData: function prepareBoxplotData$1(data2) {
|
|
240
|
+
return prepareBoxplotData(data2);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var __cssModules = {};
|
|
245
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
246
|
+
function __vue2_injectStyles(context) {
|
|
247
|
+
for (var o in __cssModules) {
|
|
248
|
+
this[o] = __cssModules[o];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
var HuiChartsBoxplot = /* @__PURE__ */ function() {
|
|
252
|
+
return __component__.exports;
|
|
253
|
+
}();
|
|
254
|
+
HuiChartsBoxplot.install = function(Vue) {
|
|
255
|
+
Vue.component(HuiChartsBoxplot.name, HuiChartsBoxplot);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export { HuiChartsBoxplot, HuiChartsBoxplot as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentinyvue/vue-huicharts-boxplot",
|
|
3
|
+
"version": "2.21.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@opentinyvue/vue-huicharts-core": "~2.21.0",
|
|
11
|
+
"@opentinyvue/vue-common": "~2.21.0"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"types": "index.d.ts",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "pnpm -w build:ui $npm_package_name",
|
|
17
|
+
"//postversion": "pnpm build"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/boxplot.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const boxplot: (columns: any, rows: any, settings: any, extra: any) => {
|
|
2
|
+
xAxis: {
|
|
3
|
+
type: any;
|
|
4
|
+
nameLocation: string;
|
|
5
|
+
nameGap: number;
|
|
6
|
+
name: any;
|
|
7
|
+
axisTick: {
|
|
8
|
+
show: boolean;
|
|
9
|
+
lineStyle: {
|
|
10
|
+
color: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
data: any;
|
|
14
|
+
show: any;
|
|
15
|
+
}[];
|
|
16
|
+
yAxis: never[];
|
|
17
|
+
data: any;
|
|
18
|
+
};
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @title Props
|
|
4
|
+
*/
|
|
5
|
+
export interface TinyBoxplotProps {
|
|
6
|
+
/**
|
|
7
|
+
* @zh 数据由指标和维度组成,“维度” 指的是数据的属性,“指标” 是量化衡量标准
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
dimension?: object;
|
|
11
|
+
/**
|
|
12
|
+
* @zh 配置项,各图表 Settings 属性配置请查阅各图表详情页面
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
settings?: Object;
|
|
16
|
+
/**
|
|
17
|
+
* @zh 设置图表容器的宽度。
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
width?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @zh 设置图表容器的高度
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
height?: string;
|
|
26
|
+
}
|