w-plot-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 (172) 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 +89 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +15 -0
  9. package/dist/w-geo-vue.umd.js +7 -0
  10. package/dist/w-geo-vue.umd.js.map +1 -0
  11. package/docs/examples/app.html +65 -0
  12. package/docs/examples/app.umd.js +7 -0
  13. package/docs/examples/app.umd.js.map +1 -0
  14. package/docs/examples/w-bar_horizontal_multi-set(color).html +492 -0
  15. package/docs/examples/w-bar_horizontal_multi-set(color, gradient).html +492 -0
  16. package/docs/examples/w-bar_horizontal_multi-set(series color).html +492 -0
  17. package/docs/examples/w-bar_horizontal_multi-set(series color, gradient).html +492 -0
  18. package/docs/examples/w-bar_horizontal_multi-set.html +492 -0
  19. package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackNormal).html +495 -0
  20. package/docs/examples/w-bar_horizontal_multi-set__barDisplay(stackPercent).html +496 -0
  21. package/docs/examples/w-bar_horizontal_multi-set__hide legned.html +492 -0
  22. package/docs/examples/w-bar_horizontal_multi-set__show labels.html +492 -0
  23. package/docs/examples/w-bar_horizontal_multi-set_barKpColor(gradient).html +508 -0
  24. package/docs/examples/w-bar_horizontal_multi-set_barKpColor.html +506 -0
  25. package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio.html +493 -0
  26. package/docs/examples/w-bar_horizontal_multi-set_barWidthRatio_barGroupWidthRatio.html +498 -0
  27. package/docs/examples/w-bar_horizontal_one-set(color).html +490 -0
  28. package/docs/examples/w-bar_horizontal_one-set(color, gradient).html +490 -0
  29. package/docs/examples/w-bar_horizontal_one-set.html +490 -0
  30. package/docs/examples/w-bar_horizontal_one-set_barColor(gradient).html +491 -0
  31. package/docs/examples/w-bar_horizontal_one-set_barColor.html +491 -0
  32. package/docs/examples/w-bar_horizontal_one-set_barKpColor(gradient).html +500 -0
  33. package/docs/examples/w-bar_horizontal_one-set_barKpColor.html +498 -0
  34. package/docs/examples/w-bar_horizontal_one-set_barWidthRatio.html +491 -0
  35. package/docs/examples/w-bar_horizontal_one-set_barWidthRatio_barGroupWidthRatio.html +496 -0
  36. package/docs/examples/w-bar_horizontal_one-set_hide labels.html +491 -0
  37. package/docs/examples/w-bar_horizontal_one-set_marginLeft_marginRight.html +495 -0
  38. package/docs/examples/w-bar_horizontal_one-set_show legned.html +491 -0
  39. package/docs/examples/w-bar_multi-set(color).html +489 -0
  40. package/docs/examples/w-bar_multi-set(color, gradient).html +489 -0
  41. package/docs/examples/w-bar_multi-set(series color).html +489 -0
  42. package/docs/examples/w-bar_multi-set(series color, gradient).html +489 -0
  43. package/docs/examples/w-bar_multi-set.html +489 -0
  44. package/docs/examples/w-bar_multi-set__barDisplay(stackNormal).html +490 -0
  45. package/docs/examples/w-bar_multi-set__barDisplay(stackNormal)_.html +492 -0
  46. package/docs/examples/w-bar_multi-set__barDisplay(stackPercent).html +491 -0
  47. package/docs/examples/w-bar_multi-set__hide legned.html +489 -0
  48. package/docs/examples/w-bar_multi-set__show labels.html +489 -0
  49. package/docs/examples/w-bar_multi-set_barKpColor(gradient).html +503 -0
  50. package/docs/examples/w-bar_multi-set_barKpColor.html +503 -0
  51. package/docs/examples/w-bar_multi-set_barWidthRatio.html +490 -0
  52. package/docs/examples/w-bar_multi-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +495 -0
  53. package/docs/examples/w-bar_one-set(color).html +487 -0
  54. package/docs/examples/w-bar_one-set(color, gradient).html +487 -0
  55. package/docs/examples/w-bar_one-set.html +487 -0
  56. package/docs/examples/w-bar_one-set_barColor(gradient).html +488 -0
  57. package/docs/examples/w-bar_one-set_barColor.html +488 -0
  58. package/docs/examples/w-bar_one-set_barKpColor(gradient).html +495 -0
  59. package/docs/examples/w-bar_one-set_barKpColor.html +495 -0
  60. package/docs/examples/w-bar_one-set_barWidthRatio.html +488 -0
  61. package/docs/examples/w-bar_one-set_barWidthRatio_barGroupWidthRatio_barBorderRadius.html +493 -0
  62. package/docs/examples/w-bar_one-set_hide labels.html +488 -0
  63. package/docs/examples/w-bar_one-set_marginLeft_marginRight_marginTop.html +493 -0
  64. package/docs/examples/w-bar_one-set_show legned.html +488 -0
  65. package/docs/examples/w-pie_one-set(color).html +251 -0
  66. package/docs/examples/w-pie_one-set(color, gradient).html +251 -0
  67. package/docs/examples/w-pie_one-set.html +251 -0
  68. package/docs/examples/w-pie_one-set_hide labels.html +252 -0
  69. package/docs/examples/w-pie_one-set_hide legned.html +252 -0
  70. package/docs/examples/w-pie_one-set_marginLeft_marginRight_marginTop.html +257 -0
  71. package/docs/examples/w-pie_one-set_pieBorderRadius.html +252 -0
  72. package/docs/examples/w-pie_one-set_pieBorderWidth_pieBorderRadius.html +253 -0
  73. package/docs/examples/w-pie_one-set_pieKpColor(gradient).html +259 -0
  74. package/docs/examples/w-pie_one-set_pieKpColor.html +259 -0
  75. package/docs/examples/w-pie_one-set_pieThicknessRatio.html +252 -0
  76. package/docs/examples/w-plot_default.html +174 -0
  77. package/docs/examples/w-rose_multi-set(color).html +489 -0
  78. package/docs/examples/w-rose_multi-set(color, gradient).html +489 -0
  79. package/docs/examples/w-rose_multi-set(series color).html +489 -0
  80. package/docs/examples/w-rose_multi-set(series color, gradient).html +489 -0
  81. package/docs/examples/w-rose_multi-set.html +489 -0
  82. package/docs/examples/w-rose_multi-set__hide legned.html +489 -0
  83. package/docs/examples/w-rose_multi-set__show labels.html +489 -0
  84. package/docs/examples/w-rose_multi-set_roseBorderWidth.html +490 -0
  85. package/docs/examples/w-rose_multi-set_roseKpColor(gradient).html +503 -0
  86. package/docs/examples/w-rose_multi-set_roseKpColor.html +503 -0
  87. package/docs/examples/w-rose_multi-set_roseWidthRatio.html +490 -0
  88. package/docs/examples/w-rose_one-set(color).html +487 -0
  89. package/docs/examples/w-rose_one-set(color, gradient).html +487 -0
  90. package/docs/examples/w-rose_one-set.html +487 -0
  91. package/docs/examples/w-rose_one-set_marginLeft_marginRight_marginTop.html +493 -0
  92. package/docs/examples/w-rose_one-set_roseBorderWidth.html +488 -0
  93. package/docs/examples/w-rose_one-set_roseKpColor(gradient).html +495 -0
  94. package/docs/examples/w-rose_one-set_roseKpColor.html +495 -0
  95. package/docs/examples/w-rose_one-set_roseShowLabels.html +488 -0
  96. package/docs/examples/w-rose_one-set_roseWidthRatio.html +488 -0
  97. package/docs/examples/w-rose_one-set_showLegend.html +488 -0
  98. package/docs/examples/w-rose_one-set_showLegend_legendPosition.html +489 -0
  99. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  100. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  101. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  102. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  103. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  104. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  105. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  106. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  107. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  108. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  109. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  110. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  111. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  112. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  113. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  114. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  115. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  116. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  117. package/docs/getDefAxis.mjs.html +157 -0
  118. package/docs/getDefChart.mjs.html +123 -0
  119. package/docs/getDefLegend.mjs.html +115 -0
  120. package/docs/getDefOpt.mjs.html +137 -0
  121. package/docs/global.html +1088 -0
  122. package/docs/index.html +84 -0
  123. package/docs/module-WBar.html +216 -0
  124. package/docs/module-WPie.html +216 -0
  125. package/docs/module-WPlot.html +216 -0
  126. package/docs/module-WRose.html +216 -0
  127. package/docs/scripts/collapse.js +39 -0
  128. package/docs/scripts/commonNav.js +28 -0
  129. package/docs/scripts/linenumber.js +25 -0
  130. package/docs/scripts/nav.js +12 -0
  131. package/docs/scripts/polyfill.js +4 -0
  132. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  133. package/docs/scripts/prettify/lang-css.js +2 -0
  134. package/docs/scripts/prettify/prettify.js +28 -0
  135. package/docs/scripts/search.js +99 -0
  136. package/docs/setLegendLoc.mjs.html +176 -0
  137. package/docs/styles/jsdoc.css +776 -0
  138. package/docs/styles/prettify.css +80 -0
  139. package/g.mjs +0 -0
  140. package/package.json +68 -0
  141. package/public/index.html +38 -0
  142. package/src/App.vue +118 -0
  143. package/src/AppZoneWBar.vue +1454 -0
  144. package/src/AppZoneWPie.vue +324 -0
  145. package/src/AppZoneWPlot.vue +78 -0
  146. package/src/AppZoneWRose.vue +735 -0
  147. package/src/components/WBar.vue +107 -0
  148. package/src/components/WGeoVue.vue +18 -0
  149. package/src/components/WPie.vue +107 -0
  150. package/src/components/WPlot.vue +86 -0
  151. package/src/components/WRose.vue +107 -0
  152. package/src/components/demolink.vue +105 -0
  153. package/src/js/genBarOpt.mjs +303 -0
  154. package/src/js/genPieOpt.mjs +233 -0
  155. package/src/js/genRoseOpt.mjs +297 -0
  156. package/src/js/getDefAxis.mjs +85 -0
  157. package/src/js/getDefChart.mjs +51 -0
  158. package/src/js/getDefLegend.mjs +43 -0
  159. package/src/js/getDefOpt.mjs +65 -0
  160. package/src/js/setLegendLoc.mjs +104 -0
  161. package/src/main.js +8 -0
  162. package/test/all.test.mjs +10 -0
  163. package/toolg/addVersion.mjs +4 -0
  164. package/toolg/cleanFolder.mjs +4 -0
  165. package/toolg/cvCasename.mjs +43 -0
  166. package/toolg/gDistApp.mjs +38 -0
  167. package/toolg/gDistRollupComps.mjs +21 -0
  168. package/toolg/gDocExams.mjs +47 -0
  169. package/toolg/gExtractHtml.mjs +263 -0
  170. package/toolg/gMergeComps.mjs +75 -0
  171. package/toolg/modifyReadme.mjs +4 -0
  172. package/vue.config.js +21 -0
