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,80 @@
|
|
|
1
|
+
.pln {
|
|
2
|
+
color: #ddd;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/* string content */
|
|
6
|
+
.str {
|
|
7
|
+
color: #61ce3c;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* a keyword */
|
|
11
|
+
.kwd {
|
|
12
|
+
color: #fbde2d;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* a comment */
|
|
16
|
+
.com {
|
|
17
|
+
color: #aeaeae;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* a type name */
|
|
21
|
+
.typ {
|
|
22
|
+
color: #8da6ce;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* a literal value */
|
|
26
|
+
.lit {
|
|
27
|
+
color: #fbde2d;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* punctuation */
|
|
31
|
+
.pun {
|
|
32
|
+
color: #ddd;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* lisp open bracket */
|
|
36
|
+
.opn {
|
|
37
|
+
color: #000000;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* lisp close bracket */
|
|
41
|
+
.clo {
|
|
42
|
+
color: #000000;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* a markup tag name */
|
|
46
|
+
.tag {
|
|
47
|
+
color: #8da6ce;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* a markup attribute name */
|
|
51
|
+
.atn {
|
|
52
|
+
color: #fbde2d;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* a markup attribute value */
|
|
56
|
+
.atv {
|
|
57
|
+
color: #ddd;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* a declaration */
|
|
61
|
+
.dec {
|
|
62
|
+
color: #EF5050;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* a variable name */
|
|
66
|
+
.var {
|
|
67
|
+
color: #c82829;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* a function name */
|
|
71
|
+
.fun {
|
|
72
|
+
color: #4271ae;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Specify class=linenums on a pre to get line numbering */
|
|
76
|
+
ol.linenums {
|
|
77
|
+
margin-top: 0;
|
|
78
|
+
margin-bottom: 0;
|
|
79
|
+
padding-bottom: 2px;
|
|
80
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "w-highcharts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/w-highcharts.umd.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"lodash": "^4.17.21",
|
|
7
|
+
"wsemi": "^1.7.3"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"w-package-tools": "^1.0.69"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",
|
|
14
|
+
"deploy": "gh-pages -d docs"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/yuda-lyu/w-highcharts.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"package",
|
|
22
|
+
"tool",
|
|
23
|
+
"highcharts",
|
|
24
|
+
"nodejs",
|
|
25
|
+
"browser"
|
|
26
|
+
],
|
|
27
|
+
"author": "yuda-lyu(semisphere)",
|
|
28
|
+
"license": "MIT"
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { default as addCircleByChart } from './addCircleByChart.mjs'
|
|
2
|
+
export { default as addIndicatorTextByChart } from './addIndicatorTextByChart.mjs'
|
|
3
|
+
export { default as addLineByChart } from './addLineByChart.mjs'
|
|
4
|
+
export { default as addPolygonByChart } from './addPolygonByChart.mjs'
|
|
5
|
+
export { default as addPolylineByChart } from './addPolylineByChart.mjs'
|
|
6
|
+
export { default as addRectByChart } from './addRectByChart.mjs'
|
|
7
|
+
export { default as addRectCenterTextByChart } from './addRectCenterTextByChart.mjs'
|
|
8
|
+
export { default as addRectTextByChart } from './addRectTextByChart.mjs'
|
|
9
|
+
export { default as addTextByChart } from './addTextByChart.mjs'
|
|
10
|
+
export { default as findMarker } from './findMarker.mjs'
|
|
11
|
+
export { default as genSerie } from './genSerie.mjs'
|
|
12
|
+
export { default as getAxisLimitByChart } from './getAxisLimitByChart.mjs'
|
|
13
|
+
export { default as getColor } from './getColor.mjs'
|
|
14
|
+
export { default as getConvertLocByChart } from './getConvertLocByChart.mjs'
|
|
15
|
+
export { default as getDefDataGrouping } from './getDefDataGrouping.mjs'
|
|
16
|
+
export { default as getDefDateFmt } from './getDefDateFmt.mjs'
|
|
17
|
+
export { default as getDefgetDefRangeSelector } from './getDefgetDefRangeSelector.mjs'
|
|
18
|
+
export { default as getDefMarker } from './getDefMarker.mjs'
|
|
19
|
+
export { default as getDefOpt } from './getDefOpt.mjs'
|
|
20
|
+
export { default as getDefUnits } from './getDefUnits.mjs'
|
|
21
|
+
export { default as getFontfamily } from './getFontfamily.mjs'
|
|
22
|
+
export { default as getHighchart } from './getHighchart.mjs'
|
|
23
|
+
export { default as getLineSetting } from './getLineSetting.mjs'
|
|
24
|
+
export { default as getLineStyle } from './getLineStyle.mjs'
|
|
25
|
+
export { default as getMarker } from './getMarker.mjs'
|
|
26
|
+
export { default as getMarkers } from './getMarkers.mjs'
|
|
27
|
+
export { default as getPicCenter } from './getPicCenter.mjs'
|
|
28
|
+
export { default as getPointXY } from './getPointXY.mjs'
|
|
29
|
+
export { default as getSeriesLimit } from './getSeriesLimit.mjs'
|
|
30
|
+
export { default as getSizeWH } from './getSizeWH.mjs'
|
|
31
|
+
export { default as getStrokeDasharrayFromLineStyle } from './getStrokeDasharrayFromLineStyle.mjs'
|
|
32
|
+
export { default as getStrokeFromLineStyle } from './getStrokeFromLineStyle.mjs'
|
|
33
|
+
export { default as iniMarkers } from './iniMarkers.mjs'
|
|
34
|
+
export { default as renderNoDataByChart } from './renderNoDataByChart.mjs'
|
|
35
|
+
export { default as setFontfamily } from './setFontfamily.mjs'
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isNumber from 'lodash/isNumber'
|
|
3
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
4
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
5
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
6
|
+
import getPointXY from './getPointXY.mjs'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function addCircleByChart(chart, p, size, opt = {}) {
|
|
10
|
+
|
|
11
|
+
//edgeWidth
|
|
12
|
+
let edgeWidth = get(opt, 'edgeWidth')
|
|
13
|
+
if (!isnum(edgeWidth)) {
|
|
14
|
+
edgeWidth = 1
|
|
15
|
+
}
|
|
16
|
+
edgeWidth = cdbl(edgeWidth)
|
|
17
|
+
edgeWidth = Math.max(edgeWidth, 0)
|
|
18
|
+
|
|
19
|
+
//edgeColor
|
|
20
|
+
let edgeColor = get(opt, 'edgeColor')
|
|
21
|
+
if (!isestr(edgeColor)) {
|
|
22
|
+
edgeColor = '#000'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//faceColor
|
|
26
|
+
let faceColor = get(opt, 'faceColor')
|
|
27
|
+
if (!isestr(faceColor)) {
|
|
28
|
+
faceColor = 'transparent'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//zIndex
|
|
32
|
+
let zIndex = get(opt, 'zIndex')
|
|
33
|
+
if (!isNumber(zIndex)) {
|
|
34
|
+
zIndex = undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//x, y
|
|
38
|
+
let [x, y] = getPointXY(p)
|
|
39
|
+
|
|
40
|
+
//renderer
|
|
41
|
+
let ren = chart.renderer
|
|
42
|
+
|
|
43
|
+
//circle
|
|
44
|
+
ren.circle(x, y, size)
|
|
45
|
+
.attr({
|
|
46
|
+
'name': 'hcextra',
|
|
47
|
+
'fill': faceColor,
|
|
48
|
+
'stroke-width': edgeWidth,
|
|
49
|
+
'stroke': edgeColor,
|
|
50
|
+
zIndex, //attr不能用z-index
|
|
51
|
+
})
|
|
52
|
+
.add()
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
export default addCircleByChart
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import size from 'lodash/size'
|
|
3
|
+
import isNumber from 'lodash/isNumber'
|
|
4
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
5
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
6
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
7
|
+
import getPointXY from './getPointXY.mjs'
|
|
8
|
+
import getSizeWH from './getSizeWH.mjs'
|
|
9
|
+
import addLineByChart from './addLineByChart.mjs'
|
|
10
|
+
import addCircleByChart from './addCircleByChart.mjs'
|
|
11
|
+
import addTextByChart from './addTextByChart.mjs'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function addIndicatorTextByChart(chart, ps, rectShift, rectSize, text, opt = {}) {
|
|
15
|
+
|
|
16
|
+
//lineWidth
|
|
17
|
+
let lineWidth = get(opt, 'lineWidth')
|
|
18
|
+
if (!isnum(lineWidth)) {
|
|
19
|
+
lineWidth = 1
|
|
20
|
+
}
|
|
21
|
+
lineWidth = cdbl(lineWidth)
|
|
22
|
+
lineWidth = Math.max(lineWidth, 0)
|
|
23
|
+
|
|
24
|
+
//lineColor
|
|
25
|
+
let lineColor = get(opt, 'lineColor')
|
|
26
|
+
if (!isestr(lineColor)) {
|
|
27
|
+
lineColor = '#aaa'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//circleColor
|
|
31
|
+
let circleColor = get(opt, 'circleColor')
|
|
32
|
+
if (!isestr(circleColor)) {
|
|
33
|
+
circleColor = '#999'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//connAlign
|
|
37
|
+
let connAlign = get(opt, 'connAlign')
|
|
38
|
+
if (connAlign !== 'left' && connAlign !== 'right') {
|
|
39
|
+
connAlign = 'left'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//shiftLen
|
|
43
|
+
let shiftLen = get(opt, 'shiftLen')
|
|
44
|
+
if (!isnum(shiftLen)) {
|
|
45
|
+
shiftLen = 20
|
|
46
|
+
}
|
|
47
|
+
shiftLen = cdbl(shiftLen)
|
|
48
|
+
shiftLen = Math.max(shiftLen, 0)
|
|
49
|
+
|
|
50
|
+
//circleSize
|
|
51
|
+
let circleSize = get(opt, 'circleSize')
|
|
52
|
+
if (!isnum(circleSize)) {
|
|
53
|
+
circleSize = 4
|
|
54
|
+
}
|
|
55
|
+
circleSize = cdbl(circleSize)
|
|
56
|
+
circleSize = Math.max(circleSize, 0)
|
|
57
|
+
|
|
58
|
+
//px,py 指向處
|
|
59
|
+
let px1 = null
|
|
60
|
+
let py1 = null
|
|
61
|
+
let px2 = null
|
|
62
|
+
let py2 = null
|
|
63
|
+
if (size(ps) === 1) {
|
|
64
|
+
let r1 = getPointXY(ps[0])
|
|
65
|
+
px1 = r1[0]
|
|
66
|
+
py1 = r1[1]
|
|
67
|
+
}
|
|
68
|
+
else if (size(ps) === 2) {
|
|
69
|
+
let r1 = getPointXY(ps[0])
|
|
70
|
+
px1 = r1[0]
|
|
71
|
+
py1 = r1[1]
|
|
72
|
+
let r2 = getPointXY(ps[1])
|
|
73
|
+
px2 = r2[0]
|
|
74
|
+
py2 = r2[1]
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('ps尚不支援3點以上')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//sx,sy 平移量
|
|
81
|
+
let [sx, sy] = getPointXY(rectShift)
|
|
82
|
+
|
|
83
|
+
//nx,ny 拉遠處
|
|
84
|
+
let nx = px1 + sx
|
|
85
|
+
let ny = py1 + sy
|
|
86
|
+
|
|
87
|
+
//ntx,nty 拉遠平移圓點處
|
|
88
|
+
let ntx = nx + shiftLen
|
|
89
|
+
if (connAlign === 'right') {
|
|
90
|
+
ntx = nx - shiftLen
|
|
91
|
+
}
|
|
92
|
+
let nty = ny
|
|
93
|
+
|
|
94
|
+
//w, h
|
|
95
|
+
let [w, h] = getSizeWH(rectSize)
|
|
96
|
+
|
|
97
|
+
//x, y 矩形左上角座標
|
|
98
|
+
let x = ntx + circleSize
|
|
99
|
+
if (connAlign === 'right') {
|
|
100
|
+
x = ntx - w - circleSize
|
|
101
|
+
}
|
|
102
|
+
let y = nty - h / 2
|
|
103
|
+
|
|
104
|
+
//addLineByChart 指向線
|
|
105
|
+
if (isNumber(px1) && isNumber(py1)) {
|
|
106
|
+
addLineByChart(chart, { x: px1, y: py1 }, { x: nx, y: ny }, { ...opt, lineWidth, lineColor })
|
|
107
|
+
}
|
|
108
|
+
if (isNumber(px2) && isNumber(py2)) {
|
|
109
|
+
addLineByChart(chart, { x: px2, y: py2 }, { x: nx, y: ny }, { ...opt, lineWidth, lineColor })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//addLineByChart 拉遠平移線
|
|
113
|
+
addLineByChart(chart, { x: nx, y: ny }, { x: ntx, y: nty }, { ...opt, lineWidth, lineColor })
|
|
114
|
+
|
|
115
|
+
//addCircleByChart 拉遠平移圓點
|
|
116
|
+
addCircleByChart(chart, { x: ntx, y: nty }, circleSize, { edgeWidth: 0, faceColor: circleColor })
|
|
117
|
+
|
|
118
|
+
//addTextByChart 文字
|
|
119
|
+
addTextByChart(chart, { x: x + w / 2, y: y + h / 2 }, text, opt)
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
export default addIndicatorTextByChart
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isNumber from 'lodash/isNumber'
|
|
3
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
4
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
5
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
6
|
+
import getPointXY from './getPointXY.mjs'
|
|
7
|
+
import getStrokeFromLineStyle from './getStrokeFromLineStyle.mjs'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function addLineByChart(chart, p1, p2, opt = {}) {
|
|
11
|
+
|
|
12
|
+
//lineWidth
|
|
13
|
+
let lineWidth = get(opt, 'lineWidth')
|
|
14
|
+
if (!isnum(lineWidth)) {
|
|
15
|
+
lineWidth = 2
|
|
16
|
+
}
|
|
17
|
+
lineWidth = cdbl(lineWidth)
|
|
18
|
+
lineWidth = Math.max(lineWidth, 0)
|
|
19
|
+
|
|
20
|
+
//lineColor
|
|
21
|
+
let lineColor = get(opt, 'lineColor')
|
|
22
|
+
if (!isestr(lineColor)) {
|
|
23
|
+
lineColor = '#000'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//lineStyle
|
|
27
|
+
let lineStyle = get(opt, 'lineStyle')
|
|
28
|
+
if (!isestr(lineStyle)) {
|
|
29
|
+
lineStyle = 'Solid'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//zIndex
|
|
33
|
+
let zIndex = get(opt, 'zIndex')
|
|
34
|
+
if (!isNumber(zIndex)) {
|
|
35
|
+
zIndex = undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//cx1,cy1,cx2,cy2
|
|
39
|
+
let [cx1, cy1] = getPointXY(p1)
|
|
40
|
+
let [cx2, cy2] = getPointXY(p2)
|
|
41
|
+
|
|
42
|
+
//renderer
|
|
43
|
+
let ren = chart.renderer
|
|
44
|
+
|
|
45
|
+
//attr
|
|
46
|
+
let attr = {
|
|
47
|
+
'name': 'hcextra',
|
|
48
|
+
'stroke-width': lineWidth,
|
|
49
|
+
'stroke': lineColor,
|
|
50
|
+
...getStrokeFromLineStyle(lineStyle),
|
|
51
|
+
zIndex, //attr不能用z-index
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//line
|
|
55
|
+
ren.path(['M', cx1, cy1, 'L', cx2, cy2])
|
|
56
|
+
.attr(attr)
|
|
57
|
+
.add()
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export default addLineByChart
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import each from 'lodash/each'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import isNumber from 'lodash/isNumber'
|
|
4
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
5
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
6
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function addPolygonByChart(chart, ps, opt = {}) {
|
|
10
|
+
|
|
11
|
+
//edgeWidth
|
|
12
|
+
let edgeWidth = get(opt, 'edgeWidth')
|
|
13
|
+
if (!isnum(edgeWidth)) {
|
|
14
|
+
edgeWidth = 2
|
|
15
|
+
}
|
|
16
|
+
edgeWidth = cdbl(edgeWidth)
|
|
17
|
+
edgeWidth = Math.max(edgeWidth, 0)
|
|
18
|
+
|
|
19
|
+
//edgeColor
|
|
20
|
+
let edgeColor = get(opt, 'edgeColor')
|
|
21
|
+
if (!isestr(edgeColor)) {
|
|
22
|
+
edgeColor = '#000'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//faceColor
|
|
26
|
+
let faceColor = get(opt, 'faceColor')
|
|
27
|
+
if (!isestr(faceColor)) {
|
|
28
|
+
faceColor = 'transparent'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//zIndex
|
|
32
|
+
let zIndex = get(opt, 'zIndex')
|
|
33
|
+
if (!isNumber(zIndex)) {
|
|
34
|
+
zIndex = undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//renderer
|
|
38
|
+
let ren = chart.renderer
|
|
39
|
+
|
|
40
|
+
//p
|
|
41
|
+
let p = []
|
|
42
|
+
each(ps, (v, k) => {
|
|
43
|
+
if (k === 0) {
|
|
44
|
+
p.push('M')
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
p.push('L')
|
|
48
|
+
}
|
|
49
|
+
p.push(v[0])
|
|
50
|
+
p.push(v[1])
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
//line
|
|
54
|
+
ren.path(p)
|
|
55
|
+
.attr({
|
|
56
|
+
'name': 'hcextra',
|
|
57
|
+
'stroke-width': edgeWidth,
|
|
58
|
+
'stroke': edgeColor,
|
|
59
|
+
'fill': faceColor,
|
|
60
|
+
zIndex, //attr不能用z-index
|
|
61
|
+
})
|
|
62
|
+
.add()
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export default addPolygonByChart
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import each from 'lodash/each'
|
|
2
|
+
import addLineByChart from './addLineByChart.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function addPolylineByChart(chart, ps, opt = {}) {
|
|
6
|
+
each(ps, (p, k) => {
|
|
7
|
+
if (k === 0) {
|
|
8
|
+
return true
|
|
9
|
+
}
|
|
10
|
+
let p1 = ps[k - 1]
|
|
11
|
+
let p2 = p
|
|
12
|
+
addLineByChart(chart, p1, p2, opt)
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export default addPolylineByChart
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isNumber from 'lodash/isNumber'
|
|
3
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
4
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
5
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
6
|
+
import getPointXY from './getPointXY.mjs'
|
|
7
|
+
import getSizeWH from './getSizeWH.mjs'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function addRectByChart(chart, rectLeftTop, rectSize, opt = {}) {
|
|
11
|
+
|
|
12
|
+
//edgeWidth
|
|
13
|
+
let edgeWidth = get(opt, 'edgeWidth')
|
|
14
|
+
if (!isnum(edgeWidth)) {
|
|
15
|
+
edgeWidth = 1
|
|
16
|
+
}
|
|
17
|
+
edgeWidth = cdbl(edgeWidth)
|
|
18
|
+
edgeWidth = Math.max(edgeWidth, 0)
|
|
19
|
+
|
|
20
|
+
//edgeColor
|
|
21
|
+
let edgeColor = get(opt, 'edgeColor')
|
|
22
|
+
if (!isestr(edgeColor)) {
|
|
23
|
+
edgeColor = '#000'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//faceColor
|
|
27
|
+
let faceColor = get(opt, 'faceColor')
|
|
28
|
+
if (!isestr(faceColor)) {
|
|
29
|
+
faceColor = 'transparent'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//radius
|
|
33
|
+
let radius = get(opt, 'radius')
|
|
34
|
+
if (!isnum(radius)) {
|
|
35
|
+
radius = 0
|
|
36
|
+
}
|
|
37
|
+
radius = cdbl(radius)
|
|
38
|
+
radius = Math.max(radius, 0)
|
|
39
|
+
|
|
40
|
+
//zIndex
|
|
41
|
+
let zIndex = get(opt, 'zIndex')
|
|
42
|
+
if (!isNumber(zIndex)) {
|
|
43
|
+
zIndex = undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//x, y
|
|
47
|
+
let [x, y] = getPointXY(rectLeftTop)
|
|
48
|
+
|
|
49
|
+
//w, h
|
|
50
|
+
let [w, h] = getSizeWH(rectSize)
|
|
51
|
+
|
|
52
|
+
//renderer
|
|
53
|
+
let ren = chart.renderer
|
|
54
|
+
|
|
55
|
+
//rect
|
|
56
|
+
ren.rect(x, y, w, h)
|
|
57
|
+
.attr({
|
|
58
|
+
'name': 'hcextra',
|
|
59
|
+
'fill': faceColor,
|
|
60
|
+
'stroke-width': edgeWidth,
|
|
61
|
+
'stroke': edgeColor,
|
|
62
|
+
'r': radius,
|
|
63
|
+
zIndex, //attr不能用z-index
|
|
64
|
+
})
|
|
65
|
+
.add()
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export default addRectByChart
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import getPointXY from './getPointXY.mjs'
|
|
2
|
+
import getSizeWH from './getSizeWH.mjs'
|
|
3
|
+
import addRectByChart from './addRectByChart.mjs'
|
|
4
|
+
import addTextByChart from './addTextByChart.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function addRectCenterTextByChart(chart, p, rectSize, text, opt = {}) {
|
|
8
|
+
|
|
9
|
+
//x, y
|
|
10
|
+
let [x, y] = getPointXY(p)
|
|
11
|
+
|
|
12
|
+
//w, h
|
|
13
|
+
let [w, h] = getSizeWH(rectSize)
|
|
14
|
+
|
|
15
|
+
//_lt
|
|
16
|
+
let _lt = { x: x - w / 2, y: y - h / 2 }
|
|
17
|
+
|
|
18
|
+
//p
|
|
19
|
+
let _p = p
|
|
20
|
+
|
|
21
|
+
//addRectByChart
|
|
22
|
+
addRectByChart(chart, _lt, rectSize, opt)
|
|
23
|
+
|
|
24
|
+
//addTextByChart
|
|
25
|
+
addTextByChart(chart, _p, text, opt)
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export default addRectCenterTextByChart
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import getPointXY from './getPointXY.mjs'
|
|
2
|
+
import getSizeWH from './getSizeWH.mjs'
|
|
3
|
+
import addRectByChart from './addRectByChart.mjs'
|
|
4
|
+
import addTextByChart from './addTextByChart.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function addRectTextByChart(chart, rectLeftTop, rectSize, text, opt = {}) {
|
|
8
|
+
|
|
9
|
+
//x, y
|
|
10
|
+
let [x, y] = getPointXY(rectLeftTop)
|
|
11
|
+
|
|
12
|
+
//w, h
|
|
13
|
+
let [w, h] = getSizeWH(rectSize)
|
|
14
|
+
|
|
15
|
+
//_lt
|
|
16
|
+
let _lt = rectLeftTop
|
|
17
|
+
|
|
18
|
+
//_p
|
|
19
|
+
let _p = { x: x + w / 2, y: y + h / 2 }
|
|
20
|
+
|
|
21
|
+
//addRectByChart
|
|
22
|
+
addRectByChart(chart, _lt, rectSize, opt)
|
|
23
|
+
|
|
24
|
+
//addTextByChart
|
|
25
|
+
addTextByChart(chart, _p, text, opt)
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default addRectTextByChart
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
import isNumber from 'lodash/isNumber'
|
|
3
|
+
import isnum from 'wsemi/src/isnum.mjs'
|
|
4
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
5
|
+
import cdbl from 'wsemi/src/cdbl.mjs'
|
|
6
|
+
import getPointXY from './getPointXY.mjs'
|
|
7
|
+
import getFontfamily from './getFontfamily.mjs'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
function addTextByChart(chart, p, text, opt = {}) {
|
|
11
|
+
|
|
12
|
+
//fontSize
|
|
13
|
+
let fontSize = get(opt, 'fontSize')
|
|
14
|
+
if (!isnum(fontSize)) {
|
|
15
|
+
fontSize = 11
|
|
16
|
+
}
|
|
17
|
+
fontSize = cdbl(fontSize)
|
|
18
|
+
fontSize = Math.max(fontSize, 6) //最小6pt
|
|
19
|
+
|
|
20
|
+
//textAlign
|
|
21
|
+
let textAlign = get(opt, 'textAlign')
|
|
22
|
+
if (textAlign !== 'left' && textAlign !== 'center' && textAlign !== 'rigth') {
|
|
23
|
+
textAlign = 'center' //預設center, 文字中點在點p上
|
|
24
|
+
}
|
|
25
|
+
let kpTextAligh = {
|
|
26
|
+
'left': 'start',
|
|
27
|
+
'center': 'middle',
|
|
28
|
+
'rigth': 'end',
|
|
29
|
+
}
|
|
30
|
+
textAlign = kpTextAligh[textAlign]
|
|
31
|
+
|
|
32
|
+
//zIndex
|
|
33
|
+
let zIndex = get(opt, 'zIndex')
|
|
34
|
+
if (!isNumber(zIndex)) {
|
|
35
|
+
zIndex = undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//style
|
|
39
|
+
let style = get(opt, 'style')
|
|
40
|
+
if (!iseobj(style)) {
|
|
41
|
+
style = {}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//attr
|
|
45
|
+
let attr = get(opt, 'attr')
|
|
46
|
+
if (!iseobj(attr)) {
|
|
47
|
+
attr = {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//x, y
|
|
51
|
+
let [x, y] = getPointXY(p)
|
|
52
|
+
|
|
53
|
+
//renderer
|
|
54
|
+
let ren = chart.renderer
|
|
55
|
+
|
|
56
|
+
//g
|
|
57
|
+
let g = chart.renderer.g().add()
|
|
58
|
+
g.attr({
|
|
59
|
+
'transform': `translate(${x},${y})`,
|
|
60
|
+
zIndex, //attr不能用z-index
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
//text
|
|
64
|
+
ren.text(text, 0, 0)
|
|
65
|
+
.css({
|
|
66
|
+
color: '#000',
|
|
67
|
+
fontFamily: getFontfamily(),
|
|
68
|
+
fontSize: `${fontSize}pt`,
|
|
69
|
+
...style,
|
|
70
|
+
})
|
|
71
|
+
.attr({ //attr不能用kebab-case會無法識別
|
|
72
|
+
'name': 'hcextra',
|
|
73
|
+
'text-anchor': textAlign,
|
|
74
|
+
'alignment-baseline': 'central', //http://bl.ocks.org/eweitnauer/7325338
|
|
75
|
+
zIndex, //attr不能用z-index
|
|
76
|
+
...attr,
|
|
77
|
+
})
|
|
78
|
+
.add(g)
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export default addTextByChart
|