@opentinyvue/vue-huicharts-funnel 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 +229 -0
- package/package.json +19 -0
- package/src/chart-funnel.vue.d.ts +6 -0
- package/src/funnel.d.ts +13 -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,229 @@
|
|
|
1
|
+
import Core, { itemPoint, itemLabel, itemContent, getFormatted } from '@opentinyvue/vue-huicharts-core';
|
|
2
|
+
import { $prefix } from '@opentinyvue/vue-common';
|
|
3
|
+
|
|
4
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
5
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
6
|
+
if (render) {
|
|
7
|
+
options.render = render;
|
|
8
|
+
options.staticRenderFns = staticRenderFns;
|
|
9
|
+
options._compiled = true;
|
|
10
|
+
}
|
|
11
|
+
var hook;
|
|
12
|
+
if (injectStyles) {
|
|
13
|
+
hook = injectStyles;
|
|
14
|
+
}
|
|
15
|
+
if (hook) {
|
|
16
|
+
if (options.functional) {
|
|
17
|
+
options._injectStyles = hook;
|
|
18
|
+
var originalRender = options.render;
|
|
19
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
20
|
+
hook.call(context);
|
|
21
|
+
return originalRender(h, context);
|
|
22
|
+
};
|
|
23
|
+
} else {
|
|
24
|
+
var existing = options.beforeCreate;
|
|
25
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
exports: scriptExports,
|
|
30
|
+
options
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var getMetrics = function getMetrics2(args) {
|
|
35
|
+
var dimension = args.dimension, columns = args.columns, settings = args.settings;
|
|
36
|
+
var metrics;
|
|
37
|
+
if (settings.metrics) {
|
|
38
|
+
metrics = settings.metrics;
|
|
39
|
+
} else {
|
|
40
|
+
var temp = columns.slice();
|
|
41
|
+
temp.splice(columns.indexOf(dimension), 1);
|
|
42
|
+
metrics = temp[0];
|
|
43
|
+
}
|
|
44
|
+
return metrics;
|
|
45
|
+
};
|
|
46
|
+
var getFunnelLegend = function getFunnelLegend2(args) {
|
|
47
|
+
var legendVisible = args.legendVisible, data2 = args.data, legendName = args.legendName;
|
|
48
|
+
if (!legendVisible) {
|
|
49
|
+
return {
|
|
50
|
+
show: false
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var show = true;
|
|
54
|
+
function formatter(name) {
|
|
55
|
+
if (legendName[name] === null || legendName[name] === void 0 || legendName[name] === "undefined") {
|
|
56
|
+
return name;
|
|
57
|
+
}
|
|
58
|
+
return legendName[name];
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
show,
|
|
62
|
+
data: data2,
|
|
63
|
+
formatter
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
var getFunnelTooltip = function getFunnelTooltip2(dataType, digit) {
|
|
67
|
+
function formatter(item) {
|
|
68
|
+
var tpl = [];
|
|
69
|
+
tpl.push(itemPoint(item.color));
|
|
70
|
+
tpl.push("" + itemLabel(item.name) + itemContent(getFormatted(item.data.realValue, dataType, digit)));
|
|
71
|
+
return tpl.join("");
|
|
72
|
+
}
|
|
73
|
+
return formatter;
|
|
74
|
+
};
|
|
75
|
+
var getFunnelSeries = function getFunnelSeries2(args) {
|
|
76
|
+
var selfSeries = [];
|
|
77
|
+
var dimension = args.dimension, metrics = args.metrics, rows = args.rows, sequence = args.sequence, label = args.label, labelLine = args.labelLine, itemStyle = args.itemStyle, useDefaultOrder = args.useDefaultOrder, ascending = args.ascending;
|
|
78
|
+
var _ref = {}, _ref$series = _ref.series, series = _ref$series === void 0 ? {
|
|
79
|
+
type: "funnel"
|
|
80
|
+
} : _ref$series, _ref$falseFunnel = _ref.falseFunnel, falseFunnel = _ref$falseFunnel === void 0 ? false : _ref$falseFunnel;
|
|
81
|
+
series.minSize = 8;
|
|
82
|
+
var innerRows = rows.sort(function(a, b) {
|
|
83
|
+
return sequence.indexOf(a[dimension]) - sequence.indexOf(b[dimension]);
|
|
84
|
+
});
|
|
85
|
+
innerRows.some(function(row, index) {
|
|
86
|
+
return index && row[metrics] > innerRows[index - 1][metrics] && (falseFunnel = true);
|
|
87
|
+
});
|
|
88
|
+
var step = 100 / innerRows.length;
|
|
89
|
+
var total = 0;
|
|
90
|
+
rows.forEach(function(row) {
|
|
91
|
+
total += row[metrics];
|
|
92
|
+
});
|
|
93
|
+
if (falseFunnel && !useDefaultOrder) {
|
|
94
|
+
var handler = function handler2(row, index) {
|
|
95
|
+
return {
|
|
96
|
+
name: row[dimension],
|
|
97
|
+
value: (index + 1) * step,
|
|
98
|
+
realValue: row[metrics]
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
series.data = innerRows.slice().reverse().map(handler);
|
|
102
|
+
series.label = {
|
|
103
|
+
position: "inside",
|
|
104
|
+
color: "#fff",
|
|
105
|
+
formatter: function formatter(item) {
|
|
106
|
+
var value = item.value;
|
|
107
|
+
return Number(value / total).toFixed(2) * 100 + "%";
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
} else {
|
|
111
|
+
innerRows.sort(function(a, b) {
|
|
112
|
+
return b[metrics] - a[metrics];
|
|
113
|
+
});
|
|
114
|
+
series.data = innerRows.map(function(row, index) {
|
|
115
|
+
return {
|
|
116
|
+
name: row[dimension],
|
|
117
|
+
value: (innerRows.length - index) * step,
|
|
118
|
+
realValue: row[metrics]
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
series.label = {
|
|
122
|
+
position: "inside",
|
|
123
|
+
color: "#fff",
|
|
124
|
+
formatter: function formatter(item) {
|
|
125
|
+
var data2 = item.data;
|
|
126
|
+
return Number(data2.realValue / total).toFixed(2) * 100 + "%";
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
ascending && (series.sort = "ascending");
|
|
131
|
+
label && (series.label = label);
|
|
132
|
+
labelLine && (series.labelLine = labelLine);
|
|
133
|
+
itemStyle && (series.itemStyle = itemStyle);
|
|
134
|
+
selfSeries.push(series);
|
|
135
|
+
return selfSeries;
|
|
136
|
+
};
|
|
137
|
+
var getIChartOption = function getIChartOption2(outerColumns, outerRows, settings, extra) {
|
|
138
|
+
var _ref2 = {}, _ref2$columns = _ref2.columns, columns = _ref2$columns === void 0 ? outerColumns.slice() : _ref2$columns, _ref2$rows = _ref2.rows, rows = _ref2$rows === void 0 ? outerRows.slice() : _ref2$rows;
|
|
139
|
+
var _settings$dataType = settings.dataType, dataType = _settings$dataType === void 0 ? "normal" : _settings$dataType, _settings$dimension = settings.dimension, dimension = _settings$dimension === void 0 ? columns[0] : _settings$dimension, _settings$sequence = settings.sequence, sequence = _settings$sequence === void 0 ? rows.map(function(row) {
|
|
140
|
+
return row[dimension];
|
|
141
|
+
}) : _settings$sequence;
|
|
142
|
+
var _settings$digit = settings.digit, digit = _settings$digit === void 0 ? 2 : _settings$digit, ascending = settings.ascending, label = settings.label, labelLine = settings.labelLine, _settings$legendName = settings.legendName, legendName = _settings$legendName === void 0 ? {} : _settings$legendName, itemStyle = settings.itemStyle, filterZero = settings.filterZero, useDefaultOrder = settings.useDefaultOrder;
|
|
143
|
+
var tooltipVisible = extra.tooltipVisible, legendVisible = extra.legendVisible;
|
|
144
|
+
var metrics = getMetrics({
|
|
145
|
+
dimension,
|
|
146
|
+
columns,
|
|
147
|
+
settings
|
|
148
|
+
});
|
|
149
|
+
var innerRows = rows.sort(function(a, b) {
|
|
150
|
+
return sequence.indexOf(a[dimension]) - sequence.indexOf(b[dimension]);
|
|
151
|
+
});
|
|
152
|
+
filterZero && (innerRows = innerRows.filter(function(row) {
|
|
153
|
+
return row[metrics];
|
|
154
|
+
}));
|
|
155
|
+
var tooltip = tooltipVisible && getFunnelTooltip(dataType, digit);
|
|
156
|
+
var legend = getFunnelLegend({
|
|
157
|
+
legendVisible,
|
|
158
|
+
data: innerRows.map(function(row) {
|
|
159
|
+
return row[dimension];
|
|
160
|
+
}),
|
|
161
|
+
legendName
|
|
162
|
+
});
|
|
163
|
+
var seriesParam = {
|
|
164
|
+
dimension,
|
|
165
|
+
metrics,
|
|
166
|
+
rows: innerRows,
|
|
167
|
+
sequence,
|
|
168
|
+
label,
|
|
169
|
+
labelLine,
|
|
170
|
+
itemStyle,
|
|
171
|
+
useDefaultOrder,
|
|
172
|
+
ascending
|
|
173
|
+
};
|
|
174
|
+
var series = getFunnelSeries(seriesParam);
|
|
175
|
+
var ichartOption = {
|
|
176
|
+
legend,
|
|
177
|
+
tipHtml: tooltip,
|
|
178
|
+
series
|
|
179
|
+
};
|
|
180
|
+
return ichartOption;
|
|
181
|
+
};
|
|
182
|
+
var render = function render2() {
|
|
183
|
+
var _vm = this;
|
|
184
|
+
var _h = _vm.$createElement;
|
|
185
|
+
var _c = _vm._self._c || _h;
|
|
186
|
+
return _c("div", {
|
|
187
|
+
ref: "chartRef",
|
|
188
|
+
staticClass: "hui-chart chart-box",
|
|
189
|
+
style: {
|
|
190
|
+
width: _vm.width,
|
|
191
|
+
height: _vm.height
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
var staticRenderFns = [];
|
|
196
|
+
var __vue2_script = {
|
|
197
|
+
name: $prefix + "ChartFunnel",
|
|
198
|
+
mixins: [Core],
|
|
199
|
+
data: function data() {
|
|
200
|
+
return {
|
|
201
|
+
iChartName: "FunnelChart"
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
methods: {
|
|
205
|
+
updateChart: function updateChart() {
|
|
206
|
+
var _this$data = this.data, _this$data$columns = _this$data.columns, columns = _this$data$columns === void 0 ? [] : _this$data$columns, _this$data$rows = _this$data.rows, rows = _this$data$rows === void 0 ? [] : _this$data$rows;
|
|
207
|
+
var extra = {
|
|
208
|
+
legendVisible: this.legendVisible,
|
|
209
|
+
tooltipVisible: this.tooltipVisible
|
|
210
|
+
};
|
|
211
|
+
this.huiChartOption = getIChartOption(columns, rows, this.settings, extra);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var __cssModules = {};
|
|
216
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
217
|
+
function __vue2_injectStyles(context) {
|
|
218
|
+
for (var o in __cssModules) {
|
|
219
|
+
this[o] = __cssModules[o];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
var HuiChartsFunnel = /* @__PURE__ */ function() {
|
|
223
|
+
return __component__.exports;
|
|
224
|
+
}();
|
|
225
|
+
HuiChartsFunnel.install = function(Vue) {
|
|
226
|
+
Vue.component(HuiChartsFunnel.name, HuiChartsFunnel);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export { HuiChartsFunnel, HuiChartsFunnel as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentinyvue/vue-huicharts-funnel",
|
|
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/funnel.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getIChartOption: (outerColumns: any, outerRows: any, settings: any, extra: any) => {
|
|
2
|
+
legend: {
|
|
3
|
+
show: boolean;
|
|
4
|
+
data?: undefined;
|
|
5
|
+
formatter?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
show: boolean;
|
|
8
|
+
data: any;
|
|
9
|
+
formatter: (name: any) => any;
|
|
10
|
+
};
|
|
11
|
+
tipHtml: any;
|
|
12
|
+
series: never[];
|
|
13
|
+
};
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @title Props
|
|
4
|
+
*/
|
|
5
|
+
export interface TinyFunnelProps {
|
|
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
|
+
}
|