@@ -0,0 +1,297 @@
1
+ import get from 'lodash-es/get'
2
+ import map from 'lodash-es/map'
3
+ import each from 'lodash-es/each'
4
+ import size from 'lodash-es/size'
5
+ import merge from 'lodash-es/merge'
6
+ import isNumber from 'lodash-es/isNumber'
7
+ // import cloneDeep from 'lodash-es/cloneDeep'
8
+ import haskey from 'wsemi/src/haskey.mjs'
9
+ // import isestr from 'wsemi/src/isestr.mjs'
10
+ import iseobj from 'wsemi/src/iseobj.mjs'
11
+ import isearr from 'wsemi/src/isearr.mjs'
12
+ import getDefOpt from './getDefOpt.mjs'
13
+ import getDefChart from './getDefChart.mjs'
14
+ import getDefAxis from './getDefAxis.mjs'
15
+ import getDefLegend from './getDefLegend.mjs'
16
+ import setLegendLoc from './setLegendLoc.mjs'
17
+
18
+
19
+ function genPieOpt(width, height, keys, rds, optPlot = {}) {
20
+
21
+ //marginLeft, marginRight, marginTop, marginBottom
22
+ let marginLeft = get(optPlot, 'marginLeft', null)
23
+ let marginRight = get(optPlot, 'marginRight', null)
24
+ let marginTop = get(optPlot, 'marginTop', null)
25
+ let marginBottom = get(optPlot, 'marginBottom', null)
26
+
27
+ //xLabelFontSize
28
+ let xLabelFontSize = get(optPlot, 'xLabelFontSize', '10pt')
29
+
30
+ //yTitle
31
+ let yTitle = get(optPlot, 'yTitle', '')
32
+
33
+ //yTitleFontSize
34
+ let yTitleFontSize = get(optPlot, 'yTitleFontSize', '10pt')
35
+
36
+ //yTitleColor
37
+ let yTitleColor = get(optPlot, 'yTitleColor', '#444')
38
+
39
+ //yLabelFontSize
40
+ let yLabelFontSize = get(optPlot, 'yLabelFontSize', '8pt')
41
+
42
+ //yLabelColor
43
+ let yLabelColor = get(optPlot, 'yLabelColor', '#888')
44
+
45
+ //roseKpColor
46
+ let roseKpColor = get(optPlot, 'roseKpColor', undefined)
47
+
48
+ //roseWidthRatio
49
+ let roseWidthRatio = get(optPlot, 'roseWidthRatio', 0.25)
50
+
51
+ //roseBorderWidth
52
+ let roseBorderWidth = get(optPlot, 'roseBorderWidth', 1)
53
+
54
+ //roseShowLabels
55
+ let roseShowLabels = get(optPlot, 'roseShowLabels', false)
56
+
57
+ //showLegend
58
+ let showLegend = get(optPlot, 'showLegend', false)
59
+
60
+ //categories
61
+ let categories = keys
62
+ // console.log('categories', categories)
63
+
64
+ //gvc
65
+ let gvc = (color) => {
66
+ if (isearr(color)) {
67
+ let n = size(color)
68
+ if (n === 1) {
69
+ color = color[0]
70
+ }
71
+ else {
72
+ let stops = map(color, (c, kc) => {
73
+ return [kc / (n - 1), c]
74
+ })
75
+ color = {
76
+ linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
77
+ stops,
78
+ }
79
+ }
80
+ }
81
+ return color
82
+ }
83
+
84
+ //ds
85
+ let ds = []
86
+ each(rds, (rd, krd) => {
87
+
88
+ //name
89
+ let name = get(rd, 'name', '')
90
+ // console.log('name', name)
91
+
92
+ //_color1
93
+ let _color1 = null
94
+
95
+ //_color2
96
+ let _color2 = get(rd, 'color', undefined)
97
+
98
+ //_data
99
+ let _data = get(rd, 'data', {})
100
+
101
+ //data
102
+ let colorFirst = null
103
+ let data = []
104
+ each(keys, (k) => {
105
+
106
+ //vo
107
+ let vo = get(_data, k, null)
108
+
109
+ //v
110
+ let v = vo
111
+ if (iseobj(v)) {
112
+ if (!haskey(v, 'value')) {
113
+ throw new Error('rose data is an object but no value')
114
+ }
115
+ v = get(v, 'value', null)
116
+ }
117
+ // console.log(k, v)
118
+
119
+ //_color3, _color4, _color5
120
+ let _color3 = get(roseKpColor, k, undefined)
121
+ let _color4 = get(roseKpColor, `${krd}.${k}`, undefined)
122
+ let _color5 = get(vo, 'color', undefined)
123
+
124
+ //color
125
+ let color = gvc(_color1 || _color2 || _color3 || _color4 || _color5) //指定各rose顏色
126
+
127
+ if (colorFirst === null) {
128
+ colorFirst = color
129
+ }
130
+
131
+ //push
132
+ data.push({
133
+ name: k,
134
+ y: v,
135
+ color,
136
+ })
137
+
138
+ })
139
+ // console.log('colorFirst', colorFirst)
140
+ // console.log('data', data)
141
+
142
+ //push
143
+ ds.push({
144
+ name,
145
+ data,
146
+ color: colorFirst,
147
+ })
148
+
149
+ })
150
+ // console.log('ds', ds)
151
+
152
+ //dopt
153
+ let dopt = getDefOpt(optPlot)
154
+
155
+ //dct
156
+ let dct = getDefChart({
157
+ ...optPlot,
158
+ space: 40,
159
+ marginLeftShift: 0,
160
+ marginRightShift: 0,
161
+ marginTopShift: 0,
162
+ marginBottomShift: 0,
163
+ plotBorderColor: 'transparent',
164
+ })
165
+ // console.log('dct', dct)
166
+
167
+ //dax
168
+ let _dax1 = getDefAxis({
169
+ ...optPlot,
170
+ labelFontSize: xLabelFontSize,
171
+ })
172
+ let _dax2 = {
173
+ categories,
174
+ // crosshair: true,
175
+ // panningEnabled: false,
176
+ labels: {
177
+ allowOverlap: true,
178
+ // autoRotationLimit: 0,
179
+ // rotation: 50,
180
+ },
181
+ }
182
+ let dax = merge(_dax1, _dax2)
183
+ // console.log('dax', dax)
184
+
185
+ //day
186
+ let _day1 = getDefAxis({
187
+ ...optPlot,
188
+ titleFontSize: yTitleFontSize,
189
+ titleColor: yTitleColor,
190
+ labelFontSize: yLabelFontSize,
191
+ labelColor: yLabelColor,
192
+ })
193
+ let _day2 = {
194
+ // reversedStacks: false,
195
+ }
196
+ let day = merge(_day1, _day2)
197
+ day.title.text = yTitle
198
+ day.min = 0 //從0開始
199
+ // console.log('day', day)
200
+
201
+ //dlg
202
+ let dlg = getDefLegend(optPlot)
203
+ // console.log('dlg', dlg)
204
+
205
+ //optHc
206
+ let optHc = {
207
+ ...dopt,
208
+
209
+ chart: {
210
+ ...dct,
211
+ polar: true,
212
+ type: 'column',
213
+ width,
214
+ height,
215
+ },
216
+
217
+ xAxis: dax,
218
+
219
+ yAxis: day,
220
+
221
+ legend: dlg,
222
+
223
+ series: ds,
224
+
225
+ }
226
+
227
+ //margin
228
+ if (true) {
229
+ if (isNumber(marginLeft)) {
230
+ optHc.chart.marginLeft = marginLeft
231
+ }
232
+ if (isNumber(marginRight)) {
233
+ optHc.chart.marginRight = marginRight
234
+ }
235
+ if (isNumber(marginTop)) {
236
+ optHc.chart.marginTop = marginTop
237
+ }
238
+ if (isNumber(marginBottom)) {
239
+ optHc.chart.marginBottom = marginBottom
240
+ }
241
+ // console.log('optHc(margin)', optHc)
242
+ }
243
+
244
+ //rose
245
+ if (true) {
246
+ optHc.plotOptions = {
247
+ ...optHc.plotOptions,
248
+
249
+ series: {
250
+ stacking: 'normal',
251
+ groupPadding: 0,
252
+ pointPadding: roseWidthRatio,
253
+ // pointWidth: rosePointWidth,
254
+ borderWidth: roseBorderWidth,
255
+ dataLabels: {
256
+ enabled: roseShowLabels,
257
+ allowOverlap: true,
258
+ align: 'center',
259
+ // distance: 50,
260
+ // crop: false,
261
+ // inside: false,
262
+ // overflow: 'allow',
263
+ // position: 'left',
264
+ y: -10,
265
+ // format: `
266
+ // <div style="width:50px;">
267
+ // <div style="font-weight:bold;">{point.name}</div>
268
+ // <div style="opacity:0.6;">{point.y}</div>
269
+ // </div>
270
+ // `,
271
+ },
272
+ },
273
+
274
+ }
275
+ // console.log('optHc(rose)', optHc)
276
+ }
277
+
278
+ //legend
279
+ if (true) {
280
+
281
+ //setLegendLoc
282
+ optHc = setLegendLoc(optHc, {
283
+ ...optPlot,
284
+ legendIgnoreMargin: true,
285
+ })
286
+
287
+ //showLegend
288
+ optHc.legend.enabled = showLegend
289
+
290
+ // console.log('optHc(legend)', optHc)
291
+ }
292
+
293
+ return optHc
294
+ }
295
+
296
+
297
+ export default genPieOpt
@@ -0,0 +1,85 @@
1
+ import get from 'lodash-es/get'
2
+ import dig from 'wsemi/src/dig.mjs'
3
+
4
+
5
+ /**
6
+ * 產生預設Highcharts軸物件
7
+ *
8
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
9
+ * @returns {Object} 回傳物件
10
+ */
11
+ function getDefAxis(opt = {}) {
12
+ //預設軸物件
13
+
14
+ let softMax = get(opt, 'softMax')
15
+ let vDig = get(opt, 'vDig')
16
+
17
+ let titleFontFamily = get(opt, 'titleFontFamily', '微軟正黑體')
18
+ let titleFontSize = get(opt, 'titleFontSize', '12pt')
19
+ let titleColor = get(opt, 'titleColor', '#000')
20
+
21
+ let labelFontFamily = get(opt, 'labelFontFamily', '微軟正黑體')
22
+ let labelFontSize = get(opt, 'labelFontSize', '9pt')
23
+ let labelColor = get(opt, 'labelColor', '#222')
24
+
25
+ let obj = {
26
+
27
+ crosshair: true,
28
+
29
+ title: {
30
+ useHTML: true,
31
+ text: '',
32
+ style: {
33
+ fontFamily: titleFontFamily,
34
+ fontSize: titleFontSize,
35
+ color: titleColor,
36
+ },
37
+ },
38
+
39
+ softMax,
40
+
41
+ labels: {
42
+ autoRotation: false,
43
+ style: {
44
+ fontFamily: labelFontFamily,
45
+ fontSize: labelFontSize,
46
+ color: labelColor,
47
+ },
48
+ formatter: function() {
49
+ if (vDig) {
50
+ return dig(this.value, vDig)
51
+ }
52
+ return this.value
53
+ },
54
+ },
55
+
56
+ lineColor: '#666',
57
+ lineWidth: 1,
58
+
59
+ //tickInterval: 0.2,
60
+ gridLineColor: '#eeeeee',
61
+ gridLineWidth: 1,
62
+
63
+ //minorTickInterval: 0.1,
64
+ minorGridLineColor: '#eeeeee',
65
+ minorGridLineWidth: 1,
66
+
67
+ tickPosition: 'inside',
68
+ tickColor: '#222222',
69
+ tickWidth: 1,
70
+ tickLength: 5,
71
+
72
+ minorTickPosition: 'inside',
73
+ minorTickColor: '#222222',
74
+ minorTickWidth: 1,
75
+ minorTickLength: 5,
76
+
77
+ //opposite: false,
78
+
79
+ }
80
+
81
+ return obj
82
+ }
83
+
84
+
85
+ export default getDefAxis
@@ -0,0 +1,51 @@
1
+ import get from 'lodash-es/get'
2
+
3
+
4
+ /**
5
+ * 產生預設Highcharts圖物件
6
+ *
7
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
8
+ * @returns {Object} 回傳物件
9
+ */
10
+ function getDefChart(opt = {}) {
11
+
12
+ //marginLeftShift, marginRightShift, marginTopShift, marginBottomShift
13
+ let marginLeftShift = get(opt, 'marginLeftShift', 60)
14
+ let marginRightShift = get(opt, 'marginRightShift', 0)
15
+ let marginTopShift = get(opt, 'marginTopShift', 10)
16
+ let marginBottomShift = get(opt, 'marginBottomShift', 50)
17
+
18
+ //spacingLeft
19
+ let spacingLeft = get(opt, 'spacingLeft', 0)
20
+ let spacingRight = get(opt, 'spacingRight', 0)
21
+ let spacingTop = get(opt, 'spacingTop', 0)
22
+ let spacingBottom = get(opt, 'spacingBottom', 0)
23
+
24
+ //plotBorderColor
25
+ let plotBorderColor = get(opt, 'plotBorderColor', '#666')
26
+
27
+ //plotBorderWidth
28
+ let plotBorderWidth = get(opt, 'plotBorderWidth', 1)
29
+
30
+ //sp, 邊緣最少5px以上, 否則曲線圖標貼框時會被裁切
31
+ let sp = get(opt, 'space', 5)
32
+
33
+ let obj = {
34
+ animation: false, //關閉動畫
35
+ plotBorderColor,
36
+ plotBorderWidth,
37
+ marginLeft: sp + marginLeftShift,
38
+ marginRight: sp + marginRightShift,
39
+ marginTop: sp + marginTopShift,
40
+ marginBottom: sp + marginBottomShift,
41
+ spacingLeft,
42
+ spacingRight,
43
+ spacingTop,
44
+ spacingBottom,
45
+ }
46
+
47
+ return obj
48
+ }
49
+
50
+
51
+ export default getDefChart
@@ -0,0 +1,43 @@
1
+ import get from 'lodash-es/get'
2
+
3
+
4
+ /**
5
+ * 產生預設Highcharts圖例物件
6
+ *
7
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
8
+ * @returns {Object} 回傳物件
9
+ */
10
+ function getDefLegend(opt = {}) {
11
+
12
+ let legnedFontFamily = get(opt, 'legnedFontFamily', '微軟正黑體')
13
+ let legnedFontSize = get(opt, 'legnedFontSize', '9pt')
14
+ let legnedColor = get(opt, 'legnedColor', '#222')
15
+
16
+ let legendBackgroundColor = get(opt, 'legendBackgroundColor', 'rgba(255,255,255,0.75)')
17
+ let legnedBorderColor = get(opt, 'legnedBorderColor', '#aaa')
18
+
19
+ let obj = {
20
+ useHTML: true,
21
+ enabled: true,
22
+ shared: true,
23
+ floating: true,
24
+ layout: 'vertical',
25
+ // align: 'right',
26
+ // verticalAlign: 'top',
27
+ // x: -5,
28
+ // y: 5,
29
+ backgroundColor: legendBackgroundColor,
30
+ borderColor: legnedBorderColor,
31
+ borderWidth: 1,
32
+ itemStyle: {
33
+ fontFamily: legnedFontFamily,
34
+ fontSize: legnedFontSize,
35
+ color: legnedColor,
36
+ },
37
+ }
38
+
39
+ return obj
40
+ }
41
+
42
+
43
+ export default getDefLegend
@@ -0,0 +1,65 @@
1
+ import get from 'lodash-es/get'
2
+
3
+
4
+ /**
5
+ * 產生預設Highcharts設定物件
6
+ *
7
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
8
+ * @returns {Object} 回傳物件
9
+ */
10
+ function getDefOpt(opt = {}) {
11
+
12
+ //useTooltip
13
+ let useTooltip = get(opt, 'useTooltip', true)
14
+
15
+ //useLegend
16
+ let useLegend = get(opt, 'useLegend', true)
17
+
18
+ let _opt = {
19
+
20
+ credits: {
21
+ enabled: false //不顯示highchart icon
22
+ },
23
+
24
+ navigation: {
25
+ buttonOptions: {
26
+ enabled: false //若有引用export.js時關閉匯出按鈕
27
+ }
28
+ },
29
+
30
+ boost: {
31
+ enabled: true,
32
+ // useGPUTranslations: true,
33
+ },
34
+
35
+ plotOptions: {
36
+ series: {
37
+ animation: false, //關閉動畫
38
+ },
39
+ },
40
+
41
+ title: {
42
+ text: ''
43
+ },
44
+
45
+ subtitle: {
46
+ text: ''
47
+ },
48
+
49
+ tooltip: {
50
+ useHTML: true,
51
+ enabled: useTooltip,
52
+ },
53
+
54
+ legend: {
55
+ useHTML: true,
56
+ enabled: useLegend,
57
+ },
58
+
59
+ }
60
+
61
+ return _opt
62
+ }
63
+
64
+
65
+ export default getDefOpt
@@ -0,0 +1,104 @@
1
+ import get from 'lodash-es/get'
2
+ import cdbl from 'wsemi/src/cdbl.mjs'
3
+
4
+
5
+ /**
6
+ * 使用繪圖設定物件針對Highcharts物件處理圖例位置
7
+ *
8
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
9
+ * @param {Object} [optPic={}] 輸入繪圖設定物件,預設{}
10
+ * @returns {Object} 回傳物件
11
+ */
12
+ function setLegendLoc(opt, optPic = {}) {
13
+
14
+ let legendPosition = get(optPic, 'legendPosition', 'topright')
15
+
16
+ let ml = get(opt, 'chart.marginLeft') || get(opt, 'chart.margin-left')
17
+ ml = cdbl(ml)
18
+ let mr = get(opt, 'chart.marginRight') || get(opt, 'chart.margin-right')
19
+ mr = cdbl(mr)
20
+ let mt = get(opt, 'chart.marginTop') || get(opt, 'chart.margin-top')
21
+ mt = cdbl(mt)
22
+ let mb = get(opt, 'chart.marginBottom') || get(opt, 'chart.margin-bottom')
23
+ mb = cdbl(mb)
24
+ // console.log('ml', ml)
25
+ // console.log('mr', mr)
26
+ // console.log('mt', mt)
27
+ // console.log('mb', mb)
28
+
29
+ //legendIgnoreMargin
30
+ let legendIgnoreMargin = get(optPic, 'legendIgnoreMargin', false)
31
+
32
+ if (legendIgnoreMargin) {
33
+ ml = 0
34
+ mr = 0
35
+ mt = 0
36
+ mb = 0
37
+ }
38
+
39
+ let sl = get(opt, 'chart.spacingLeft') || get(opt, 'chart.spacing-left')
40
+ sl = cdbl(sl)
41
+ let sr = get(opt, 'chart.spacingRight') || get(opt, 'chart.spacing-right')
42
+ sr = cdbl(sr)
43
+ let st = get(opt, 'chart.spacingTop') || get(opt, 'chart.spacing-top')
44
+ st = cdbl(st)
45
+ let sb = get(opt, 'chart.spacingBottom') || get(opt, 'chart.spacing-bottom')
46
+ sb = cdbl(sb)
47
+ // console.log('sl', sl)
48
+ // console.log('sr', sr)
49
+ // console.log('st', st)
50
+ // console.log('sb', sb)
51
+
52
+ //legendIgnoreSpacing
53
+ let legendIgnoreSpacing = get(optPic, 'legendIgnoreSpacing', false)
54
+
55
+ if (legendIgnoreSpacing) {
56
+ sl = 0
57
+ sr = 0
58
+ st = 0
59
+ sb = 0
60
+ }
61
+
62
+ let lg = get(opt, 'legend', {})
63
+ opt.legend = lg //若無, 則先給予空物件, 避免後續無法直接鏈式給予值
64
+
65
+ //legendPosition
66
+ if (legendPosition === 'topleft') {
67
+ opt.legend.align = 'left'
68
+ opt.legend.verticalAlign = 'top'
69
+ let dx = 5
70
+ let dy = 5
71
+ opt.legend.x = ml - sl + dx
72
+ opt.legend.y = mt - st + dy
73
+ }
74
+ else if (legendPosition === 'bottomleft') {
75
+ opt.legend.align = 'left'
76
+ opt.legend.verticalAlign = 'bottom'
77
+ let dx = 5
78
+ let dy = -5
79
+ opt.legend.x = ml - sl + dx
80
+ opt.legend.y = -mb + sb + dy
81
+ }
82
+ else if (legendPosition === 'bottomright') {
83
+ opt.legend.align = 'right'
84
+ opt.legend.verticalAlign = 'bottom'
85
+ let dx = -5
86
+ let dy = -5
87
+ opt.legend.x = -mr + sr + dx
88
+ opt.legend.y = -mb + sb + dy
89
+ }
90
+ else { //legendPosition==='topright'
91
+ opt.legend.align = 'right'
92
+ opt.legend.verticalAlign = 'top'
93
+ let dx = -5
94
+ let dy = 5
95
+ opt.legend.x = -mr + sr + dx
96
+ opt.legend.y = mt - st + dy
97
+ }
98
+ // console.log('opt.legend', JSON.stringify(opt.legend))
99
+
100
+ return opt
101
+ }
102
+
103
+
104
+ export default setLegendLoc
package/src/main.js ADDED
@@ -0,0 +1,8 @@
1
+ import Vue from 'vue'
2
+ import App from './App.vue'
3
+
4
+ Vue.config.productionTip = false
5
+
6
+ new Vue({
7
+ render: h => h(App),
8
+ }).$mount('#app')
@@ -0,0 +1,10 @@
1
+ import assert from 'assert'
2
+
3
+
4
+ describe('all', function() {
5
+
6
+ it('test in localhost', function() {
7
+ assert.strict.deepEqual(1, 1)
8
+ })
9
+
10
+ })
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,4 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('docs')