w-plot-vue 1.0.0 → 1.0.2

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 (140) hide show
  1. package/README.md +4 -4
  2. package/dist/w-plot-vue.umd.js +7 -0
  3. package/dist/w-plot-vue.umd.js.map +1 -0
  4. package/docs/examples/app.html +1 -1
  5. package/docs/examples/app.umd.js +2 -2
  6. package/docs/examples/app.umd.js.map +1 -1
  7. package/docs/examples/w-bar_horizontal_multi-set(color).html +10 -10
  8. package/docs/examples/w-bar_horizontal_multi-set(color, gradient).html +10 -10
  9. package/docs/examples/w-bar_horizontal_multi-set(series color).html +10 -10
  10. package/docs/examples/w-bar_horizontal_multi-set(series color, gradient).html +10 -10
  11. package/docs/examples/w-bar_horizontal_multi-set.html +10 -10
  12. package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackNormal).html +10 -10
  13. package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackPercent).html +10 -10
  14. package/docs/examples/w-bar_horizontal_multi-set__hide legned.html +10 -10
  15. package/docs/examples/w-bar_horizontal_multi-set__show labels.html +10 -10
  16. package/docs/examples/w-bar_horizontal_multi-set_barKpColor(gradient).html +10 -10
  17. package/docs/examples/w-bar_horizontal_multi-set_barKpColor.html +10 -10
  18. package/docs/examples/w-bar_horizontal_multi-set_barUseInnerLabelsForHorizontal_barGroupWidthRatio.html +496 -0
  19. package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio.html +10 -10
  20. package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio_barGroupWidthRatio.html +10 -10
  21. package/docs/examples/w-bar_horizontal_one-set(color).html +10 -10
  22. package/docs/examples/w-bar_horizontal_one-set(color, gradient).html +10 -10
  23. package/docs/examples/w-bar_horizontal_one-set.html +10 -10
  24. package/docs/examples/w-bar_horizontal_one-set_barColor(gradient).html +10 -10
  25. package/docs/examples/w-bar_horizontal_one-set_barColor.html +10 -10
  26. package/docs/examples/w-bar_horizontal_one-set_barKpColor(gradient).html +10 -10
  27. package/docs/examples/w-bar_horizontal_one-set_barKpColor.html +10 -10
  28. package/docs/examples/w-bar_horizontal_one-set_barUseInnerLabelsForHorizontal.html +493 -0
  29. package/docs/examples/w-bar_horizontal_one-set_barWidthRatio.html +10 -10
  30. package/docs/examples/w-bar_horizontal_one-set_barWidthRatio_barGroupWidthRatio.html +10 -10
  31. package/docs/examples/w-bar_horizontal_one-set_hide labels.html +10 -10
  32. package/docs/examples/w-bar_horizontal_one-set_marginLeft_marginRight.html +10 -10
  33. package/docs/examples/w-bar_horizontal_one-set_show legned.html +10 -10
  34. package/docs/examples/w-bar_multi-set(color).html +10 -10
  35. package/docs/examples/w-bar_multi-set(color, gradient).html +10 -10
  36. package/docs/examples/w-bar_multi-set(series color).html +10 -10
  37. package/docs/examples/w-bar_multi-set(series color, gradient).html +10 -10
  38. package/docs/examples/w-bar_multi-set.html +10 -10
  39. package/docs/examples/w-bar_multi-set__barDisplay(stackNormal).html +10 -10
  40. package/docs/examples/w-bar_multi-set__barDisplay(stackNormal)_.html +10 -10
  41. package/docs/examples/w-bar_multi-set__barDisplay(stackPercent).html +10 -10
  42. package/docs/examples/w-bar_multi-set__hide legned.html +10 -10
  43. package/docs/examples/w-bar_multi-set__show labels.html +10 -10
  44. package/docs/examples/w-bar_multi-set_barKpColor(gradient).html +10 -10
  45. package/docs/examples/w-bar_multi-set_barKpColor.html +10 -10
  46. package/docs/examples/w-bar_multi-set_barWidthRatio.html +10 -10
  47. package/docs/examples/w-bar_multi-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +10 -10
  48. package/docs/examples/w-bar_one-set(color).html +10 -10
  49. package/docs/examples/w-bar_one-set(color, gradient).html +10 -10
  50. package/docs/examples/w-bar_one-set.html +10 -10
  51. package/docs/examples/w-bar_one-set_barColor(gradient).html +10 -10
  52. package/docs/examples/w-bar_one-set_barColor.html +10 -10
  53. package/docs/examples/w-bar_one-set_barKpColor(gradient).html +10 -10
  54. package/docs/examples/w-bar_one-set_barKpColor.html +10 -10
  55. package/docs/examples/w-bar_one-set_barWidthRatio.html +10 -10
  56. package/docs/examples/w-bar_one-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +10 -10
  57. package/docs/examples/w-bar_one-set_hide labels.html +10 -10
  58. package/docs/examples/w-bar_one-set_marginLeft_marginRight_marginTop.html +10 -10
  59. package/docs/examples/w-bar_one-set_show legned.html +10 -10
  60. package/docs/examples/w-pie_one-set(color).html +5 -5
  61. package/docs/examples/w-pie_one-set(color, gradient).html +5 -5
  62. package/docs/examples/w-pie_one-set.html +5 -5
  63. package/docs/examples/w-pie_one-set_hide labels.html +5 -5
  64. package/docs/examples/w-pie_one-set_hide legned.html +5 -5
  65. package/docs/examples/w-pie_one-set_marginLeft_marginRight_marginTop.html +5 -5
  66. package/docs/examples/w-pie_one-set_pieBorderRadius.html +5 -5
  67. package/docs/examples/w-pie_one-set_pieBorderWidth_pieBorderRadius.html +5 -5
  68. package/docs/examples/w-pie_one-set_pieKpColor(gradient).html +5 -5
  69. package/docs/examples/w-pie_one-set_pieKpColor.html +5 -5
  70. package/docs/examples/w-pie_one-set_pieThicknessRatio.html +5 -5
  71. package/docs/examples/w-plot_default.html +1 -1
  72. package/docs/examples/w-rose_multi-set(color).html +10 -10
  73. package/docs/examples/w-rose_multi-set(color, gradient).html +10 -10
  74. package/docs/examples/w-rose_multi-set(series color).html +10 -10
  75. package/docs/examples/w-rose_multi-set(series color, gradient).html +10 -10
  76. package/docs/examples/w-rose_multi-set.html +10 -10
  77. package/docs/examples/w-rose_multi-set__hide legned.html +10 -10
  78. package/docs/examples/w-rose_multi-set__show labels.html +10 -10
  79. package/docs/examples/w-rose_multi-set_roseBorderWidth.html +10 -10
  80. package/docs/examples/w-rose_multi-set_roseKpColor(gradient).html +10 -10
  81. package/docs/examples/w-rose_multi-set_roseKpColor.html +10 -10
  82. package/docs/examples/w-rose_multi-set_roseWidthRatio.html +10 -10
  83. package/docs/examples/w-rose_one-set(color).html +10 -10
  84. package/docs/examples/w-rose_one-set(color, gradient).html +10 -10
  85. package/docs/examples/w-rose_one-set.html +10 -10
  86. package/docs/examples/w-rose_one-set_marginLeft_marginRight_marginTop.html +10 -10
  87. package/docs/examples/w-rose_one-set_roseBorderWidth.html +10 -10
  88. package/docs/examples/w-rose_one-set_roseKpColor(gradient).html +10 -10
  89. package/docs/examples/w-rose_one-set_roseKpColor.html +10 -10
  90. package/docs/examples/w-rose_one-set_roseShowLabels.html +10 -10
  91. package/docs/examples/w-rose_one-set_roseWidthRatio.html +10 -10
  92. package/docs/examples/w-rose_one-set_showLegend.html +10 -10
  93. package/docs/examples/w-rose_one-set_showLegend_legendPosition.html +10 -10
  94. package/docs/examples/w-set-multi_default.html +221 -0
  95. package/docs/examples/w-set-multi_hide labels.html +222 -0
  96. package/docs/examples/w-set-multi_hide legned.html +222 -0
  97. package/docs/examples/w-set-multi_keySelect.html +226 -0
  98. package/docs/examples/w-set-multi_slot head.html +225 -0
  99. package/docs/examples/w-set-multi_textPlotType_kpSelectText_widthSelect.html +233 -0
  100. package/docs/examples/w-set-one_default.html +192 -0
  101. package/docs/examples/w-set-one_hide labels.html +193 -0
  102. package/docs/examples/w-set-one_keySelect.html +197 -0
  103. package/docs/examples/w-set-one_show legned.html +193 -0
  104. package/docs/examples/w-set-one_slot head.html +196 -0
  105. package/docs/examples/w-set-one_textPlotType_kpSelectText_widthSelect.html +201 -0
  106. package/docs/getDefAxis.mjs.html +5 -5
  107. package/docs/getDefChart.mjs.html +3 -3
  108. package/docs/getDefLegend.mjs.html +2 -2
  109. package/docs/getDefOpt.mjs.html +2 -2
  110. package/docs/global.html +2 -2
  111. package/docs/index.html +2 -2
  112. package/docs/module-WBar.html +2 -2
  113. package/docs/module-WPie.html +2 -2
  114. package/docs/module-WPlot.html +2 -2
  115. package/docs/module-WRose.html +2 -2
  116. package/docs/module-WSetMulti.html +216 -0
  117. package/docs/module-WSetOne.html +216 -0
  118. package/docs/setLegendLoc.mjs.html +2 -2
  119. package/package.json +1 -1
  120. package/src/App.vue +224 -20
  121. package/src/AppZoneWBar.vue +50 -9
  122. package/src/AppZoneWPie.vue +4 -4
  123. package/src/AppZoneWRose.vue +9 -9
  124. package/src/AppZoneWSetMulti.vue +225 -0
  125. package/src/AppZoneWSetOne.vue +193 -0
  126. package/src/components/WBar.vue +128 -18
  127. package/src/components/WPie.vue +21 -18
  128. package/src/components/{WGeoVue.vue → WPlotVue.vue} +8 -4
  129. package/src/components/WRose.vue +21 -18
  130. package/src/components/WSetMulti.vue +423 -0
  131. package/src/components/WSetOne.vue +57 -0
  132. package/src/js/genBarOpt.mjs +54 -7
  133. package/src/js/genPieOpt.mjs +1 -1
  134. package/src/js/genRoseOpt.mjs +1 -1
  135. package/src/js/getDefAxis.mjs +3 -3
  136. package/src/js/getDefChart.mjs +1 -1
  137. package/toolg/gDistRollupComps.mjs +1 -1
  138. package/toolg/gMergeComps.mjs +4 -4
  139. package/dist/w-geo-vue.umd.js +0 -7
  140. package/dist/w-geo-vue.umd.js.map +0 -1
