@xq-labs/data-ui-v2 0.2.0 → 0.2.1
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/docs/api/overview.md +42 -6
- package/docs/examples/bar-line-chart.md +21 -4
- package/docs/examples/pie-chart.md +31 -4
- package/es/bar-line-chart/index.js +2 -2
- package/es/base-chart/index.js +1 -1
- package/es/{index-6128787e.js → index-017ccf86.js} +16 -4
- package/es/{index-6af2ada7.js → index-d151eeca.js} +31 -10
- package/es/index.js +3 -3
- package/es/pie-chart/index.js +2 -2
- package/es/with-install-e405b463.js +560 -0
- package/lib/bar-line-chart/index.js +2 -2
- package/lib/base-chart/index.js +1 -1
- package/lib/{index-b3548b04.js → index-7abf647e.js} +31 -10
- package/lib/{index-ce63a14a.js → index-b9e0c40b.js} +16 -4
- package/lib/index.js +3 -3
- package/lib/pie-chart/index.js +2 -2
- package/lib/with-install-4304a8ea.js +565 -0
- package/package.json +1 -1
- package/es/with-install-befebea5.js +0 -411
- package/lib/with-install-6ce12163.js +0 -416
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import { init } from 'echarts/core';
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
var script$1 = {
|
|
9
|
-
name: 'BaseEmpty',
|
|
10
|
-
props: {
|
|
11
|
-
text: {
|
|
12
|
-
type: String,
|
|
13
|
-
"default": '暂无数据'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function styleInject(css, ref) {
|
|
19
|
-
if ( ref === void 0 ) ref = {};
|
|
20
|
-
var insertAt = ref.insertAt;
|
|
21
|
-
|
|
22
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
23
|
-
|
|
24
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
25
|
-
var style = document.createElement('style');
|
|
26
|
-
style.type = 'text/css';
|
|
27
|
-
|
|
28
|
-
if (insertAt === 'top') {
|
|
29
|
-
if (head.firstChild) {
|
|
30
|
-
head.insertBefore(style, head.firstChild);
|
|
31
|
-
} else {
|
|
32
|
-
head.appendChild(style);
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
head.appendChild(style);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (style.styleSheet) {
|
|
39
|
-
style.styleSheet.cssText = css;
|
|
40
|
-
} else {
|
|
41
|
-
style.appendChild(document.createTextNode(css));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var css_248z$1 = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
|
|
46
|
-
styleInject(css_248z$1);
|
|
47
|
-
|
|
48
|
-
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
49
|
-
if (typeof shadowMode !== 'boolean') {
|
|
50
|
-
createInjectorSSR = createInjector;
|
|
51
|
-
createInjector = shadowMode;
|
|
52
|
-
shadowMode = false;
|
|
53
|
-
}
|
|
54
|
-
// Vue.extend constructor export interop.
|
|
55
|
-
const options = typeof script === 'function' ? script.options : script;
|
|
56
|
-
// render functions
|
|
57
|
-
if (template && template.render) {
|
|
58
|
-
options.render = template.render;
|
|
59
|
-
options.staticRenderFns = template.staticRenderFns;
|
|
60
|
-
options._compiled = true;
|
|
61
|
-
// functional template
|
|
62
|
-
if (isFunctionalTemplate) {
|
|
63
|
-
options.functional = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// scopedId
|
|
67
|
-
if (scopeId) {
|
|
68
|
-
options._scopeId = scopeId;
|
|
69
|
-
}
|
|
70
|
-
let hook;
|
|
71
|
-
if (moduleIdentifier) {
|
|
72
|
-
// server build
|
|
73
|
-
hook = function (context) {
|
|
74
|
-
// 2.3 injection
|
|
75
|
-
context =
|
|
76
|
-
context || // cached call
|
|
77
|
-
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
|
78
|
-
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
|
|
79
|
-
// 2.2 with runInNewContext: true
|
|
80
|
-
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
81
|
-
context = __VUE_SSR_CONTEXT__;
|
|
82
|
-
}
|
|
83
|
-
// inject component styles
|
|
84
|
-
if (style) {
|
|
85
|
-
style.call(this, createInjectorSSR(context));
|
|
86
|
-
}
|
|
87
|
-
// register component module identifier for async chunk inference
|
|
88
|
-
if (context && context._registeredComponents) {
|
|
89
|
-
context._registeredComponents.add(moduleIdentifier);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
// used by ssr in case component is cached and beforeCreate
|
|
93
|
-
// never gets called
|
|
94
|
-
options._ssrRegister = hook;
|
|
95
|
-
}
|
|
96
|
-
else if (style) {
|
|
97
|
-
hook = shadowMode
|
|
98
|
-
? function (context) {
|
|
99
|
-
style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
|
|
100
|
-
}
|
|
101
|
-
: function (context) {
|
|
102
|
-
style.call(this, createInjector(context));
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
if (hook) {
|
|
106
|
-
if (options.functional) {
|
|
107
|
-
// register for functional component in vue file
|
|
108
|
-
const originalRender = options.render;
|
|
109
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
110
|
-
hook.call(context);
|
|
111
|
-
return originalRender(h, context);
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
// inject component registration as beforeCreate hook
|
|
116
|
-
const existing = options.beforeCreate;
|
|
117
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return script;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* script */
|
|
124
|
-
var __vue_script__$1 = script$1;
|
|
125
|
-
/* template */
|
|
126
|
-
var __vue_render__$1 = function __vue_render__() {
|
|
127
|
-
var _vm = this;
|
|
128
|
-
var _h = _vm.$createElement;
|
|
129
|
-
var _c = _vm._self._c || _h;
|
|
130
|
-
return _c("div", {
|
|
131
|
-
staticClass: "base-empty"
|
|
132
|
-
}, [_vm._v(_vm._s(_vm.text))]);
|
|
133
|
-
};
|
|
134
|
-
var __vue_staticRenderFns__$1 = [];
|
|
135
|
-
__vue_render__$1._withStripped = true;
|
|
136
|
-
|
|
137
|
-
/* style */
|
|
138
|
-
var __vue_inject_styles__$1 = undefined;
|
|
139
|
-
/* scoped */
|
|
140
|
-
var __vue_scope_id__$1 = "data-v-5b935462";
|
|
141
|
-
/* module identifier */
|
|
142
|
-
var __vue_module_identifier__$1 = undefined;
|
|
143
|
-
/* functional template */
|
|
144
|
-
var __vue_is_functional_template__$1 = false;
|
|
145
|
-
/* style inject */
|
|
146
|
-
|
|
147
|
-
/* style inject SSR */
|
|
148
|
-
|
|
149
|
-
/* style inject shadow dom */
|
|
150
|
-
|
|
151
|
-
var __vue_component__$1 = /*#__PURE__*/normalizeComponent({
|
|
152
|
-
render: __vue_render__$1,
|
|
153
|
-
staticRenderFns: __vue_staticRenderFns__$1
|
|
154
|
-
}, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, undefined, undefined, undefined);
|
|
155
|
-
var BaseEmpty = __vue_component__$1;
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
var script = {
|
|
166
|
-
name: 'BaseChart',
|
|
167
|
-
components: {
|
|
168
|
-
BaseEmpty: BaseEmpty
|
|
169
|
-
},
|
|
170
|
-
props: {
|
|
171
|
-
/**
|
|
172
|
-
* 已构建完成的 ECharts option。
|
|
173
|
-
* 上层业务图表组件只负责生成 option,真正渲染由 BaseChart 统一完成。
|
|
174
|
-
*/
|
|
175
|
-
option: {
|
|
176
|
-
type: Object,
|
|
177
|
-
"default": function _default() {
|
|
178
|
-
return {};
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
/**
|
|
182
|
-
* 是否展示 loading。
|
|
183
|
-
* 当图表实例已初始化时,会同步调用 showLoading / hideLoading。
|
|
184
|
-
*/
|
|
185
|
-
loading: {
|
|
186
|
-
type: Boolean,
|
|
187
|
-
"default": false
|
|
188
|
-
},
|
|
189
|
-
/**
|
|
190
|
-
* 是否进入空态。
|
|
191
|
-
* 为空时不渲染画布,而是显示统一空状态组件。
|
|
192
|
-
*/
|
|
193
|
-
empty: {
|
|
194
|
-
type: Boolean,
|
|
195
|
-
"default": false
|
|
196
|
-
},
|
|
197
|
-
/**
|
|
198
|
-
* 空态文本。
|
|
199
|
-
* 由 BaseEmpty 组件直接展示。
|
|
200
|
-
*/
|
|
201
|
-
emptyText: {
|
|
202
|
-
type: String,
|
|
203
|
-
"default": '暂无数据'
|
|
204
|
-
},
|
|
205
|
-
/**
|
|
206
|
-
* 图表容器高度。
|
|
207
|
-
* 数字按 px 处理,字符串则原样作为 CSS 高度使用。
|
|
208
|
-
*/
|
|
209
|
-
height: {
|
|
210
|
-
type: [String, Number],
|
|
211
|
-
"default": 320
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
/**
|
|
215
|
-
* 维护组件内部唯一的 ECharts 实例引用。
|
|
216
|
-
* 所有渲染、loading、resize 与销毁逻辑都围绕该实例展开。
|
|
217
|
-
*/
|
|
218
|
-
data: function data() {
|
|
219
|
-
return {
|
|
220
|
-
chart: null
|
|
221
|
-
};
|
|
222
|
-
},
|
|
223
|
-
computed: {
|
|
224
|
-
/**
|
|
225
|
-
* 统一计算容器高度样式,保证外层容器和内部 canvas 高度一致。
|
|
226
|
-
*/
|
|
227
|
-
chartStyle: function chartStyle() {
|
|
228
|
-
return {
|
|
229
|
-
height: typeof this.height === 'number' ? "".concat(this.height, "px") : this.height
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
watch: {
|
|
234
|
-
/**
|
|
235
|
-
* 监听外部 option 变化,并在实例已存在时立即覆盖渲染。
|
|
236
|
-
*/
|
|
237
|
-
option: {
|
|
238
|
-
deep: true,
|
|
239
|
-
handler: function handler(value) {
|
|
240
|
-
this.applyOption(value);
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
/**
|
|
244
|
-
* 监听 loading 状态变化,并同步到底层 ECharts 实例。
|
|
245
|
-
*/
|
|
246
|
-
loading: function loading(value) {
|
|
247
|
-
this.syncLoading(value);
|
|
248
|
-
},
|
|
249
|
-
/**
|
|
250
|
-
* 监听空态切换。
|
|
251
|
-
* 进入空态时立即销毁实例;退出空态时重新初始化并恢复渲染。
|
|
252
|
-
*/
|
|
253
|
-
empty: function empty(value) {
|
|
254
|
-
var _this = this;
|
|
255
|
-
if (value) {
|
|
256
|
-
// 共享运行时核心逻辑:空态出现时立即释放图表实例与窗口监听,避免内存泄漏。
|
|
257
|
-
window.removeEventListener('resize', this.handleResize);
|
|
258
|
-
this.disposeChart();
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
this.$nextTick(function () {
|
|
262
|
-
_this.ensureChart();
|
|
263
|
-
_this.applyOption(_this.option);
|
|
264
|
-
_this.syncLoading(_this.loading);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
/**
|
|
269
|
-
* 组件挂载后按需初始化图表,并同步初始 option / loading。
|
|
270
|
-
*/
|
|
271
|
-
mounted: function mounted() {
|
|
272
|
-
if (this.empty) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
this.ensureChart();
|
|
276
|
-
this.applyOption(this.option);
|
|
277
|
-
this.syncLoading(this.loading);
|
|
278
|
-
},
|
|
279
|
-
/**
|
|
280
|
-
* 组件销毁前释放图表实例与窗口监听,避免内存泄漏。
|
|
281
|
-
*/
|
|
282
|
-
beforeDestroy: function beforeDestroy() {
|
|
283
|
-
window.removeEventListener('resize', this.handleResize);
|
|
284
|
-
this.disposeChart();
|
|
285
|
-
},
|
|
286
|
-
methods: {
|
|
287
|
-
/**
|
|
288
|
-
* 按需初始化 ECharts 实例。
|
|
289
|
-
* 仅在:
|
|
290
|
-
* - 当前还没有实例
|
|
291
|
-
* - 不处于空态
|
|
292
|
-
* - canvas 已挂载
|
|
293
|
-
* 三个条件同时满足时执行。
|
|
294
|
-
*/
|
|
295
|
-
ensureChart: function ensureChart() {
|
|
296
|
-
var _this2 = this;
|
|
297
|
-
if (this.chart || this.empty || !this.$refs.canvas) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// 共享运行时核心逻辑:统一通过 echarts/core 的 init 创建实例,供各业务图表复用。
|
|
302
|
-
this.chart = init(this.$refs.canvas);
|
|
303
|
-
this.chart.on('click', function (params) {
|
|
304
|
-
_this2.$emit('chart-click', params);
|
|
305
|
-
});
|
|
306
|
-
this.$emit('ready', this.chart);
|
|
307
|
-
window.addEventListener('resize', this.handleResize);
|
|
308
|
-
},
|
|
309
|
-
/**
|
|
310
|
-
* 将最新 option 应用到图表实例。
|
|
311
|
-
* 统一使用 notMerge=true 覆盖渲染,避免旧配置残留。
|
|
312
|
-
*/
|
|
313
|
-
applyOption: function applyOption(option) {
|
|
314
|
-
if (!this.chart || this.empty) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
this.chart.setOption(option || {}, true);
|
|
318
|
-
},
|
|
319
|
-
/**
|
|
320
|
-
* 同步 loading 状态到图表实例。
|
|
321
|
-
*/
|
|
322
|
-
syncLoading: function syncLoading(value) {
|
|
323
|
-
if (!this.chart) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (value) {
|
|
327
|
-
this.chart.showLoading();
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
this.chart.hideLoading();
|
|
331
|
-
},
|
|
332
|
-
/**
|
|
333
|
-
* 窗口尺寸变化时触发图表自适应。
|
|
334
|
-
*/
|
|
335
|
-
handleResize: function handleResize() {
|
|
336
|
-
if (this.chart) {
|
|
337
|
-
this.chart.resize();
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
/**
|
|
341
|
-
* 销毁当前图表实例并释放引用。
|
|
342
|
-
* 由 empty 切换、组件销毁等场景统一复用。
|
|
343
|
-
*/
|
|
344
|
-
disposeChart: function disposeChart() {
|
|
345
|
-
if (!this.chart) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
this.chart.dispose();
|
|
349
|
-
this.chart = null;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
var css_248z = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
|
|
355
|
-
styleInject(css_248z);
|
|
356
|
-
|
|
357
|
-
/* script */
|
|
358
|
-
var __vue_script__ = script;
|
|
359
|
-
/* template */
|
|
360
|
-
var __vue_render__ = function __vue_render__() {
|
|
361
|
-
var _vm = this;
|
|
362
|
-
var _h = _vm.$createElement;
|
|
363
|
-
var _c = _vm._self._c || _h;
|
|
364
|
-
return _c("div", {
|
|
365
|
-
staticClass: "base-chart",
|
|
366
|
-
style: _vm.chartStyle
|
|
367
|
-
}, [_vm.empty && !_vm.loading ? _c("BaseEmpty", {
|
|
368
|
-
attrs: {
|
|
369
|
-
text: _vm.emptyText
|
|
370
|
-
}
|
|
371
|
-
}) : _c("div", {
|
|
372
|
-
ref: "canvas",
|
|
373
|
-
staticClass: "base-chart__canvas",
|
|
374
|
-
style: _vm.chartStyle
|
|
375
|
-
})], 1);
|
|
376
|
-
};
|
|
377
|
-
var __vue_staticRenderFns__ = [];
|
|
378
|
-
__vue_render__._withStripped = true;
|
|
379
|
-
|
|
380
|
-
/* style */
|
|
381
|
-
var __vue_inject_styles__ = undefined;
|
|
382
|
-
/* scoped */
|
|
383
|
-
var __vue_scope_id__ = "data-v-4419fdfb";
|
|
384
|
-
/* module identifier */
|
|
385
|
-
var __vue_module_identifier__ = undefined;
|
|
386
|
-
/* functional template */
|
|
387
|
-
var __vue_is_functional_template__ = false;
|
|
388
|
-
/* style inject */
|
|
389
|
-
|
|
390
|
-
/* style inject SSR */
|
|
391
|
-
|
|
392
|
-
/* style inject shadow dom */
|
|
393
|
-
|
|
394
|
-
var __vue_component__ = /*#__PURE__*/normalizeComponent({
|
|
395
|
-
render: __vue_render__,
|
|
396
|
-
staticRenderFns: __vue_staticRenderFns__
|
|
397
|
-
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
398
|
-
var BaseChart = __vue_component__;
|
|
399
|
-
|
|
400
|
-
// 为公开组件补齐 install,供组件级发布入口复用统一注册语义。
|
|
401
|
-
var withInstall = function withInstall(component) {
|
|
402
|
-
if (!component.install) {
|
|
403
|
-
component.install = function (Vue) {
|
|
404
|
-
Vue.component(component.name, component);
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
return component;
|
|
408
|
-
};
|
|
409
|
-
var withInstall$1 = withInstall;
|
|
410
|
-
|
|
411
|
-
export { BaseChart as B, normalizeComponent as n, styleInject as s, withInstall$1 as w };
|