w-highcharts 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.
- package/.editorconfig +9 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +54 -0
- package/.jsdoc +25 -0
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/SECURITY.md +5 -0
- package/babel.config.js +15 -0
- package/dist/w-highcharts.umd.js +7 -0
- package/dist/w-highcharts.umd.js.map +1 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/getDefDataGrouping.mjs.html +91 -0
- package/docs/getDefDateFmt.mjs.html +101 -0
- package/docs/getDefMarker.mjs.html +91 -0
- package/docs/getDefOpt.mjs.html +170 -0
- package/docs/getDefUnits.mjs.html +98 -0
- package/docs/global.html +856 -0
- package/docs/index.html +84 -0
- package/docs/iniMarkers.mjs.html +167 -0
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +99 -0
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/package.json +29 -0
- package/src/WHighcharts.mjs +35 -0
- package/src/addCircleByChart.mjs +57 -0
- package/src/addIndicatorTextByChart.mjs +124 -0
- package/src/addLineByChart.mjs +62 -0
- package/src/addPolygonByChart.mjs +67 -0
- package/src/addPolylineByChart.mjs +17 -0
- package/src/addRectByChart.mjs +70 -0
- package/src/addRectCenterTextByChart.mjs +30 -0
- package/src/addRectTextByChart.mjs +29 -0
- package/src/addTextByChart.mjs +83 -0
- package/src/findMarker.mjs +38 -0
- package/src/genSerie.mjs +124 -0
- package/src/getAxisLimitByChart.mjs +49 -0
- package/src/getColor.mjs +65 -0
- package/src/getConvertLocByChart.mjs +89 -0
- package/src/getDefDataGrouping.mjs +19 -0
- package/src/getDefDateFmt.mjs +29 -0
- package/src/getDefMarker.mjs +19 -0
- package/src/getDefOpt.mjs +98 -0
- package/src/getDefUnits.mjs +26 -0
- package/src/getDefgetDefRangeSelector.mjs +46 -0
- package/src/getFontfamily.mjs +26 -0
- package/src/getHighchart.mjs +17 -0
- package/src/getLineSetting.mjs +26 -0
- package/src/getLineStyle.mjs +23 -0
- package/src/getMarker.mjs +19 -0
- package/src/getMarkers.mjs +56 -0
- package/src/getPicCenter.mjs +34 -0
- package/src/getPointXY.mjs +21 -0
- package/src/getSeriesLimit.mjs +72 -0
- package/src/getSizeWH.mjs +21 -0
- package/src/getStrokeDasharrayFromLineStyle.mjs +21 -0
- package/src/getStrokeFromLineStyle.mjs +15 -0
- package/src/iniMarkers.mjs +95 -0
- package/src/renderNoDataByChart.mjs +34 -0
- package/src/setFontfamily.mjs +23 -0
- package/test/convertCoordinate.test.mjs +430 -0
- package/toolg/addVersion.mjs +4 -0
- package/toolg/cleanFolder.mjs +4 -0
- package/toolg/gDistRollup.mjs +43 -0
- package/toolg/gDocsExams.mjs +51 -0
- package/toolg/gPackageIndex.mjs +46 -0
- package/toolg/modifyReadme.mjs +4 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import each from 'lodash/each'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
4
|
+
import getMarkers from './getMarkers.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function findMarker(smbl) {
|
|
8
|
+
|
|
9
|
+
//check
|
|
10
|
+
if (!isestr(smbl)) {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//ms
|
|
15
|
+
let ms = getMarkers()
|
|
16
|
+
|
|
17
|
+
//find
|
|
18
|
+
let m = null
|
|
19
|
+
each(ms, (v) => {
|
|
20
|
+
let _smbl = get(v, 0, null)
|
|
21
|
+
if (_smbl === smbl) {
|
|
22
|
+
m = v
|
|
23
|
+
return false //跳出
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
//symbol
|
|
28
|
+
let symbol = get(m, 0, null)
|
|
29
|
+
let size = get(m, 1, null)
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
symbol,
|
|
33
|
+
size,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export default findMarker
|
package/src/genSerie.mjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import getLineSetting from './getLineSetting.mjs'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function genSerie(displayDataMode, name, data, i) {
|
|
5
|
+
|
|
6
|
+
//s
|
|
7
|
+
let s
|
|
8
|
+
if (displayDataMode === 'line' || displayDataMode === 'line(grey)') {
|
|
9
|
+
let color = 'rgba(100, 140, 220, 1)'
|
|
10
|
+
if (displayDataMode === 'line(grey)') {
|
|
11
|
+
color = '#999'
|
|
12
|
+
}
|
|
13
|
+
s = {
|
|
14
|
+
type: 'line',
|
|
15
|
+
name,
|
|
16
|
+
data,
|
|
17
|
+
lineWidth: 1,
|
|
18
|
+
color,
|
|
19
|
+
marker: {
|
|
20
|
+
enabled: false,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (displayDataMode === 'marker') {
|
|
25
|
+
s = {
|
|
26
|
+
type: 'scatter',
|
|
27
|
+
name,
|
|
28
|
+
data,
|
|
29
|
+
lineWidth: 0,
|
|
30
|
+
color: 'transparent',
|
|
31
|
+
dashStyle: null,
|
|
32
|
+
marker: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
symbol: 'circle',
|
|
35
|
+
radius: 4,
|
|
36
|
+
lineWidth: 0,
|
|
37
|
+
fillColor: 'rgba(100,170,255,1)',
|
|
38
|
+
lineColor: 'rgba(20,100,200,1)',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (displayDataMode === 'markers') {
|
|
43
|
+
let ls = getLineSetting(i)
|
|
44
|
+
s = {
|
|
45
|
+
type: 'scatter',
|
|
46
|
+
name,
|
|
47
|
+
data,
|
|
48
|
+
lineWidth: 0,
|
|
49
|
+
color: 'transparent',
|
|
50
|
+
dashStyle: null,
|
|
51
|
+
marker: {
|
|
52
|
+
enabled: true,
|
|
53
|
+
symbol: ls.marker,
|
|
54
|
+
radius: ls.markerSize,
|
|
55
|
+
lineWidth: 1,
|
|
56
|
+
fillColor: ls.markerFacecolor,
|
|
57
|
+
lineColor: ls.markerEdgecolor,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (displayDataMode === 'dot point') {
|
|
62
|
+
s = {
|
|
63
|
+
type: 'scatter',
|
|
64
|
+
name,
|
|
65
|
+
data,
|
|
66
|
+
lineWidth: 0,
|
|
67
|
+
color: 'transparent',
|
|
68
|
+
dashStyle: null,
|
|
69
|
+
marker: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
symbol: 'circle',
|
|
72
|
+
radius: 2,
|
|
73
|
+
lineWidth: 0,
|
|
74
|
+
fillColor: 'rgba(255, 34, 102, 1)', //#f26
|
|
75
|
+
lineColor: 'transparent',
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (displayDataMode === 'small point') {
|
|
80
|
+
s = {
|
|
81
|
+
type: 'scatter',
|
|
82
|
+
name,
|
|
83
|
+
data,
|
|
84
|
+
lineWidth: 0,
|
|
85
|
+
color: 'transparent',
|
|
86
|
+
dashStyle: null,
|
|
87
|
+
marker: {
|
|
88
|
+
enabled: true,
|
|
89
|
+
symbol: 'circle',
|
|
90
|
+
radius: 1,
|
|
91
|
+
lineWidth: 0,
|
|
92
|
+
fillColor: 'rgba(100, 140, 220, 1)',
|
|
93
|
+
lineColor: 'transparent',
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (displayDataMode === 'marker point') {
|
|
98
|
+
s = {
|
|
99
|
+
type: 'scatter',
|
|
100
|
+
name,
|
|
101
|
+
data,
|
|
102
|
+
lineWidth: 0,
|
|
103
|
+
color: 'transparent',
|
|
104
|
+
dashStyle: null,
|
|
105
|
+
marker: {
|
|
106
|
+
enabled: true,
|
|
107
|
+
symbol: 'circle',
|
|
108
|
+
radius: 4,
|
|
109
|
+
lineWidth: 1,
|
|
110
|
+
fillColor: 'transparent',
|
|
111
|
+
lineColor: '#f26',
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.log('displayDataMode', displayDataMode)
|
|
117
|
+
throw new Error(`invalid displayDataMode[${displayDataMode}]`)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return s
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
export default genSerie
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isp0int from 'wsemi/src/isp0int.mjs'
|
|
3
|
+
import cint from 'wsemi/src/cint.mjs'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function getAxisLimitByChart(chart, opt = {}) {
|
|
7
|
+
|
|
8
|
+
//indXAxis
|
|
9
|
+
let indXAxis = get(opt, 'indXAxis')
|
|
10
|
+
if (!isp0int(indXAxis)) {
|
|
11
|
+
indXAxis = 0
|
|
12
|
+
}
|
|
13
|
+
indXAxis = cint(indXAxis)
|
|
14
|
+
|
|
15
|
+
//indYAxis
|
|
16
|
+
let indYAxis = get(opt, 'indYAxis')
|
|
17
|
+
if (!isp0int(indYAxis)) {
|
|
18
|
+
indYAxis = 0
|
|
19
|
+
}
|
|
20
|
+
indYAxis = cint(indYAxis)
|
|
21
|
+
|
|
22
|
+
//xLimMin,xLimMax,yLimMin,yLimMax
|
|
23
|
+
let xLimMin = chart.xAxis[indXAxis].min
|
|
24
|
+
if (!xLimMin) {
|
|
25
|
+
xLimMin = 0
|
|
26
|
+
}
|
|
27
|
+
let xLimMax = chart.xAxis[indXAxis].max
|
|
28
|
+
if (!xLimMax) {
|
|
29
|
+
xLimMax = 0
|
|
30
|
+
}
|
|
31
|
+
let yLimMin = chart.yAxis[indYAxis].min
|
|
32
|
+
if (!yLimMin) {
|
|
33
|
+
yLimMin = 0
|
|
34
|
+
}
|
|
35
|
+
let yLimMax = chart.yAxis[indYAxis].max
|
|
36
|
+
if (!yLimMax) {
|
|
37
|
+
yLimMax = 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
xLimMin,
|
|
42
|
+
xLimMax,
|
|
43
|
+
yLimMin,
|
|
44
|
+
yLimMax,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export default getAxisLimitByChart
|
package/src/getColor.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import each from 'lodash/each'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import times from 'lodash/times'
|
|
4
|
+
import oc from 'wsemi/src/color.mjs'
|
|
5
|
+
import ispint from 'wsemi/src/ispint.mjs'
|
|
6
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
7
|
+
import isearr from 'wsemi/src/isearr.mjs'
|
|
8
|
+
import cint from 'wsemi/src/cint.mjs'
|
|
9
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function getColor(i, opt = {}) {
|
|
13
|
+
|
|
14
|
+
//listL
|
|
15
|
+
let listL = get(opt, 'listL')
|
|
16
|
+
if (!isearr(listL)) {
|
|
17
|
+
listL = [0.35, 0.7]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//listS
|
|
21
|
+
let listS = get(opt, 'listS')
|
|
22
|
+
if (!isearr(listS)) {
|
|
23
|
+
listS = [0.9, 0.5, 0.2]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//opacity
|
|
27
|
+
let opacity = get(opt, 'opacity')
|
|
28
|
+
if (!isnum(opacity)) {
|
|
29
|
+
opacity = 1
|
|
30
|
+
}
|
|
31
|
+
opacity = cdbl(opacity)
|
|
32
|
+
opacity = Math.max(opacity, 0)
|
|
33
|
+
opacity = Math.min(opacity, 1)
|
|
34
|
+
|
|
35
|
+
//hueSliceNum
|
|
36
|
+
let hueSliceNum = get(opt, 'hueSliceNum')
|
|
37
|
+
if (!ispint(hueSliceNum)) {
|
|
38
|
+
hueSliceNum = 5
|
|
39
|
+
}
|
|
40
|
+
hueSliceNum = cint(hueSliceNum)
|
|
41
|
+
|
|
42
|
+
//ltcolor
|
|
43
|
+
let ltcolor = []
|
|
44
|
+
each(listL, function (rl) {
|
|
45
|
+
each(listS, function (rs) {
|
|
46
|
+
times(hueSliceNum, function (i) {
|
|
47
|
+
let tc = oc.toRgbaString({
|
|
48
|
+
h: (360 * i / hueSliceNum),
|
|
49
|
+
s: rs,
|
|
50
|
+
l: rl,
|
|
51
|
+
a: opacity,
|
|
52
|
+
})
|
|
53
|
+
ltcolor.push(tc)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
//j
|
|
59
|
+
let j = i % ltcolor.length
|
|
60
|
+
|
|
61
|
+
return ltcolor[j]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
export default getColor
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import map from 'lodash/map'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import isNumber from 'lodash/isNumber'
|
|
4
|
+
import isfun from 'wsemi/src/isfun.mjs'
|
|
5
|
+
import getAxisLimitByChart from './getAxisLimitByChart.mjs'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function getConvertLocByChart(chart, opt = {}) {
|
|
9
|
+
|
|
10
|
+
//size
|
|
11
|
+
let rl = chart.plotLeft
|
|
12
|
+
let rt = chart.plotTop
|
|
13
|
+
let rw = chart.plotWidth
|
|
14
|
+
let rh = chart.plotHeight
|
|
15
|
+
// console.log('rl', rl, 'rt', rt, 'rw', rw, 'rh', rh)
|
|
16
|
+
|
|
17
|
+
//getAxisLimitByChart
|
|
18
|
+
let lims = getAxisLimitByChart(chart, opt)
|
|
19
|
+
|
|
20
|
+
//cvLim
|
|
21
|
+
let cvLim = get(opt, 'cvLim')
|
|
22
|
+
if (isfun(cvLim)) {
|
|
23
|
+
lims = cvLim(lims)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//spread
|
|
27
|
+
let { xLimMin, xLimMax, yLimMin, yLimMax } = lims
|
|
28
|
+
// console.log('chart.yAxis', chart.yAxis)
|
|
29
|
+
// console.log('xLimMax', xLimMax)
|
|
30
|
+
// console.log('xLimMin', xLimMin)
|
|
31
|
+
// console.log('yLimMax', yLimMax)
|
|
32
|
+
// console.log('yLimMin', yLimMin)
|
|
33
|
+
|
|
34
|
+
//getType
|
|
35
|
+
let getType = (p) => {
|
|
36
|
+
let len1 = get(p, '0')
|
|
37
|
+
if (isNumber(len1)) {
|
|
38
|
+
return 'point'
|
|
39
|
+
}
|
|
40
|
+
let len2 = get(p, '0.0')
|
|
41
|
+
if (isNumber(len2)) {
|
|
42
|
+
return 'points'
|
|
43
|
+
}
|
|
44
|
+
console.log('p', p)
|
|
45
|
+
throw new Error('invalid type of p')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//cv
|
|
49
|
+
let cv = (p, invXY = false) => {
|
|
50
|
+
|
|
51
|
+
//xr,yr
|
|
52
|
+
let xr = (p[0] - xLimMin) / (xLimMax - xLimMin)
|
|
53
|
+
let yr = (p[1] - yLimMin) / (yLimMax - yLimMin)
|
|
54
|
+
if (invXY) {
|
|
55
|
+
let t = xr
|
|
56
|
+
xr = yr
|
|
57
|
+
yr = t
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//xn,yn
|
|
61
|
+
let xn = xr * (rw) + rl
|
|
62
|
+
let yn = (1 - yr) * (rh) + rt
|
|
63
|
+
|
|
64
|
+
return [xn, yn]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//cvp
|
|
68
|
+
let cvp = (p, invXY = false) => {
|
|
69
|
+
let type = getType(p)
|
|
70
|
+
if (type === 'point') {
|
|
71
|
+
return cv(p, invXY)
|
|
72
|
+
}
|
|
73
|
+
else if (type === 'points') {
|
|
74
|
+
let ps = p
|
|
75
|
+
return map(ps, (p) => {
|
|
76
|
+
return cv(p, invXY)
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
throw new Error('invalid type')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
lims,
|
|
84
|
+
cvp,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
export default getConvertLocByChart
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import getDefUnits from './getDefUnits.mjs'
|
|
2
|
+
import getDefDateFmt from './getDefDateFmt.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 取得Highcharts時間群組設定物件
|
|
7
|
+
*
|
|
8
|
+
* @returns {Object} 回傳時間群組設定物件
|
|
9
|
+
*/
|
|
10
|
+
function getDefDataGrouping() {
|
|
11
|
+
return {
|
|
12
|
+
enabled: true,
|
|
13
|
+
units: getDefUnits(),
|
|
14
|
+
dateTimeLabelFormats: getDefDateFmt(),
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export default getDefDataGrouping
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 取得Highcharts時間單位格式物件
|
|
4
|
+
*
|
|
5
|
+
* @returns {Object} 回傳時間單位格式物件
|
|
6
|
+
*/
|
|
7
|
+
function getDefDateFmt() {
|
|
8
|
+
return {
|
|
9
|
+
//millisecond: ['%A, %m/%d, %H:%M:%S.%L', '%A, %m/%d, %H:%M:%S.%L', '-%H:%M:%S.%L'],
|
|
10
|
+
//second: ['%A, %m/%d, %H:%M:%S', '%A, %m/%d, %H:%M:%S', '-%H:%M:%S'],
|
|
11
|
+
//minute: ['%A, %m/%d, %H:%M', '%A, %m/%d, %H:%M', '-%H:%M'],
|
|
12
|
+
//hour: ['%A, %m/%d, %H:%M', '%A, %m/%d, %H:%M', '-%H:%M'],
|
|
13
|
+
//day: ['%A, %Y/%m/%d', '%A, %m/%d', '-%A, %Y/%m/%d'],
|
|
14
|
+
//week: ['%Y/%m/%d', '%A, %m/%d', '-%A, %Y/%m/%d'],
|
|
15
|
+
//month: ['%Y/%m', '%m', '-%m %Y'],
|
|
16
|
+
//year: ['%Y', '%Y', '-%Y']
|
|
17
|
+
millisecond: ['%Y/%m/%d %H:%M:%S.%L', '%Y/%m/%d %H:%M:%S.%L', ' ~ %H:%M:%S.%L'],
|
|
18
|
+
second: ['%Y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', ' ~ %H:%M:%S'],
|
|
19
|
+
minute: ['%Y/%m/%d %H:%M', '%Y/%m/%d %H:%M', ' ~ %H:%M'],
|
|
20
|
+
hour: ['%Y/%m/%d %H:%M', '%Y/%m/%d %H:%M', ' ~ %H:%M'],
|
|
21
|
+
day: ['%Y/%m/%d', '%Y/%m/%d', ' ~ %Y/%m/%d'],
|
|
22
|
+
week: ['%Y/%m/%d', '%Y/%m/%d', ' ~ %Y/%m/%d'],
|
|
23
|
+
month: ['%Y/%m', '%Y/%m', ' ~ %Y/%m'],
|
|
24
|
+
year: ['%Y', '%Y', ' ~ %Y']
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export default getDefDateFmt
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 產生Highcharts標記物件
|
|
5
|
+
*
|
|
6
|
+
* @returns {Object} 回傳標記物件
|
|
7
|
+
*/
|
|
8
|
+
function getDefMarker() {
|
|
9
|
+
return {
|
|
10
|
+
enabled: true,
|
|
11
|
+
symbol: 'circle',
|
|
12
|
+
fillColor: 'rgba(255,255,255,0.5)', //'#fff',
|
|
13
|
+
lineWidth: 2,
|
|
14
|
+
lineColor: null,
|
|
15
|
+
radius: 5,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default getDefMarker
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import getDefDateFmt from './getDefDateFmt.mjs'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 取得Highcharts繪圖設定物件
|
|
6
|
+
*
|
|
7
|
+
* @returns {Object} 回傳繪圖設定物件
|
|
8
|
+
*/
|
|
9
|
+
function getDefOpt() {
|
|
10
|
+
return {
|
|
11
|
+
|
|
12
|
+
credits: {
|
|
13
|
+
enabled: false
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
global: {
|
|
17
|
+
useUTC: false, //輸入資料自訂UTC時間, 此處關閉避免被強制轉換
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
lang: {
|
|
21
|
+
decimalPoint: '.',
|
|
22
|
+
thousandsSep: ',',
|
|
23
|
+
contextButtonTitle: '圖表匯出功能表',
|
|
24
|
+
downloadJPEG: '下載 JPEG 圖片',
|
|
25
|
+
downloadPDF: '下載 PDF 文件',
|
|
26
|
+
downloadPNG: '下載 PNG 文件',
|
|
27
|
+
downloadSVG: '下載 SVG 文件',
|
|
28
|
+
downloadXLS: '下載 XLS 文件',
|
|
29
|
+
openInCloud: '在 Highcharts Cloud 中打開',
|
|
30
|
+
drillUpText: '返回 {series.name}',
|
|
31
|
+
invalidDate: '無效的時間',
|
|
32
|
+
loading: '載入中...',
|
|
33
|
+
months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
34
|
+
noData: '沒有資料',
|
|
35
|
+
printChart: '列印圖表',
|
|
36
|
+
resetZoom: '重置縮放比例',
|
|
37
|
+
resetZoomTitle: '重置為原始大小',
|
|
38
|
+
shortMonths: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
39
|
+
weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
|
40
|
+
viewData: '查看資料',
|
|
41
|
+
rangeSelectorFrom: '開始時間',
|
|
42
|
+
rangeSelectorTo: '結束時間',
|
|
43
|
+
rangeSelectorZoom: '範圍',
|
|
44
|
+
zoomIn: '縮小',
|
|
45
|
+
zoomOut: '放大',
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
tooltip: {
|
|
49
|
+
dateTimeLabelFormats: {
|
|
50
|
+
millisecond: '%H:%M:%S.%L',
|
|
51
|
+
second: '%H:%M:%S',
|
|
52
|
+
minute: '%H:%M',
|
|
53
|
+
hour: '%H:%M',
|
|
54
|
+
day: '%Y/%m/%d',
|
|
55
|
+
week: '%Y/%m/%d',
|
|
56
|
+
month: '%Y/%m',
|
|
57
|
+
year: '%Y'
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
xAxis: {
|
|
62
|
+
dateTimeLabelFormats: {
|
|
63
|
+
second: '%Y<br/>%m/%d',
|
|
64
|
+
minute: '%Y<br/>%m/%d',
|
|
65
|
+
hour: '%Y<br/>%m/%d',
|
|
66
|
+
day: '%Y<br/>%m/%d',
|
|
67
|
+
week: '%Y<br/>%m/%d',
|
|
68
|
+
month: '%Y<br/>%m/%d',
|
|
69
|
+
year: '%Y<br/>%m/%d',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
rangeSelector: { //選擇起訖時間輸入框與按鈕區
|
|
74
|
+
enabled: false
|
|
75
|
+
},
|
|
76
|
+
// rangeSelector,
|
|
77
|
+
|
|
78
|
+
// navigator: { //選擇時間起訖拖曳區
|
|
79
|
+
// enabled: false
|
|
80
|
+
// },
|
|
81
|
+
// scrollbar: { //選擇時間起訖捲軸區
|
|
82
|
+
// enabled: false
|
|
83
|
+
// },
|
|
84
|
+
|
|
85
|
+
plotOptions: {
|
|
86
|
+
series: {
|
|
87
|
+
dataGrouping: {
|
|
88
|
+
dateTimeLabelFormats: getDefDateFmt()
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export default getDefOpt
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 取得Highcharts時間單位陣列
|
|
5
|
+
*
|
|
6
|
+
* @returns {Array} 回傳時間單位陣列
|
|
7
|
+
*/
|
|
8
|
+
function getDefUnits() {
|
|
9
|
+
return [
|
|
10
|
+
[
|
|
11
|
+
'day',
|
|
12
|
+
[1], //允許1天為群組單位
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
'week',
|
|
16
|
+
[1], //允許1週為群組單位
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
'month',
|
|
20
|
+
[1, 3, 6], //允許1月,1季,半年為群組單位
|
|
21
|
+
]
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export default getDefUnits
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
function getDefgetDefRangeSelector() {
|
|
4
|
+
let rangeSelector = {
|
|
5
|
+
inputDateFormat: '%Y/%m/%d',
|
|
6
|
+
// buttonTheme: {
|
|
7
|
+
// width: 'auto',
|
|
8
|
+
// style: {
|
|
9
|
+
// fontSize: '12px',
|
|
10
|
+
// padding: '4px'
|
|
11
|
+
// }
|
|
12
|
+
// },
|
|
13
|
+
buttons: [{
|
|
14
|
+
type: 'month',
|
|
15
|
+
count: 1,
|
|
16
|
+
text: '月'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'month',
|
|
20
|
+
count: 3,
|
|
21
|
+
text: '季度'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'month',
|
|
25
|
+
count: 6,
|
|
26
|
+
text: '半年'
|
|
27
|
+
},
|
|
28
|
+
// {
|
|
29
|
+
// type: 'ytd',
|
|
30
|
+
// text: 'YTD'
|
|
31
|
+
// },
|
|
32
|
+
{
|
|
33
|
+
type: 'year',
|
|
34
|
+
count: 1,
|
|
35
|
+
text: '年'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'all',
|
|
39
|
+
text: '所有'
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
42
|
+
return rangeSelector
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export default getDefgetDefRangeSelector
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
3
|
+
import getHighchart from './getHighchart.mjs'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let key = '__fontFamily__'
|
|
7
|
+
|
|
8
|
+
function getFontfamily() {
|
|
9
|
+
|
|
10
|
+
//getHighchart
|
|
11
|
+
let hc = getHighchart()
|
|
12
|
+
|
|
13
|
+
//fontFamily
|
|
14
|
+
let fontFamily = get(hc, key)
|
|
15
|
+
|
|
16
|
+
//check
|
|
17
|
+
if (!isestr(fontFamily)) {
|
|
18
|
+
fontFamily = `'Times New Roman', 'DFKai-SB', 'DFKaiShu-SB-Estd-BF', 'KaiU', '標楷體'`
|
|
19
|
+
// let fontFamilyEng = `'微軟正黑體'`
|
|
20
|
+
// let fontFamilyCht = `'DFKai-SB', 'DFKaiShu-SB-Estd-BF', 'KaiU', '標楷體'`
|
|
21
|
+
}
|
|
22
|
+
return fontFamily
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export default getFontfamily
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// import Highcharts from 'highcharts' //統一使用window的
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function getHighchart() {
|
|
5
|
+
|
|
6
|
+
//Highcharts
|
|
7
|
+
let Highcharts = null
|
|
8
|
+
try {
|
|
9
|
+
Highcharts = window['Highcharts']
|
|
10
|
+
}
|
|
11
|
+
catch (err) {}
|
|
12
|
+
|
|
13
|
+
return Highcharts
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export default getHighchart
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import getColor from './getColor.mjs'
|
|
2
|
+
import getMarker from './getMarker.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function getLineSetting(i, opt = {}) {
|
|
6
|
+
let cb = getColor(i, opt)
|
|
7
|
+
let cl = getColor(i, { opacity: 0.2 })
|
|
8
|
+
let mb = getMarker(i, opt)
|
|
9
|
+
let lineStyle = 'Solid' //getLineStyle(i);
|
|
10
|
+
let lineColor = cb
|
|
11
|
+
let marker = mb.symbol
|
|
12
|
+
let markerSize = mb.size
|
|
13
|
+
let markerEdgecolor = cb
|
|
14
|
+
let markerFacecolor = cl
|
|
15
|
+
return {
|
|
16
|
+
lineColor,
|
|
17
|
+
lineStyle,
|
|
18
|
+
marker,
|
|
19
|
+
markerEdgecolor,
|
|
20
|
+
markerFacecolor,
|
|
21
|
+
markerSize,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export default getLineSetting
|