w-plot-vue 1.0.0 → 1.0.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/README.md +4 -4
- package/dist/w-plot-vue.umd.js +7 -0
- package/dist/w-plot-vue.umd.js.map +1 -0
- package/docs/examples/app.html +1 -1
- package/docs/examples/app.umd.js +2 -2
- package/docs/examples/app.umd.js.map +1 -1
- package/docs/examples/w-bar_horizontal_multi-set(color).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set(color, gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set(series color).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set(series color, gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set.html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackNormal).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackPercent).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set__hide legned.html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set__show labels.html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set_barKpColor(gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set_barKpColor.html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set_barUseInnerLabelsForHorizontal_barGroupWidthRatio.html +496 -0
- package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio.html +10 -10
- package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio_barGroupWidthRatio.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set(color).html +10 -10
- package/docs/examples/w-bar_horizontal_one-set(color, gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_one-set.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barColor(gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barColor.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barKpColor(gradient).html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barKpColor.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barUseInnerLabelsForHorizontal.html +493 -0
- package/docs/examples/w-bar_horizontal_one-set_barWidthRatio.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_barWidthRatio_barGroupWidthRatio.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_hide labels.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_marginLeft_marginRight.html +10 -10
- package/docs/examples/w-bar_horizontal_one-set_show legned.html +10 -10
- package/docs/examples/w-bar_multi-set(color).html +10 -10
- package/docs/examples/w-bar_multi-set(color, gradient).html +10 -10
- package/docs/examples/w-bar_multi-set(series color).html +10 -10
- package/docs/examples/w-bar_multi-set(series color, gradient).html +10 -10
- package/docs/examples/w-bar_multi-set.html +10 -10
- package/docs/examples/w-bar_multi-set__barDisplay(stackNormal).html +10 -10
- package/docs/examples/w-bar_multi-set__barDisplay(stackNormal)_.html +10 -10
- package/docs/examples/w-bar_multi-set__barDisplay(stackPercent).html +10 -10
- package/docs/examples/w-bar_multi-set__hide legned.html +10 -10
- package/docs/examples/w-bar_multi-set__show labels.html +10 -10
- package/docs/examples/w-bar_multi-set_barKpColor(gradient).html +10 -10
- package/docs/examples/w-bar_multi-set_barKpColor.html +10 -10
- package/docs/examples/w-bar_multi-set_barWidthRatio.html +10 -10
- package/docs/examples/w-bar_multi-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +10 -10
- package/docs/examples/w-bar_one-set(color).html +10 -10
- package/docs/examples/w-bar_one-set(color, gradient).html +10 -10
- package/docs/examples/w-bar_one-set.html +10 -10
- package/docs/examples/w-bar_one-set_barColor(gradient).html +10 -10
- package/docs/examples/w-bar_one-set_barColor.html +10 -10
- package/docs/examples/w-bar_one-set_barKpColor(gradient).html +10 -10
- package/docs/examples/w-bar_one-set_barKpColor.html +10 -10
- package/docs/examples/w-bar_one-set_barWidthRatio.html +10 -10
- package/docs/examples/w-bar_one-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +10 -10
- package/docs/examples/w-bar_one-set_hide labels.html +10 -10
- package/docs/examples/w-bar_one-set_marginLeft_marginRight_marginTop.html +10 -10
- package/docs/examples/w-bar_one-set_show legned.html +10 -10
- package/docs/examples/w-pie_one-set(color).html +5 -5
- package/docs/examples/w-pie_one-set(color, gradient).html +5 -5
- package/docs/examples/w-pie_one-set.html +5 -5
- package/docs/examples/w-pie_one-set_hide labels.html +5 -5
- package/docs/examples/w-pie_one-set_hide legned.html +5 -5
- package/docs/examples/w-pie_one-set_marginLeft_marginRight_marginTop.html +5 -5
- package/docs/examples/w-pie_one-set_pieBorderRadius.html +5 -5
- package/docs/examples/w-pie_one-set_pieBorderWidth_pieBorderRadius.html +5 -5
- package/docs/examples/w-pie_one-set_pieKpColor(gradient).html +5 -5
- package/docs/examples/w-pie_one-set_pieKpColor.html +5 -5
- package/docs/examples/w-pie_one-set_pieThicknessRatio.html +5 -5
- package/docs/examples/w-plot_default.html +1 -1
- package/docs/examples/w-rose_multi-set(color).html +10 -10
- package/docs/examples/w-rose_multi-set(color, gradient).html +10 -10
- package/docs/examples/w-rose_multi-set(series color).html +10 -10
- package/docs/examples/w-rose_multi-set(series color, gradient).html +10 -10
- package/docs/examples/w-rose_multi-set.html +10 -10
- package/docs/examples/w-rose_multi-set__hide legned.html +10 -10
- package/docs/examples/w-rose_multi-set__show labels.html +10 -10
- package/docs/examples/w-rose_multi-set_roseBorderWidth.html +10 -10
- package/docs/examples/w-rose_multi-set_roseKpColor(gradient).html +10 -10
- package/docs/examples/w-rose_multi-set_roseKpColor.html +10 -10
- package/docs/examples/w-rose_multi-set_roseWidthRatio.html +10 -10
- package/docs/examples/w-rose_one-set(color).html +10 -10
- package/docs/examples/w-rose_one-set(color, gradient).html +10 -10
- package/docs/examples/w-rose_one-set.html +10 -10
- package/docs/examples/w-rose_one-set_marginLeft_marginRight_marginTop.html +10 -10
- package/docs/examples/w-rose_one-set_roseBorderWidth.html +10 -10
- package/docs/examples/w-rose_one-set_roseKpColor(gradient).html +10 -10
- package/docs/examples/w-rose_one-set_roseKpColor.html +10 -10
- package/docs/examples/w-rose_one-set_roseShowLabels.html +10 -10
- package/docs/examples/w-rose_one-set_roseWidthRatio.html +10 -10
- package/docs/examples/w-rose_one-set_showLegend.html +10 -10
- package/docs/examples/w-rose_one-set_showLegend_legendPosition.html +10 -10
- package/docs/examples/w-set-multi_default.html +221 -0
- package/docs/examples/w-set-multi_hide labels.html +222 -0
- package/docs/examples/w-set-multi_hide legned.html +222 -0
- package/docs/examples/w-set-multi_keySelect.html +226 -0
- package/docs/examples/w-set-multi_slot head.html +225 -0
- package/docs/examples/w-set-multi_textPlotType_kpSelectText_widthSelect.html +233 -0
- package/docs/examples/w-set-one_default.html +192 -0
- package/docs/examples/w-set-one_hide labels.html +193 -0
- package/docs/examples/w-set-one_keySelect.html +197 -0
- package/docs/examples/w-set-one_show legned.html +193 -0
- package/docs/examples/w-set-one_slot head.html +196 -0
- package/docs/examples/w-set-one_textPlotType_kpSelectText_widthSelect.html +201 -0
- package/docs/getDefAxis.mjs.html +5 -5
- package/docs/getDefChart.mjs.html +3 -3
- package/docs/getDefLegend.mjs.html +2 -2
- package/docs/getDefOpt.mjs.html +2 -2
- package/docs/global.html +2 -2
- package/docs/index.html +2 -2
- package/docs/module-WBar.html +2 -2
- package/docs/module-WPie.html +2 -2
- package/docs/module-WPlot.html +2 -2
- package/docs/module-WRose.html +2 -2
- package/docs/module-WSetMulti.html +216 -0
- package/docs/module-WSetOne.html +216 -0
- package/docs/setLegendLoc.mjs.html +2 -2
- package/package.json +1 -1
- package/src/App.vue +10 -0
- package/src/AppZoneWBar.vue +50 -9
- package/src/AppZoneWPie.vue +4 -4
- package/src/AppZoneWRose.vue +9 -9
- package/src/AppZoneWSetMulti.vue +225 -0
- package/src/AppZoneWSetOne.vue +193 -0
- package/src/components/WBar.vue +128 -18
- package/src/components/WPie.vue +21 -18
- package/src/components/{WGeoVue.vue → WPlotVue.vue} +8 -4
- package/src/components/WRose.vue +21 -18
- package/src/components/WSetMulti.vue +423 -0
- package/src/components/WSetOne.vue +57 -0
- package/src/js/genBarOpt.mjs +54 -7
- package/src/js/genPieOpt.mjs +1 -1
- package/src/js/genRoseOpt.mjs +1 -1
- package/src/js/getDefAxis.mjs +3 -3
- package/src/js/getDefChart.mjs +1 -1
- package/toolg/gDistRollupComps.mjs +1 -1
- package/toolg/gMergeComps.mjs +4 -4
- package/dist/w-geo-vue.umd.js +0 -7
- package/dist/w-geo-vue.umd.js.map +0 -1
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
import WBar from './WBar.vue'
|
|
3
3
|
import WPie from './WPie.vue'
|
|
4
4
|
import WPlot from './WPlot.vue'
|
|
5
|
-
import WRose from './WRose.vue'
|
|
5
|
+
import WRose from './WRose.vue'
|
|
6
|
+
import WSetMulti from './WSetMulti.vue'
|
|
7
|
+
import WSetOne from './WSetOne.vue'
|
|
6
8
|
|
|
7
|
-
let
|
|
9
|
+
let WPlotVue = {
|
|
8
10
|
install: function(Vue) {
|
|
9
11
|
Vue.component('w-bar', WBar)
|
|
10
12
|
Vue.component('w-pie', WPie)
|
|
11
13
|
Vue.component('w-plot', WPlot)
|
|
12
|
-
Vue.component('w-rose', WRose)
|
|
14
|
+
Vue.component('w-rose', WRose)
|
|
15
|
+
Vue.component('w-set-multi', WSetMulti)
|
|
16
|
+
Vue.component('w-set-one', WSetOne)
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
export default
|
|
20
|
+
export default WPlotVue
|
|
17
21
|
</script>
|
|
18
22
|
|
package/src/components/WRose.vue
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
v-if="hasOptRose"
|
|
5
5
|
>
|
|
6
6
|
|
|
7
|
-
<div :style="`width:${
|
|
7
|
+
<div :style="`width:${picWidth}px; max-width:${picWidth}px;`">
|
|
8
8
|
<slot
|
|
9
9
|
name="top"
|
|
10
10
|
:opt="optRose"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
:options="optRose"
|
|
16
16
|
></WPlot>
|
|
17
17
|
|
|
18
|
-
<div :style="`width:${
|
|
18
|
+
<div :style="`width:${picWidth}px; max-width:${picWidth}px;`">
|
|
19
19
|
<slot
|
|
20
20
|
name="bottom"
|
|
21
21
|
:opt="optRose"
|
|
@@ -54,6 +54,24 @@ export default {
|
|
|
54
54
|
},
|
|
55
55
|
computed: {
|
|
56
56
|
|
|
57
|
+
picWidth: function() {
|
|
58
|
+
let vo = this
|
|
59
|
+
let w = get(vo, 'opt.width', 0)
|
|
60
|
+
return w
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
picHeight: function() {
|
|
64
|
+
let vo = this
|
|
65
|
+
let w = get(vo, 'opt.height', 0)
|
|
66
|
+
return w
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
ks: function() {
|
|
70
|
+
let vo = this
|
|
71
|
+
let ks = get(vo, 'opt.keys', [])
|
|
72
|
+
return ks
|
|
73
|
+
},
|
|
74
|
+
|
|
57
75
|
hasOptRose: function() {
|
|
58
76
|
//console.log('computed hasOptRose')
|
|
59
77
|
|
|
@@ -71,11 +89,8 @@ export default {
|
|
|
71
89
|
|
|
72
90
|
let r = null
|
|
73
91
|
try {
|
|
74
|
-
let w = vo.getWidth()
|
|
75
|
-
let h = vo.getHeight()
|
|
76
|
-
let keys = get(vo, 'opt.keys', [])
|
|
77
92
|
let rds = get(vo, 'opt.rds', [])
|
|
78
|
-
r = genRoseOpt(
|
|
93
|
+
r = genRoseOpt(vo.picWidth, vo.picHeight, vo.ks, rds, vo.opt)
|
|
79
94
|
}
|
|
80
95
|
catch (err) {
|
|
81
96
|
console.log(err)
|
|
@@ -87,18 +102,6 @@ export default {
|
|
|
87
102
|
},
|
|
88
103
|
methods: {
|
|
89
104
|
|
|
90
|
-
getWidth: function() {
|
|
91
|
-
let vo = this
|
|
92
|
-
let w = get(vo, 'opt.width', 0)
|
|
93
|
-
return w
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
getHeight: function() {
|
|
97
|
-
let vo = this
|
|
98
|
-
let w = get(vo, 'opt.height', 0)
|
|
99
|
-
return w
|
|
100
|
-
},
|
|
101
|
-
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
</script>
|
|
@@ -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>
|
package/src/js/genBarOpt.mjs
CHANGED
|
@@ -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
|
|
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
|