w-echarts-vue 1.0.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.
Files changed (81) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +130 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +16 -0
  9. package/dist/w-echarts-vue.umd.js +30 -0
  10. package/dist/w-echarts-vue.umd.js.map +1 -0
  11. package/docs/components_WEchartsVue.vue.html +420 -0
  12. package/docs/examples/app.html +62 -0
  13. package/docs/examples/app.umd.js +31 -0
  14. package/docs/examples/app.umd.js.map +1 -0
  15. package/docs/examples/w-echarts-vue_area.html +1733 -0
  16. package/docs/examples/w-echarts-vue_bar3D.html +1733 -0
  17. package/docs/examples/w-echarts-vue_continuous.html +1733 -0
  18. package/docs/examples/w-echarts-vue_heatmap.html +1733 -0
  19. package/docs/examples/w-echarts-vue_line.html +1733 -0
  20. package/docs/examples/w-echarts-vue_line3D.html +1733 -0
  21. package/docs/examples/w-echarts-vue_parallel.html +1733 -0
  22. package/docs/examples/w-echarts-vue_polar heatmap.html +1733 -0
  23. package/docs/examples/w-echarts-vue_polar.html +1733 -0
  24. package/docs/examples/w-echarts-vue_radar.html +1733 -0
  25. package/docs/examples/w-echarts-vue_resize.html +1746 -0
  26. package/docs/examples/w-echarts-vue_scatter.html +1733 -0
  27. package/docs/examples/w-echarts-vue_stack.html +1733 -0
  28. package/docs/examples/w-echarts-vue_surface.html +1733 -0
  29. package/docs/examples/w-echarts-vue_tree.html +1736 -0
  30. package/docs/examples/w-echarts-vue_treemap.html +1734 -0
  31. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  33. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  34. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  35. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  36. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  37. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  38. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  44. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  45. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  46. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  47. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  48. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  49. package/docs/global.html +281 -0
  50. package/docs/index.html +84 -0
  51. package/docs/js_iniEcharts.mjs.html +104 -0
  52. package/docs/module-WEchartsVue.html +1006 -0
  53. package/docs/scripts/collapse.js +39 -0
  54. package/docs/scripts/commonNav.js +28 -0
  55. package/docs/scripts/linenumber.js +25 -0
  56. package/docs/scripts/nav.js +12 -0
  57. package/docs/scripts/polyfill.js +4 -0
  58. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  59. package/docs/scripts/prettify/lang-css.js +2 -0
  60. package/docs/scripts/prettify/prettify.js +28 -0
  61. package/docs/scripts/search.js +99 -0
  62. package/docs/styles/jsdoc.css +776 -0
  63. package/docs/styles/prettify.css +80 -0
  64. package/package.json +70 -0
  65. package/public/index.html +31 -0
  66. package/script.txt +22 -0
  67. package/src/App.vue +180 -0
  68. package/src/AppZoneWEchartsVue.vue +1171 -0
  69. package/src/components/WEchartsVue.vue +348 -0
  70. package/src/js/iniEcharts.mjs +32 -0
  71. package/src/main.js +8 -0
  72. package/test/all.test.mjs +10 -0
  73. package/toolg/addVersion.mjs +4 -0
  74. package/toolg/cleanFolder.mjs +5 -0
  75. package/toolg/cvCasename.mjs +43 -0
  76. package/toolg/gDistApp.mjs +35 -0
  77. package/toolg/gDistRollupComps.mjs +24 -0
  78. package/toolg/gDocExams.mjs +47 -0
  79. package/toolg/gExtractHtml.mjs +285 -0
  80. package/toolg/modifyReadme.mjs +4 -0
  81. package/vue.config.js +27 -0