@@ -0,0 +1,423 @@
1
+ <template>
2
+ <div
3
+ style="display:inline-block;"
4
+ :changeTypeItems="changeTypeItems"
5
+ :changeKeySelect="changeKeySelect"
6
+ >
7
+
8
+ <div style="padding-bottom:5px;">
9
+
10
+ <div style="display:flex; align-items:flex-end;">
11
+
12
+ <div :style="``">
13
+ <slot name="head"></slot>
14
+ </div>
15
+
16
+ <div style="display:flex; align-items:center;">
17
+
18
+ <div style="padding-right:10px; font-size:0.85rem; color:#666;">
19
+ {{textPlotType}}:
20
+ </div>
21
+
22
+ <WTextSelect
23
+ :style="`width:${widthSelect}px;`"
24
+ :paddingStyle="{v:3,h:10}"
25
+ :borderRadius="4"
26
+ :items="typeItems"
27
+ :value="typeSelect"
28
+ @input="updateTypeSelectAndEmitKeySelect"
29
+ ></WTextSelect>
30
+
31
+ </div>
32
+
33
+ </div>
34
+
35
+ </div>
36
+
37
+ <div
38
+ name="tarp"
39
+ v-if="hasOptTar"
40
+ >
41
+
42
+ <component
43
+ :is="cmp"
44
+ :opt="optTar"
45
+ ></component>
46
+
47
+ </div>
48
+
49
+ </div>
50
+ </template>
51
+
52
+ <script>
53
+ import get from 'lodash-es/get'
54
+ import each from 'lodash-es/each'
55
+ import merge from 'lodash-es/merge'
56
+ import size from 'lodash-es/size'
57
+ import capitalize from 'lodash-es/capitalize'
58
+ import cloneDeep from 'lodash-es/cloneDeep'
59
+ import haskey from 'wsemi/src/haskey.mjs'
60
+ import iseobj from 'wsemi/src/iseobj.mjs'
61
+ import WTextSelect from 'w-component-vue/src/components/WTextSelect.vue'
62
+ import WBar from './WBar.vue'
63
+ import WPie from './WPie.vue'
64
+ import WRose from './WRose.vue'
65
+
66
+
67
+ /**
68
+ * @vue-prop {Object} [opt={}] 輸入設定物件,預設{}
69
+ */
70
+ export default {
71
+ components: {
72
+ WTextSelect,
73
+ WBar,
74
+ WPie,
75
+ WRose,
76
+ },
77
+ props: {
78
+ mode: {
79
+ type: String,
80
+ default: 'multi',
81
+ },
82
+ opt: {
83
+ type: Object,
84
+ default: () => {},
85
+ },
86
+ textPlotType: {
87
+ type: String,
88
+ default: 'Plot type',
89
+ },
90
+ widthSelect: {
91
+ type: Number,
92
+ default: 260,
93
+ },
94
+ keySelect: {
95
+ type: String,
96
+ default: 'bar-v-normal',
97
+ },
98
+ kpSelectText: {
99
+ type: Object,
100
+ default: () => {},
101
+ },
102
+ },
103
+ data: function() {
104
+ return {
105
+
106
+ typeItemsDefOne: [
107
+
108
+ {
109
+ key: 'bar-v-normal',
110
+ type: 'bar',
111
+ text: 'Vertical bars',
112
+ optExt: {},
113
+ },
114
+
115
+ {
116
+ key: 'bar-h-normal',
117
+ type: 'bar',
118
+ text: 'Horizontal bars',
119
+ optExt: {
120
+ direction: 'horizontal',
121
+ marginLeft: 80,
122
+ legendPosition: 'bottomright',
123
+ },
124
+ },
125
+ {
126
+ key: 'bar-h-normal-dense',
127
+ type: 'bar',
128
+ text: 'Horizontal bars with dense',
129
+ optExt: {
130
+ direction: 'horizontal',
131
+ marginLeft: 80,
132
+ legendPosition: 'bottomright',
133
+ barUseInnerLabelsForHorizontal: true,
134
+ },
135
+ },
136
+
137
+ {
138
+ key: 'pie-normal',
139
+ type: 'pie',
140
+ text: 'Pies',
141
+ optExt: {},
142
+ },
143
+
144
+ {
145
+ key: 'rose-normal',
146
+ type: 'rose',
147
+ text: 'Roses',
148
+ optExt: {},
149
+ },
150
+
151
+ ],
152
+
153
+ typeItemsDefMulti: [
154
+
155
+ {
156
+ key: 'bar-v-normal',
157
+ type: 'bar',
158
+ text: 'Vertical bars',
159
+ optExt: {},
160
+ },
161
+ {
162
+ key: 'bar-v-stack-normal',
163
+ type: 'bar',
164
+ text: 'Vertical bars with normal stack',
165
+ optExt: {
166
+ barDisplay: 'stackNormal',
167
+ },
168
+ },
169
+ {
170
+ key: 'bar-v-stack-percent',
171
+ type: 'bar',
172
+ text: 'Vertical bars with percent stack',
173
+ optExt: {
174
+ barDisplay: 'stackPercent',
175
+ },
176
+ },
177
+
178
+ {
179
+ key: 'bar-h-normal',
180
+ type: 'bar',
181
+ text: 'Horizontal bars',
182
+ optExt: {
183
+ direction: 'horizontal',
184
+ marginLeft: 80,
185
+ legendPosition: 'bottomright',
186
+ },
187
+ },
188
+ {
189
+ key: 'bar-h-normal-dense',
190
+ type: 'bar',
191
+ text: 'Horizontal bars with dense',
192
+ optExt: {
193
+ direction: 'horizontal',
194
+ marginLeft: 80,
195
+ legendPosition: 'bottomright',
196
+ barUseInnerLabelsForHorizontal: true,
197
+ barGroupWidthRatio: 0.25,
198
+ },
199
+ },
200
+ {
201
+ key: 'bar-h-stack-normal',
202
+ type: 'bar',
203
+ text: 'Horizontal bars with normal stack',
204
+ optExt: {
205
+ direction: 'horizontal',
206
+ marginLeft: 80,
207
+ legendPosition: 'bottomright',
208
+ barDisplay: 'stackNormal',
209
+ },
210
+ },
211
+ {
212
+ key: 'bar-h-stack-percent',
213
+ type: 'bar',
214
+ text: 'Horizontal bars with percent stack',
215
+ optExt: {
216
+ direction: 'horizontal',
217
+ marginLeft: 80,
218
+ legendPosition: 'bottomright',
219
+ barDisplay: 'stackPercent',
220
+ },
221
+ },
222
+
223
+ {
224
+ key: 'rose-normal',
225
+ type: 'rose',
226
+ text: 'Roses',
227
+ optExt: {},
228
+ },
229
+
230
+ ],
231
+
232
+ typeItems: [],
233
+
234
+ keySelectTrans: null,
235
+ typeSelect: null,
236
+
237
+ }
238
+ },
239
+ computed: {
240
+
241
+ typeItemsDef: function() {
242
+ let vo = this
243
+ if (vo.mode === 'one') {
244
+ return vo.typeItemsDefOne
245
+ }
246
+ return vo.typeItemsDefMulti
247
+ },
248
+
249
+ changeTypeItems: function() {
250
+ let vo = this
251
+
252
+ //typeItems
253
+ let typeItems = []
254
+ if (!iseobj(vo.kpSelectText)) {
255
+ typeItems = vo.typeItemsDef
256
+ }
257
+ else {
258
+ each(vo.typeItemsDef, (v) => {
259
+ if (!haskey(vo.kpSelectText, v.key)) {
260
+ return true //跳出換下一個
261
+ }
262
+ let text = vo.kpSelectText[v.key]
263
+ typeItems.push({
264
+ ...v,
265
+ text,
266
+ })
267
+ })
268
+ }
269
+ // console.log('kpSelectText', vo.kpSelectText)
270
+ // console.log('typeItems', typeItems)
271
+
272
+ //save
273
+ vo.typeItems = typeItems
274
+
275
+ return ''
276
+ },
277
+
278
+ changeKeySelect: function() {
279
+ let vo = this
280
+
281
+ //updateTypeSelectByKey
282
+ vo.updateTypeSelectByKey(vo.keySelect)
283
+
284
+ return ''
285
+ },
286
+
287
+ picWidth: function() {
288
+ let vo = this
289
+ let w = get(vo, 'opt.width', 0)
290
+ return w
291
+ },
292
+
293
+ picHeight: function() {
294
+ let vo = this
295
+ let w = get(vo, 'opt.height', 0)
296
+ return w
297
+ },
298
+
299
+ ks: function() {
300
+ let vo = this
301
+ let ks = get(vo, 'opt.keys', [])
302
+ return ks
303
+ },
304
+
305
+ hasOptTar: function() {
306
+ let vo = this
307
+ let b = iseobj(vo.optTar)
308
+ return b
309
+ },
310
+
311
+ cmp: function() {
312
+ let vo = this
313
+ let type = get(vo, 'typeSelect.type', '')
314
+ type = capitalize(type)
315
+ return `W${type}`
316
+ },
317
+
318
+ optTar: function() {
319
+ // console.log('computed optTar')
320
+
321
+ let vo = this
322
+
323
+ //showLabels
324
+ let showLabels = get(vo, 'opt.showLabels', true)
325
+ let barShowLabels = showLabels
326
+ let pieShowLabels = showLabels
327
+ let roseShowLabels = showLabels
328
+
329
+ //showLegend
330
+ let showLegend = get(vo, 'opt.showLegend', false)
331
+
332
+ //rds
333
+ let rds = get(vo, 'opt.rds', [])
334
+
335
+ //nrds
336
+ let nrds = size(rds)
337
+
338
+ //check
339
+ if (nrds === 0) {
340
+ console.log('no data, size(opt.rds)=0')
341
+ return null
342
+ }
343
+ else if (vo.mode === 'one' && nrds > 1) {
344
+ console.log('size(opt.rds)>1')
345
+ rds = [rds[0]]
346
+ }
347
+
348
+ //opt
349
+ let opt = null
350
+ try {
351
+
352
+ //opt
353
+ opt = vo.opt
354
+ opt = cloneDeep(opt)
355
+ let optExt = get(vo, 'typeSelect.optExt', {})
356
+ optExt = cloneDeep(optExt)
357
+ let optSet = {
358
+ barShowLabels,
359
+ pieShowLabels,
360
+ roseShowLabels,
361
+ showLegend,
362
+ }
363
+ opt = merge(opt, optExt)
364
+ opt = merge(opt, optSet)
365
+ // console.log('opt', opt)
366
+
367
+ }
368
+ catch (err) {
369
+ console.log(err)
370
+ }
371
+
372
+ return opt
373
+ },
374
+
375
+ },
376
+ methods: {
377
+
378
+ updateTypeSelectByKey: function(keySelect) {
379
+ let vo = this
380
+
381
+ //save keySelectTrans
382
+ vo.keySelectTrans = keySelect
383
+
384
+ //typeSelect
385
+ let typeSelect = null
386
+ each(vo.typeItems, (v) => {
387
+ if (v.key === keySelect) {
388
+ typeSelect = v
389
+ return false //跳出
390
+ }
391
+ })
392
+
393
+ //save
394
+ vo.typeSelect = typeSelect
395
+ // console.log('typeSelect', typeSelect)
396
+
397
+ },
398
+
399
+ updateTypeSelectAndEmitKeySelect: function(typeSelect) {
400
+ let vo = this
401
+
402
+ //save typeSelect
403
+ vo.typeSelect = typeSelect
404
+ // console.log('typeSelect', typeSelect)
405
+
406
+ //keySelect
407
+ let keySelect = get(typeSelect, 'key', '')
408
+ // console.log('keySelect', keySelect)
409
+
410
+ //updateTypeSelectByKey
411
+ vo.updateTypeSelectByKey(keySelect)
412
+
413
+ //emit
414
+ vo.$emit('update:keySelect', keySelect)
415
+
416
+ },
417
+
418
+ },
419
+ }
420
+ </script>
421
+
422
+ <style scoped>
423
+ </style>
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <WSetMulti
3
+ v-bind="{...$props,mode:'one'}"
4
+ v-on="$listeners"
5
+ >
6
+ <template v-slot:head>
7
+ <slot name="head"></slot>
8
+ </template>
9
+ </WSetMulti>
10
+ </template>
11
+
12
+ <script>
13
+ import WSetMulti from './WSetMulti.vue'
14
+
15
+
16
+ /**
17
+ * @vue-prop {Object} [opt={}] 輸入設定物件,預設{}
18
+ */
19
+ export default {
20
+ components: {
21
+ WSetMulti,
22
+ },
23
+ props: {
24
+ opt: {
25
+ type: Object,
26
+ default: () => {},
27
+ },
28
+ textPlotType: {
29
+ type: String,
30
+ default: 'Plot type',
31
+ },
32
+ widthSelect: {
33
+ type: Number,
34
+ default: 215,
35
+ },
36
+ keySelect: {
37
+ type: String,
38
+ default: 'bar-v-normal',
39
+ },
40
+ kpSelectText: {
41
+ type: Object,
42
+ default: () => {},
43
+ },
44
+ },
45
+ data: function() {
46
+ return {
47
+ }
48
+ },
49
+ computed: {
50
+ },
51
+ methods: {
52
+ },
53
+ }
54
+ </script>
55
+
56
+ <style scoped>
57
+ </style>
@@ -4,6 +4,7 @@ import each from 'lodash-es/each'
4
4
  import size from 'lodash-es/size'
