jmchart 1.2.10 → 1.2.11
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 +322 -40
- package/build.js +35 -35
- package/dist/jmchart.amd.js +8206 -6502
- package/dist/jmchart.cjs.js +8203 -6499
- package/dist/jmchart.esm.js +8202 -6498
- package/dist/jmchart.iife.js +8204 -6500
- package/dist/jmchart.system.js +8204 -6500
- package/index.js +8 -8
- package/package.json +7 -7
- package/rollup.config.js +26 -26
- package/server.js +48 -48
- package/src/common/style.js +285 -285
- package/src/common/tooltip.js +165 -165
- package/src/common/utils.js +21 -21
- package/src/component/vchart.js +130 -143
- package/src/core/axis/axis.js +727 -727
- package/src/core/legend/legend.js +145 -145
- package/src/core/markLine/manager.js +186 -186
- package/src/core/markLine/markLine.js +191 -191
- package/src/jmChart.js +427 -427
- package/src/series/barSeries.js +123 -135
- package/src/series/candlestickSeries.js +114 -114
- package/src/series/lineSeries.js +224 -243
- package/src/series/pieSeries.js +337 -337
- package/src/series/radarSeries.js +313 -313
- package/src/series/series.js +387 -404
- package/src/series/stackBarSeries.js +149 -149
- package/src/series/stackLineSeries.js +145 -145
package/src/series/barSeries.js
CHANGED
|
@@ -1,136 +1,124 @@
|
|
|
1
|
-
import jmSeries from './series.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @param {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const point = points[i];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 在图上加下定制图形
|
|
129
|
-
* @param {jmShape} shape 图形
|
|
130
|
-
*/
|
|
131
|
-
addShape(shape) {
|
|
132
|
-
this.children.add(shape);
|
|
133
|
-
this.shapes.add(shape);
|
|
134
|
-
return shape;
|
|
135
|
-
}
|
|
1
|
+
import jmSeries from './series.js';
|
|
2
|
+
|
|
3
|
+
const ANIMATION_DATA_THRESHOLD = 100;
|
|
4
|
+
const DEFAULT_ANIMATION_COUNT = 10;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 柱图
|
|
8
|
+
*
|
|
9
|
+
* @class jmBarSeries
|
|
10
|
+
* @module jmChart
|
|
11
|
+
* @param {jmChart} chart 当前图表
|
|
12
|
+
* @param {array} mappings 图形字段映射
|
|
13
|
+
* @param {style} style 样式
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export default class jmBarSeries extends jmSeries {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 初始化柱图
|
|
23
|
+
*
|
|
24
|
+
* @method init
|
|
25
|
+
* @for jmBarSeries
|
|
26
|
+
*/
|
|
27
|
+
init() {
|
|
28
|
+
const {points, dataChanged} = this.initDataPoint();
|
|
29
|
+
|
|
30
|
+
const len = points.length;
|
|
31
|
+
if(!len) return;
|
|
32
|
+
|
|
33
|
+
this.initWidth(len);
|
|
34
|
+
|
|
35
|
+
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0) && len < ANIMATION_DATA_THRESHOLD;
|
|
36
|
+
let aniIsEnd = true;
|
|
37
|
+
const aniCount = (this.style.aniCount || DEFAULT_ANIMATION_COUNT);
|
|
38
|
+
|
|
39
|
+
for(let i = 0; i < len; i++) {
|
|
40
|
+
const point = points[i];
|
|
41
|
+
|
|
42
|
+
if(typeof point.y === 'undefined' || point.y === null) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
point.style.fill = this.getColor(point);
|
|
47
|
+
const sp = this.addShape(this.graph.createPath(null, point.style));
|
|
48
|
+
|
|
49
|
+
const p1 = {x: point.x - this.barTotalWidth / 2 + this.barWidth * this.barIndex, y: this.baseY };
|
|
50
|
+
const p4 = {x: p1.x + this.barWidth, y: p1.y };
|
|
51
|
+
|
|
52
|
+
const p2 = {x: p1.x, y: p1.y };
|
|
53
|
+
const p3 = {x: p4.x, y: p1.y };
|
|
54
|
+
|
|
55
|
+
if(isRunningAni) {
|
|
56
|
+
const step = point.height / aniCount;
|
|
57
|
+
const offHeight = step * this.___animateCounter;
|
|
58
|
+
p2.y = p1.y - offHeight;
|
|
59
|
+
|
|
60
|
+
if((step >= 0 && p2.y <= point.y) || (step < 0 && p2.y >= point.y)) {
|
|
61
|
+
p2.y = point.y;
|
|
62
|
+
} else {
|
|
63
|
+
aniIsEnd = false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
p3.y = p2.y;
|
|
67
|
+
} else {
|
|
68
|
+
p2.y = point.y;
|
|
69
|
+
p3.y = point.y;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
sp.points.push(p1);
|
|
73
|
+
sp.points.push(p2);
|
|
74
|
+
sp.points.push(p3);
|
|
75
|
+
sp.points.push(p4);
|
|
76
|
+
|
|
77
|
+
this.createItemLabel(point);
|
|
78
|
+
|
|
79
|
+
this.emit('onPointCreated', point);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if(aniIsEnd) {
|
|
83
|
+
this.___animateCounter = 0;
|
|
84
|
+
} else {
|
|
85
|
+
this.___animateCounter++;
|
|
86
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
87
|
+
this.needUpdate = true;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 计算柱子宽度
|
|
93
|
+
initWidth(count) {
|
|
94
|
+
|
|
95
|
+
//计算每个柱子占宽
|
|
96
|
+
//每项柱子占宽除以柱子个数,默认最大宽度为30
|
|
97
|
+
const maxWidth = this.xAxis.width / count / this.graph.barSeriesCount;
|
|
98
|
+
|
|
99
|
+
if(this.style.barWidth > 0) {
|
|
100
|
+
this.barWidth = Number(this.style.barWidth);
|
|
101
|
+
this.barTotalWidth = this.barWidth * this.graph.barSeriesCount;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.barTotalWidth = (this.xAxis.width / count * (this.style.perWidth||0.4));
|
|
105
|
+
this.barWidth = this.barTotalWidth / this.graph.barSeriesCount;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if(this.barWidth > maxWidth) {
|
|
109
|
+
this.barWidth = maxWidth;
|
|
110
|
+
this.barTotalWidth = maxWidth * this.graph.barSeriesCount;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 在图上加下定制图形
|
|
117
|
+
* @param {jmShape} shape 图形
|
|
118
|
+
*/
|
|
119
|
+
addShape(shape) {
|
|
120
|
+
this.children.add(shape);
|
|
121
|
+
this.shapes.add(shape);
|
|
122
|
+
return shape;
|
|
123
|
+
}
|
|
136
124
|
}
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
import jmSeries from './series.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* K线图
|
|
6
|
-
*
|
|
7
|
-
* @class jmCandlestickSeries
|
|
8
|
-
* @module jmChart
|
|
9
|
-
* @param {jmChart} chart 当前图表
|
|
10
|
-
* @param {array} mappings 图形字段映射
|
|
11
|
-
* @param {style} style 样式
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
//构造函数
|
|
15
|
-
export default class jmCandlestickSeries extends jmSeries {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
options.style = options.style || options.graph.style.line;
|
|
18
|
-
super(options);
|
|
19
|
-
|
|
20
|
-
//this.on('beginDraw', this[PreDrawKey]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 绘制图形前 初始化线条
|
|
25
|
-
*
|
|
26
|
-
* @method preDraw
|
|
27
|
-
* @for jmLineSeries
|
|
28
|
-
*/
|
|
29
|
-
init() {
|
|
30
|
-
//生成描点位
|
|
31
|
-
const {
|
|
32
|
-
points
|
|
33
|
-
} = this.initDataPoint();
|
|
34
|
-
|
|
35
|
-
//去除多余的线条
|
|
36
|
-
//当数据源线条数比现有的少时,删除多余的线条
|
|
37
|
-
const len = points.length;
|
|
38
|
-
this.initWidth(len);
|
|
39
|
-
|
|
40
|
-
const w = this.barWidth / 2; //实心处宽度的一半
|
|
41
|
-
|
|
42
|
-
for(let i=0; i< len;i++) {
|
|
43
|
-
const p = points[i];
|
|
44
|
-
|
|
45
|
-
//如果当前点无效,则跳致下一点
|
|
46
|
-
if(typeof p.y === 'undefined' || p.y === null) {
|
|
47
|
-
//prePoint = null;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const sp = this.addShape(this.graph.createPath([], p.style));
|
|
52
|
-
|
|
53
|
-
const bl = {
|
|
54
|
-
x: p.x - w,
|
|
55
|
-
y: p.points[0].y
|
|
56
|
-
};
|
|
57
|
-
const br = {
|
|
58
|
-
x: p.x + w,
|
|
59
|
-
y: p.points[0].y
|
|
60
|
-
};
|
|
61
|
-
const tl = {
|
|
62
|
-
x: p.x - w,
|
|
63
|
-
y: p.points[1].y
|
|
64
|
-
};
|
|
65
|
-
const tr = {
|
|
66
|
-
x: p.x + w,
|
|
67
|
-
y: p.points[1].y
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// 默认认为是阳线
|
|
71
|
-
let tm = p.points[1];
|
|
72
|
-
let bm = p.points[0];
|
|
73
|
-
p.style.stroke = p.style.fill = p.style.masculineColor || 'red';
|
|
74
|
-
|
|
75
|
-
// 开盘大于收盘,则阴线
|
|
76
|
-
if(p.points[0].yValue > p.points[1].yValue) {
|
|
77
|
-
p.style.stroke = p.style.fill = p.style.negativeColor || 'green';
|
|
78
|
-
bl.y = br.y = p.points[1].y;
|
|
79
|
-
tl.y = tr.y = p.points[0].y;
|
|
80
|
-
|
|
81
|
-
tm = p.points[0];
|
|
82
|
-
bm = p.points[1];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
sp.points.push(p.points[2], tm, tl, bl, bm, p.points[3], bm, br, tr, tm, p.points[2]);
|
|
86
|
-
|
|
87
|
-
// 生成关健值标注
|
|
88
|
-
this.emit('onPointCreated', p);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 计算实心体宽度
|
|
93
|
-
initWidth(count) {
|
|
94
|
-
//计算每个柱子占宽
|
|
95
|
-
//每项柱子占宽除以柱子个数,默认最大宽度为30
|
|
96
|
-
const maxWidth = this.xAxis.width / count;
|
|
97
|
-
|
|
98
|
-
if(this.style.barWidth > 0) {
|
|
99
|
-
this.barWidth = Number(this.style.barWidth);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
this.barWidth = maxWidth * (this.style.perWidth||0.4);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if(this.barWidth > maxWidth) {
|
|
106
|
-
this.barWidth = maxWidth;
|
|
107
|
-
this.barTotalWidth = maxWidth * count;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
jmCandlestickSeries
|
|
114
|
-
}
|
|
1
|
+
|
|
2
|
+
import jmSeries from './series.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* K线图
|
|
6
|
+
*
|
|
7
|
+
* @class jmCandlestickSeries
|
|
8
|
+
* @module jmChart
|
|
9
|
+
* @param {jmChart} chart 当前图表
|
|
10
|
+
* @param {array} mappings 图形字段映射
|
|
11
|
+
* @param {style} style 样式
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
//构造函数
|
|
15
|
+
export default class jmCandlestickSeries extends jmSeries {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
options.style = options.style || options.graph.style.line;
|
|
18
|
+
super(options);
|
|
19
|
+
|
|
20
|
+
//this.on('beginDraw', this[PreDrawKey]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 绘制图形前 初始化线条
|
|
25
|
+
*
|
|
26
|
+
* @method preDraw
|
|
27
|
+
* @for jmLineSeries
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
//生成描点位
|
|
31
|
+
const {
|
|
32
|
+
points
|
|
33
|
+
} = this.initDataPoint();
|
|
34
|
+
|
|
35
|
+
//去除多余的线条
|
|
36
|
+
//当数据源线条数比现有的少时,删除多余的线条
|
|
37
|
+
const len = points.length;
|
|
38
|
+
this.initWidth(len);
|
|
39
|
+
|
|
40
|
+
const w = this.barWidth / 2; //实心处宽度的一半
|
|
41
|
+
|
|
42
|
+
for(let i=0; i< len;i++) {
|
|
43
|
+
const p = points[i];
|
|
44
|
+
|
|
45
|
+
//如果当前点无效,则跳致下一点
|
|
46
|
+
if(typeof p.y === 'undefined' || p.y === null) {
|
|
47
|
+
//prePoint = null;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const sp = this.addShape(this.graph.createPath([], p.style));
|
|
52
|
+
|
|
53
|
+
const bl = {
|
|
54
|
+
x: p.x - w,
|
|
55
|
+
y: p.points[0].y
|
|
56
|
+
};
|
|
57
|
+
const br = {
|
|
58
|
+
x: p.x + w,
|
|
59
|
+
y: p.points[0].y
|
|
60
|
+
};
|
|
61
|
+
const tl = {
|
|
62
|
+
x: p.x - w,
|
|
63
|
+
y: p.points[1].y
|
|
64
|
+
};
|
|
65
|
+
const tr = {
|
|
66
|
+
x: p.x + w,
|
|
67
|
+
y: p.points[1].y
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// 默认认为是阳线
|
|
71
|
+
let tm = p.points[1];
|
|
72
|
+
let bm = p.points[0];
|
|
73
|
+
p.style.stroke = p.style.fill = p.style.masculineColor || 'red';
|
|
74
|
+
|
|
75
|
+
// 开盘大于收盘,则阴线
|
|
76
|
+
if(p.points[0].yValue > p.points[1].yValue) {
|
|
77
|
+
p.style.stroke = p.style.fill = p.style.negativeColor || 'green';
|
|
78
|
+
bl.y = br.y = p.points[1].y;
|
|
79
|
+
tl.y = tr.y = p.points[0].y;
|
|
80
|
+
|
|
81
|
+
tm = p.points[0];
|
|
82
|
+
bm = p.points[1];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
sp.points.push(p.points[2], tm, tl, bl, bm, p.points[3], bm, br, tr, tm, p.points[2]);
|
|
86
|
+
|
|
87
|
+
// 生成关健值标注
|
|
88
|
+
this.emit('onPointCreated', p);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 计算实心体宽度
|
|
93
|
+
initWidth(count) {
|
|
94
|
+
//计算每个柱子占宽
|
|
95
|
+
//每项柱子占宽除以柱子个数,默认最大宽度为30
|
|
96
|
+
const maxWidth = this.xAxis.width / count;
|
|
97
|
+
|
|
98
|
+
if(this.style.barWidth > 0) {
|
|
99
|
+
this.barWidth = Number(this.style.barWidth);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.barWidth = maxWidth * (this.style.perWidth||0.4);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if(this.barWidth > maxWidth) {
|
|
106
|
+
this.barWidth = maxWidth;
|
|
107
|
+
this.barTotalWidth = maxWidth * count;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
jmCandlestickSeries
|
|
114
|
+
}
|