@@ -0,0 +1,420 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <title>components/WEchartsVue.vue - Documentation</title>
7
+
8
+
9
+ <script src="scripts/prettify/prettify.js"></script>
10
+ <script src="scripts/prettify/lang-css.js"></script>
11
+ <!--[if lt IE 9]>
12
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
13
+ <![endif]-->
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
19
+ </head>
20
+ <body>
21
+
22
+ <input type="checkbox" id="nav-trigger" class="nav-trigger" />
23
+ <label for="nav-trigger" class="navicon-button x">
24
+ <div class="navicon"></div>
25
+ </label>
26
+
27
+ <label for="nav-trigger" class="overlay"></label>
28
+
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-WEchartsVue.html">WEchartsVue</a><ul class='methods'><li data-type='method'><a href="module-WEchartsVue.html#bindResize">bindResize</a></li><li data-type='method'><a href="module-WEchartsVue.html#clear">clear</a></li><li data-type='method'><a href="module-WEchartsVue.html#clearResize">clearResize</a></li><li data-type='method'><a href="module-WEchartsVue.html#getChart">getChart</a></li><li data-type='method'><a href="module-WEchartsVue.html#init">init</a></li><li data-type='method'><a href="module-WEchartsVue.html#reinit">reinit</a></li><li data-type='method'><a href="module-WEchartsVue.html#updateLoading">updateLoading</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#iniEcharts">iniEcharts</a></li></ul>
33
+
34
+ </nav>
35
+
36
+ <div id="main">
37
+
38
+ <h1 class="page-title">components/WEchartsVue.vue</h1>
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ <section>
47
+ <article>
48
+ <pre class="prettyprint source linenums"><code>&lt;template>
49
+ &lt;!-- ref=$self為供外部存取繪圖容器之用; 寬高由外部以style給予 -->
50
+ &lt;div ref="$self" class="w-echarts-vue">&lt;/div>
51
+ &lt;/template>
52
+
53
+ &lt;script>
54
+ import { throttle } from 'echarts/core'
55
+ import iniEcharts from '../js/iniEcharts.mjs'
56
+
57
+
58
+ //echarts, 直接引用echarts與echarts-gl不使用cdn
59
+ //注意: 本組件直接以echarts原生API實作生命週期(init, setOption, resize, dispose)與事件轉發,
60
+ //不使用vue-echarts, 因其runtime依賴vue-demi, 而vue-demi出廠為Vue3模式須靠postinstall切換,
61
+ //npm>=12/pnpm>=10/bun預設封鎖依賴套件install scripts, 下游以src方式引用本套件時會靜默停在Vue3模式而壞掉;
62
+ //直接實作後全依賴樹零install script, 下游任意套件管理器與打包器皆零設定可用
63
+ let echarts = iniEcharts()
64
+
65
+
66
+ /**
67
+ * echarts繪圖組件, 已內含echarts全量圖表與組件, 以及echarts-gl之3D圖表(bar3D, line3D, scatter3D, surface等), 不須自cdn額外引用
68
+ *
69
+ * 注意: 組件本身不帶預設高度, 須由外部給予寬高(例如style="width:620px; height:300px;"), 否則因高度為0而看不見圖形
70
+ *
71
+ * @vue-prop {Object} [options={}] 輸入echarts設定物件,即echarts之option,預設{}。變更時自動重繪:給予新物件(參照改變)採整體置換(notMerge),原物件內變更(mutation)採合併更新,與vue-echarts語意一致
72
+ * @vue-prop {String|Object} [theme=''] 輸入echarts主題字串或主題設定物件,字串為已使用echarts.registerTheme註冊之主題名稱,變更時會自動銷毀重建圖表,預設''
73
+ * @vue-prop {Object} [initOptions={}] 輸入echarts初始化設定物件,即echarts.init之opts,可設定renderer('canvas'或'svg')、locale、devicePixelRatio等,變更時會自動銷毀重建圖表,預設{}
74
+ * @vue-prop {Object} [updateOptions={}] 輸入echarts更新設定物件,即echarts之setOption之opts,可設定notMerge、replaceMerge、lazyUpdate等,預設{}
75
+ * @vue-prop {String} [group=''] 輸入圖表群組名稱字串,供echarts.connect跨圖表連動使用,預設''
76
+ * @vue-prop {Boolean} [manualUpdate=false] 輸入是否關閉options之深度監聽布林值,若為true則變更options不會自動重繪,須自行取得實例呼叫setOption更新,適用於資料量龐大時,預設false
77
+ * @vue-prop {Boolean} [loading=false] 輸入是否顯示讀取中動畫布林值,預設false
78
+ * @vue-prop {Object} [loadingOptions={}] 輸入讀取中動畫設定物件,即echarts之showLoading之opts,可設定text、color、maskColor等,預設{}
79
+ * @vue-prop {Boolean|Object} [autoresize=true] 輸入是否於容器尺寸改變時自動重繪布林值,亦可給物件設定{throttle,onResize},throttle為節流毫秒數預設100,預設true
80
+ * @vue-event {Object} * 對外轉發echarts之全部事件,例如click、mouseover、legendselectchanged、datazoom、finished等,回傳事件參數物件;zrender事件以zr:前綴綁定,例如@zr:click
81
+ */
82
+ export default {
83
+ props: {
84
+ options: {
85
+ type: Object,
86
+ default: () => {},
87
+ },
88
+ theme: {
89
+ type: [String, Object],
90
+ default: () => '',
91
+ },
92
+ initOptions: {
93
+ type: Object,
94
+ default: () => {},
95
+ },
96
+ updateOptions: {
97
+ type: Object,
98
+ default: () => {},
99
+ },
100
+ group: {
101
+ type: String,
102
+ default: () => '',
103
+ },
104
+ manualUpdate: {
105
+ type: Boolean,
106
+ default: () => false,
107
+ },
108
+ loading: {
109
+ type: Boolean,
110
+ default: () => false,
111
+ },
112
+ loadingOptions: {
113
+ type: Object,
114
+ default: () => {},
115
+ },
116
+ autoresize: {
117
+ type: [Boolean, Object],
118
+ default: () => true,
119
+ },
120
+ },
121
+ data: function() {
122
+ //chart與resizeObserver為echarts實例與瀏覽器原生物件, 不可放入data,
123
+ //否則Vue會對其深層響應化(遞迴defineProperty), 造成效能問題, 故於init時直接掛this成非響應式屬性
124
+ return {
125
+ }
126
+ },
127
+ mounted: function() {
128
+ //console.log('mounted')
129
+
130
+ let vo = this
131
+
132
+ //init
133
+ vo.init()
134
+
135
+ },
136
+ beforeDestroy: function() {
137
+ //console.log('beforeDestroy')
138
+
139
+ let vo = this
140
+
141
+ //clear
142
+ vo.clear()
143
+
144
+ },
145
+ watch: {
146
+
147
+ options: {
148
+ deep: true,
149
+ handler: function(nv, ov) {
150
+ let vo = this
151
+
152
+ //manualUpdate, 關閉自動重繪
153
+ if (vo.manualUpdate) {
154
+ return
155
+ }
156
+
157
+ //check
158
+ if (!vo.chart) {
159
+ return
160
+ }
161
+
162
+ //setOption, 參照改變(給予新物件)採整體置換, 原物件內變更採合併更新, 與vue-echarts語意一致
163
+ vo.chart.setOption(nv || {}, { notMerge: nv !== ov, ...vo.updateOptions })
164
+
165
+ },
166
+ },
167
+
168
+ theme: function() {
169
+ this.reinit()
170
+ },
171
+
172
+ initOptions: {
173
+ deep: true,
174
+ handler: function() {
175
+ this.reinit()
176
+ },
177
+ },
178
+
179
+ group: function(nv) {
180
+ let vo = this
181
+ if (vo.chart) {
182
+ vo.chart.group = nv || ''
183
+ }
184
+ },
185
+
186
+ loading: function() {
187
+ this.updateLoading()
188
+ },
189
+
190
+ loadingOptions: {
191
+ deep: true,
192
+ handler: function() {
193
+ this.updateLoading()
194
+ },
195
+ },
196
+
197
+ autoresize: function() {
198
+ let vo = this
199
+ vo.clearResize()
200
+ vo.bindResize()
201
+ },
202
+
203
+ },
204
+ computed: {
205
+ },
206
+ methods: {
207
+
208
+ /**
209
+ * 初始化圖表, 建立echarts實例並綁定事件, 讀取中動畫與尺寸監聽(內部使用)
210
+ */
211
+ init: function() {
212
+ let vo = this
213
+
214
+ //el
215
+ let el = vo.$refs['$self']
216
+ if (!el) {
217
+ return
218
+ }
219
+
220
+ //init
221
+ let chart = echarts.init(el, vo.theme || null, vo.initOptions || {})
222
+
223
+ //chart, 掛this成非響應式屬性
224
+ vo.chart = chart
225
+
226
+ //group
227
+ if (vo.group) {
228
+ chart.group = vo.group
229
+ }
230
+
231
+ //setOption
232
+ chart.setOption(vo.options || {}, vo.updateOptions || {})
233
+
234
+ //事件轉發, 由$listeners綁定echarts事件, zr:前綴綁定zrender事件
235
+ Object.keys(vo.$listeners || {}).forEach((key) => {
236
+
237
+ //k, 剝除Vue事件修飾前綴(~為once, &amp;為passive, !為capture)
238
+ let k = key.replace(/^[~!&amp;]+/, '')
239
+
240
+ //fn
241
+ let fn = vo.$listeners[key]
242
+
243
+ //on
244
+ if (k.indexOf('zr:') === 0) {
245
+ chart.getZr().on(k.slice(3), fn)
246
+ }
247
+ else {
248
+ chart.on(k, fn)
249
+ }
250
+
251
+ })
252
+
253
+ //updateLoading
254
+ vo.updateLoading()
255
+
256
+ //bindResize
257
+ vo.bindResize()
258
+
259
+ },
260
+
261
+ /**
262
+ * 銷毀並重建圖表, 供theme或initOptions變更時使用(內部使用)
263
+ */
264
+ reinit: function() {
265
+ let vo = this
266
+
267
+ //clear
268
+ vo.clear()
269
+
270
+ //init
271
+ vo.init()
272
+
273
+ },
274
+
275
+ /**
276
+ * 更新讀取中動畫(內部使用)
277
+ */
278
+ updateLoading: function() {
279
+ let vo = this
280
+
281
+ //check
282
+ if (!vo.chart) {
283
+ return
284
+ }
285
+
286
+ //showLoading, hideLoading
287
+ if (vo.loading) {
288
+ vo.chart.showLoading('default', vo.loadingOptions || {})
289
+ }
290
+ else {
291
+ vo.chart.hideLoading()
292
+ }
293
+
294
+ },
295
+
296
+ /**
297
+ * 綁定容器尺寸監聽, 尺寸改變時自動重繪(內部使用)
298
+ */
299
+ bindResize: function() {
300
+ let vo = this
301
+
302
+ //check
303
+ if (!vo.autoresize || !vo.chart) {
304
+ return
305
+ }
306
+
307
+ //el
308
+ let el = vo.$refs['$self']
309
+ if (!el) {
310
+ return
311
+ }
312
+
313
+ //wait, onResize
314
+ let opt = (vo.autoresize === true) ? {} : vo.autoresize
315
+ let wait = Number.isFinite(opt.throttle) ? opt.throttle : 100
316
+ let onResize = opt.onResize
317
+
318
+ //callback, 重繪並通知外部
319
+ let callback = () => {
320
+ if (!vo.chart) {
321
+ return
322
+ }
323
+ vo.chart.resize()
324
+ if (typeof onResize === 'function') {
325
+ onResize()
326
+ }
327
+ }
328
+ if (wait > 0) {
329
+ callback = throttle(callback, wait)
330
+ }
331
+
332
+ //resizeObserver, 掛this成非響應式屬性, 首次observe必觸發一次callback故跳過
333
+ let bFirst = true
334
+ vo.resizeObserver = new ResizeObserver(() => {
335
+ if (bFirst) {
336
+ bFirst = false
337
+ return
338
+ }
339
+ callback()
340
+ })
341
+ vo.resizeObserver.observe(el)
342
+
343
+ },
344
+
345
+ /**
346
+ * 解除容器尺寸監聽(內部使用)
347
+ */
348
+ clearResize: function() {
349
+ let vo = this
350
+
351
+ //disconnect
352
+ if (vo.resizeObserver) {
353
+ vo.resizeObserver.disconnect()
354
+ vo.resizeObserver = null
355
+ }
356
+
357
+ },
358
+
359
+ /**
360
+ * 銷毀圖表與監聽(內部使用)
361
+ */
362
+ clear: function() {
363
+ let vo = this
364
+
365
+ //clearResize
366
+ vo.clearResize()
367
+
368
+ //dispose
369
+ if (vo.chart) {
370
+ vo.chart.dispose()
371
+ vo.chart = null
372
+ }
373
+
374
+ },
375
+
376
+ /**
377
+ * 取得內部echarts實例, 供外部呼叫echarts原生方法(setOption, resize, getDataURL, dispatchAction等)之用
378
+ * 因echarts實例於組件掛載後才建立, 故初始化前呼叫會回傳null
379
+ *
380
+ * @returns {Object|null} 回傳echarts實例物件, 若尚未初始化則回傳null
381
+ */
382
+ getChart: function() {
383
+ let vo = this
384
+ return vo.chart || null
385
+ },
386
+
387
+ },
388
+ }
389
+ &lt;/script>
390
+
391
+ &lt;style scoped>
392
+ .w-echarts-vue {
393
+ display: block;
394
+ }
395
+ &lt;/style>
396
+ </code></pre>
397
+ </article>
398
+ </section>
399
+
400
+
401
+
402
+
403
+
404
+
405
+ </div>
406
+
407
+ <br class="clear">
408
+
409
+ <footer>
410
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 19 2026 22:33:39 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
411
+ </footer>
412
+
413
+ <script>prettyPrint();</script>
414
+ <script src="scripts/polyfill.js"></script>
415
+ <script src="scripts/linenumber.js"></script>
416
+
417
+
418
+
419
+ </body>
420
+ </html>
@@ -0,0 +1,62 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
7
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
+ <title>w-echarts-vue</title>
9
+
10
+ <!-- @babel/polyfill已廢棄 -->
11
+ <script nomodule src="https://cdn.jsdelivr.net/npm/@babel/polyfill@7.12.1/dist/polyfill.min.js"></script>
12
+
13
+ <!-- vue -->
14
+ <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.min.js"></script>
15
+
16
+
17
+
18
+ <!-- rollupVueToHtml已自動添加@babel/polyfill與vue -->
19
+
20
+ <!-- fontawesome -->
21
+ <link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
22
+
23
+ <!-- mdi, 各組件使用mdi/js故不需引用 -->
24
+ <link _href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
25
+
26
+ <!-- google, 各組件使用mdi/js故不需引用 -->
27
+ <link _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
28
+ <link _href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
29
+
30
+ <!-- data -->
31
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataAAPL.js"></script>
32
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataUSD2EUR.js"></script>
33
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataHousePriceArea.js"></script>
34
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataFlare.js"></script>
35
+
36
+
37
+
38
+ <!-- app -->
39
+ <script src="app.umd.js?1787150020751"></script>
40
+
41
+ </head>
42
+ <body style="font-family:'Microsoft JhengHei','Avenir','Helvetica'; padding:0px; margin:0px;">
43
+
44
+ <div id="app">
45
+ <w-app></w-app>
46
+ </div>
47
+
48
+ <script>
49
+
50
+ //install app
51
+ Vue.component('w-app',app)
52
+
53
+ //initialize
54
+ new Vue({
55
+ el: '#app',
56
+
57
+ })
58
+
59
+ </script>
60
+
61
+ </body>
62
+ </html>