5
5
  import merge from 'lodash-es/merge'
6
6
  import isNumber from 'lodash-es/isNumber'
7
+ // import range from 'lodash-es/range'
7
8
  // import cloneDeep from 'lodash-es/cloneDeep'
8
9
  import haskey from 'wsemi/src/haskey.mjs'
9
10
  // import isestr from 'wsemi/src/isestr.mjs'
@@ -26,6 +27,9 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
26
27
 
27
28
  //direction
28
29
  let direction = get(optPlot, 'direction', 'vertical')
30
+ if (direction !== 'vertical' && direction !== 'horizontal') {
31
+ direction = 'vertical'
32
+ }
29
33
 
30
34
  //xTitle
31
35
  let xTitle = get(optPlot, 'xTitle', '')
@@ -72,6 +76,9 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
72
76
  //barShowLabels
73
77
  let barShowLabels = get(optPlot, 'barShowLabels', true)
74
78
 
79
+ //barUseInnerLabelsForHorizontal
80
+ let barUseInnerLabelsForHorizontal = get(optPlot, 'barUseInnerLabelsForHorizontal', false)
81
+
75
82
  //showLegend
76
83
  let showLegend = get(optPlot, 'showLegend', false)
77
84
 
@@ -177,8 +184,9 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
177
184
  let _dax1 = getDefAxis(optPlot)
