@opentinyvue/vue-huicharts-wordcloud 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 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
@@ -0,0 +1,3 @@
1
+ import HuiChartsWordcloud from './src/chart-wordcloud.vue';
2
+ export { HuiChartsWordcloud };
3
+ export default HuiChartsWordcloud;
package/lib/index.js ADDED
@@ -0,0 +1,159 @@
1
+ import Core, { itemLabel, itemContent } from '@opentinyvue/vue-huicharts-core';
2
+ import { $prefix } from '@opentinyvue/vue-common';
3
+ import 'echarts-wordcloud';
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 getTooltip = function getTooltip2(args) {
45
+ var tooltipFormatter = args.tooltipFormatter;
46
+ function formatter(params) {
47
+ var data2 = params.data;
48
+ var name = data2.name, value = data2.value;
49
+ if (tooltipFormatter) {
50
+ return tooltipFormatter.apply(void 0, params);
51
+ }
52
+ return "" + itemLabel(name) + itemContent(value);
53
+ }
54
+ return formatter;
55
+ };
56
+ var shapeSquare = function shapeSquare2(theta) {
57
+ return Math.min(1 / Math.abs(Math.cos(theta)), 1 / Math.abs(Math.sin(theta)));
58
+ };
59
+ var getData = function getData2(args) {
60
+ var dimension = args.dimension, metrics = args.metrics, rows = args.rows;
61
+ return rows.slice().map(function(row) {
62
+ return {
63
+ name: row[dimension],
64
+ value: row[metrics]
65
+ };
66
+ });
67
+ };
68
+ var getWordColor = function getWordColor2(args) {
69
+ var color = args.color, colors = args.colors;
70
+ var tempColor = color || colors;
71
+ if (Array.isArray(tempColor) && tempColor.length) {
72
+ var textColor = function textColor2(word) {
73
+ return tempColor[word.dataIndex % tempColor.length];
74
+ };
75
+ return {
76
+ textColor
77
+ };
78
+ }
79
+ if (!Array.isArray(tempColor) && Boolean(tempColor)) {
80
+ return {
81
+ color: tempColor
82
+ };
83
+ }
84
+ return "rgb(" + Math.round(Math.random() * 160) + "," + Math.round(Math.random() * 160) + "," + Math.round(Math.random() * 160) + ")";
85
+ };
86
+ var wordcloud = function wordcloud2(columns, rows, settings, extra) {
87
+ var _settings$dimension = settings.dimension, dimension = _settings$dimension === void 0 ? columns[0] : _settings$dimension, _settings$metrics = settings.metrics, metrics = _settings$metrics === void 0 ? columns[1] : _settings$metrics;
88
+ var _settings$sizeMax = settings.sizeMax, sizeMax = _settings$sizeMax === void 0 ? 60 : _settings$sizeMax, _settings$sizeMin = settings.sizeMin, sizeMin = _settings$sizeMin === void 0 ? 12 : _settings$sizeMin, shape = settings.shape, _settings$color = settings.color, color = _settings$color === void 0 ? "" : _settings$color;
89
+ var tooltipVisible = extra.tooltipVisible, tooltipFormatter = extra.tooltipFormatter, colors = extra.color;
90
+ var data2 = getData({
91
+ dimension,
92
+ metrics,
93
+ rows
94
+ });
95
+ var wordColors = getWordColor({
96
+ color,
97
+ colors
98
+ });
99
+ var ichartOptions = _extends({
100
+ sizeRange: [sizeMin, sizeMax],
101
+ shape: shape || shapeSquare,
102
+ data: data2
103
+ }, wordColors);
104
+ if (tooltipVisible) {
105
+ ichartOptions.tipHtml = getTooltip({
106
+ tooltipFormatter
107
+ });
108
+ }
109
+ return ichartOptions;
110
+ };
111
+ var render = function render2() {
112
+ var _vm = this;
113
+ var _h = _vm.$createElement;
114
+ var _c = _vm._self._c || _h;
115
+ return _c("div", {
116
+ staticClass: "hui-chart chart-box"
117
+ }, [_c("div", {
118
+ ref: "chartRef",
119
+ style: {
120
+ width: _vm.width,
121
+ height: _vm.height
122
+ }
123
+ }), _vm._t("default")], 2);
124
+ };
125
+ var staticRenderFns = [];
126
+ var __vue2_script = {
127
+ name: $prefix + "ChartWordcloud",
128
+ mixins: [Core],
129
+ data: function data() {
130
+ return {
131
+ iChartName: "WordCloudChart"
132
+ };
133
+ },
134
+ methods: {
135
+ updateChart: function updateChart() {
136
+ 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;
137
+ var extra = {
138
+ tooltipVisible: this.tooltipVisible
139
+ };
140
+ var option = wordcloud(columns, rows, this.settings, extra);
141
+ this.huiChartOption = _extends({}, option);
142
+ }
143
+ }
144
+ };
145
+ var __cssModules = {};
146
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
147
+ function __vue2_injectStyles(context) {
148
+ for (var o in __cssModules) {
149
+ this[o] = __cssModules[o];
150
+ }
151
+ }
152
+ var HuiChartsWordcloud = /* @__PURE__ */ function() {
153
+ return __component__.exports;
154
+ }();
155
+ HuiChartsWordcloud.install = function(Vue) {
156
+ Vue.component(HuiChartsWordcloud.name, HuiChartsWordcloud);
157
+ };
158
+
159
+ export { HuiChartsWordcloud, HuiChartsWordcloud as default };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@opentinyvue/vue-huicharts-wordcloud",
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
+ "echarts-wordcloud": "2.0.0",
12
+ "@opentinyvue/vue-common": "~2.21.0"
13
+ },
14
+ "license": "MIT",
15
+ "types": "index.d.ts",
16
+ "scripts": {
17
+ "build": "pnpm -w build:ui $npm_package_name",
18
+ "//postversion": "pnpm build"
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ declare const _default: import("vue/types/vue").ExtendedVue<import("vue").default, {
2
+ iChartName: string;
3
+ }, {
4
+ updateChart(): void;
5
+ }, any, Record<never, any>>;
6
+ export default _default;
package/src/types.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ *
3
+ * @title Props
4
+ */
5
+ export interface TinyWordcloudProps {
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
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Dimension 维度 String 默认 columns[0]
3
+ * metrics 指标 String 默认 columns[1]
4
+ * sizeMin 最小字体大小 Number 默认为 12
5
+ * sizeMax 最大字体大小 Number 默认为 60
6
+ * shape 词云图的形状 String 默认为 circle,可选值有 cardioid、 diamond、triangle-forward、triangle、pentagon、star 等
7
+ * color 词云图字体颜色 Array[String], String, Function 默认为 "rgb(Math.round(Math.random * 160), Math.round(Math.random * 160), Math.round(Math.random * 160))"
8
+ */
9
+ export declare const wordcloud: (columns: any, rows: any, settings: any, extra: any) => any;