178
185
  let _dax2 = {
179
186
  categories,
180
- crosshair: true,
181
- panningEnabled: false,
187
+ // crosshair: true,
188
+ // panningEnabled: false,
189
+ // tickmarkPlacement: 'on',
182
190
  labels: {
183
191
  allowOverlap: true,
184
192
  // autoRotationLimit: 0,
@@ -190,18 +198,20 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
190
198
  // dax.min = xmin
191
199
  // dax.max = xmax
192
200
  // if (!isestr(xtitle)) {
193
- // dax.labels.formatter = function () {
201
+ // dax.labels.formatter = function (hc) {
194
202
  // return ''
195
203
  // }
196
204
  // }
197
- dax.opposite = false
198
205
  // console.log('dax', dax)
199
206
 
200
207
  //day
201
- let day = getDefAxis(optPlot)
208
+ let _day1 = getDefAxis(optPlot)
209
+ let _day2 = {
210
+ // tickmarkPlacement: 'on',
211
+ }
212
+ let day = merge(_day1, _day2)
202
213
  day.title.text = yTitle
203
214
  day.min = 0 //從0開始
204
- // day.opposite = false
205
215
  // console.log('day', day)
206
216
 
207
217
  //dlg
@@ -255,6 +265,43 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
255
265
  // console.log('optHc(margin)', optHc)
256
266
  }
257
267
 
268
+ //stackPercent
269
+ if (barDisplay === 'stackPercent') {
270
+ if (direction === 'vertical') {
271
+ optHc.chart.marginLeft += 11
272
+ }
273
+ optHc.yAxis.labels.formatter = (hc) => {
274
+ return `${hc.value}%`
275
+ }
276
+ }
277
+
278
+ //horizontal, 會影響marginLeft故放margin後面
279
+ if (direction === 'horizontal' && barUseInnerLabelsForHorizontal) {
280
+ optHc.chart.marginLeft = 40
281
+ optHc.xAxis.title.margin = 21
282
+ optHc.xAxis.labels.enabled = false
283
+ // optHc.xAxis.startOnTick = true
284
+ // optHc.xAxis.endOnTick = true
285
+ optHc.xAxis.tickWidth = 0
286
+ // optHc.xAxis.gridLineWidth = 0
287
+ // optHc.xAxis.minorGridLineWidth = 0
288
+ optHc.xAxis.min = -0.25
289
+ // optHc.xAxis.max = size(categories) - 1 - 0.25
290
+ optHc.xAxis.tickInterval = 1
291
+ // optHc.xAxis.tickAmount = size(categories)
292
+ // optHc.xAxis.tickPositions = range(-1, size(categories))
293
+ // optHc.xAxis.tickPosition = 'outside'
294
+ optHc.xAxis.plotLines = [ //因highcharts的tick是between, 且min設定-0.25, 故無法繪製位置-0.5的gridLine, 得另外補畫
295
+ {
296
+ color: optHc.xAxis.gridLineColor,
297
+ width: optHc.xAxis.gridLineWidth,
298
+ value: -0.5,
299
+ // dashStyle: 'LongDash',
300
+ // zIndex: 1,
301
+ },
302
+ ]
303
+ }
304
+
258
305
  //column
259
306
  if (true) {
260
307
  optHc.plotOptions = {
@@ -284,7 +331,7 @@ function genBarOpt(width, height, keys, rds, optPlot = {}) {
284
331
  // console.log('optHc(column)', optHc)
285
332
  }
286
333
 
287
- //legend
334
+ //legend, 會使用margin故放最後
288
335
  if (true) {
289
336
 
290
337
  //setLegendLoc
@@ -211,7 +211,7 @@ function genPieOpt(width, height, keys, rds, optPlot = {}) {
211
211
  // console.log('optHc(pie)', optHc)
212
212
  }
213
213
 
214
- //legend
214
+ //legend, 會使用margin故放最後
215
215
  if (true) {
216
216
 
217
217
  //setLegendLoc
@@ -275,7 +275,7 @@ function genPieOpt(width, height, keys, rds, optPlot = {}) {
275
275
  // console.log('optHc(rose)', optHc)
276
276
  }
277
277
 
278
- //legend
278
+ //legend, 會使用margin故放最後
279
279
  if (true) {
280
280
 
281
281
  //setLegendLoc
@@ -45,11 +45,11 @@ function getDefAxis(opt = {}) {
45
45
  fontSize: labelFontSize,
46
46
  color: labelColor,
47
47
  },
48
- formatter: function() {
48
+ formatter: function(hc) {
49
49
  if (vDig) {
50
- return dig(this.value, vDig)
50
+ return dig(hc.value, vDig)
51
51
  }
52
- return this.value
52
+ return hc.value
53
53
  },
54
54
  },
55
55
 
@@ -13,7 +13,7 @@ function getDefChart(opt = {}) {
13
13
  let marginLeftShift = get(opt, 'marginLeftShift', 60)
14
14
  let marginRightShift = get(opt, 'marginRightShift', 0)
15
15
  let marginTopShift = get(opt, 'marginTopShift', 10)
16
- let marginBottomShift = get(opt, 'marginBottomShift', 50)
16
+ let marginBottomShift = get(opt, 'marginBottomShift', 60)
17
17
 
18
18
  //spacingLeft
19
19
  let spacingLeft = get(opt, 'spacingLeft', 0)
@@ -7,7 +7,7 @@ let fdTar = './dist'
7
7
 
8
8
 
9
9
  rollupFiles({
10
- fns: 'WGeoVue.vue',
10
+ fns: 'WPlotVue.vue',
11
11
  fdSrc,
12
12
  fdTar,
13
13
  nameDistType: 'kebabCase',
@@ -5,11 +5,11 @@ import getFiles from 'w-package-tools/src/getFiles.mjs'
5
5
 
6
6
 
7
7
  let fdSrc = './src/components/'
8
- let fn_tar = 'WGeoVue.vue'
8
+ let fn_tar = 'WPlotVue.vue'
9
9
 
10
10
 
11
11
  function main() {
12
- //讀取components裡面組件, 自動生成WGeoVue, 供rollup打包整體組件
12
+ //讀取components裡面組件, 自動生成WPlotVue, 供rollup打包整體組件
13
13
 
14
14
  //getFiles
15
15
  let ltfs = getFiles(fdSrc)
@@ -56,13 +56,13 @@ function main() {
56
56
  `<script>
57
57
  ${_.join(c1, '\r\n')}
58
58
 
59
- let WGeoVue = {
59
+ let WPlotVue = {
60
60
  install: function(Vue) {
61
61
  ${_.join(c2, '\r\n')}
62
62
  }
63
63
  }
64
64
 
65
- export default WGeoVue
65
+ export default WPlotVue
66
66
  </script>
67
67
 
68
68
  `