jmchart 1.2.10 → 1.2.12
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 +8207 -6503
- package/dist/jmchart.cjs.js +8204 -6500
- package/dist/jmchart.esm.js +8203 -6499
- package/dist/jmchart.iife.js +8205 -6501
- package/dist/jmchart.system.js +8205 -6501
- package/index.js +8 -8
- package/package.json +11 -11
- 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/common/tooltip.js
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 显示提示控件
|
|
4
|
-
* params参数:style=样式,value=显示的文字
|
|
5
|
-
*
|
|
6
|
-
* @class jmTooltip
|
|
7
|
-
* @for jmGraph
|
|
8
|
-
* @module jmGraph
|
|
9
|
-
* @param {jmGraph} graph 当前画布
|
|
10
|
-
* @param {object} params 参数
|
|
11
|
-
*/
|
|
12
|
-
function jmTooltip(graph,params) {
|
|
13
|
-
if(!params) params = {};
|
|
14
|
-
var style = params.style || {};
|
|
15
|
-
style.font = style.font || "15px Arial";
|
|
16
|
-
this.type = 'jmTooltip';
|
|
17
|
-
|
|
18
|
-
this.graph = graph;
|
|
19
|
-
|
|
20
|
-
this.position(params.position || {x:0,y:0});
|
|
21
|
-
this.initializing(graph.context,style);
|
|
22
|
-
|
|
23
|
-
this.element = document.createElement('div');
|
|
24
|
-
this.element.className = 'jm-tooltip';
|
|
25
|
-
this.element.style.position = 'absolute';
|
|
26
|
-
this.element.style.display = 'none';
|
|
27
|
-
this.value(params.value);
|
|
28
|
-
document.body.appendChild(this.element);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
jmUtils.extend(jmTooltip,jmControl);//jmPath
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 写入样式
|
|
35
|
-
*
|
|
36
|
-
* @method setStyle
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
jmTooltip.prototype.setStyle = function(style) {
|
|
40
|
-
style = style || this.style;
|
|
41
|
-
if(style && typeof style == 'object') {
|
|
42
|
-
for(var k in style) {
|
|
43
|
-
if(typeof(k) != 'string' || typeof(style[k]) != 'string') continue;
|
|
44
|
-
try {
|
|
45
|
-
this.element.style[k] = style[k];
|
|
46
|
-
}
|
|
47
|
-
catch(e) {
|
|
48
|
-
window.console.log(e);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 计算提示位并显示
|
|
56
|
-
*
|
|
57
|
-
* @method draw
|
|
58
|
-
*/
|
|
59
|
-
jmTooltip.prototype.draw = function() {
|
|
60
|
-
this.setPosition();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 设置提示坐标位置
|
|
65
|
-
*
|
|
66
|
-
* @method setPosition
|
|
67
|
-
* @param {number} x X轴坐标
|
|
68
|
-
* @param {number} y Y轴坐标
|
|
69
|
-
*/
|
|
70
|
-
jmTooltip.prototype.setPosition = function(x,y) {
|
|
71
|
-
this.x = x || this.x || 0;
|
|
72
|
-
this.y = y || this.y || 0;
|
|
73
|
-
//获取当前控件的绝对位置
|
|
74
|
-
var bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
75
|
-
var location = this.getLocation();
|
|
76
|
-
x = this.x + location.left + bounds.left;
|
|
77
|
-
y = this.y + location.top + bounds.top;
|
|
78
|
-
|
|
79
|
-
var graphpostion = this.graph.getPosition();
|
|
80
|
-
x += graphpostion.left;
|
|
81
|
-
y += graphpostion.top;
|
|
82
|
-
|
|
83
|
-
this.element.style.top = y + 'px';
|
|
84
|
-
this.element.style.left = x + 'px';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 移除当前控件
|
|
89
|
-
*
|
|
90
|
-
* @method remove
|
|
91
|
-
*/
|
|
92
|
-
jmTooltip.prototype.remove = function() {
|
|
93
|
-
if(this.element) {
|
|
94
|
-
document.body.removeChild(this.element);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 显示当前控件
|
|
100
|
-
*
|
|
101
|
-
* @method remove
|
|
102
|
-
*/
|
|
103
|
-
jmTooltip.prototype.show = function() {
|
|
104
|
-
if(this.element) {
|
|
105
|
-
this.element.style.display = 'inline';
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 隐藏当前控件
|
|
111
|
-
*
|
|
112
|
-
* @method remove
|
|
113
|
-
*/
|
|
114
|
-
jmTooltip.prototype.hide = function() {
|
|
115
|
-
if(this.element) {
|
|
116
|
-
this.element.style.display = 'none';
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 设置或获取当前值
|
|
122
|
-
*
|
|
123
|
-
* @method value
|
|
124
|
-
*/
|
|
125
|
-
jmTooltip.prototype.value = function(v) {
|
|
126
|
-
if(this.element) {
|
|
127
|
-
if(v !== undefined) {
|
|
128
|
-
this.element.innerHTML = v;
|
|
129
|
-
}
|
|
130
|
-
return this.element.innerHTML;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 设置或获取当前宽度
|
|
136
|
-
*
|
|
137
|
-
* @method width
|
|
138
|
-
* @param {number} w 宽度
|
|
139
|
-
*/
|
|
140
|
-
jmTooltip.prototype.width = function(w) {
|
|
141
|
-
if(this.element) {
|
|
142
|
-
if(w !== undefined) {
|
|
143
|
-
this.element.style.width = w + 'px';
|
|
144
|
-
}
|
|
145
|
-
return this.element.clientWidth;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 设置或获取当前高度
|
|
151
|
-
*
|
|
152
|
-
* @method width
|
|
153
|
-
* @param {number} w 宽度
|
|
154
|
-
*/
|
|
155
|
-
jmTooltip.prototype.height = function(h) {
|
|
156
|
-
if(this.element) {
|
|
157
|
-
if(h !== undefined) {
|
|
158
|
-
this.element.style.height = h + 'px';
|
|
159
|
-
}
|
|
160
|
-
return this.element.clientHeight;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 显示提示控件
|
|
4
|
+
* params参数:style=样式,value=显示的文字
|
|
5
|
+
*
|
|
6
|
+
* @class jmTooltip
|
|
7
|
+
* @for jmGraph
|
|
8
|
+
* @module jmGraph
|
|
9
|
+
* @param {jmGraph} graph 当前画布
|
|
10
|
+
* @param {object} params 参数
|
|
11
|
+
*/
|
|
12
|
+
function jmTooltip(graph,params) {
|
|
13
|
+
if(!params) params = {};
|
|
14
|
+
var style = params.style || {};
|
|
15
|
+
style.font = style.font || "15px Arial";
|
|
16
|
+
this.type = 'jmTooltip';
|
|
17
|
+
|
|
18
|
+
this.graph = graph;
|
|
19
|
+
|
|
20
|
+
this.position(params.position || {x:0,y:0});
|
|
21
|
+
this.initializing(graph.context,style);
|
|
22
|
+
|
|
23
|
+
this.element = document.createElement('div');
|
|
24
|
+
this.element.className = 'jm-tooltip';
|
|
25
|
+
this.element.style.position = 'absolute';
|
|
26
|
+
this.element.style.display = 'none';
|
|
27
|
+
this.value(params.value);
|
|
28
|
+
document.body.appendChild(this.element);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
jmUtils.extend(jmTooltip,jmControl);//jmPath
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 写入样式
|
|
35
|
+
*
|
|
36
|
+
* @method setStyle
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
jmTooltip.prototype.setStyle = function(style) {
|
|
40
|
+
style = style || this.style;
|
|
41
|
+
if(style && typeof style == 'object') {
|
|
42
|
+
for(var k in style) {
|
|
43
|
+
if(typeof(k) != 'string' || typeof(style[k]) != 'string') continue;
|
|
44
|
+
try {
|
|
45
|
+
this.element.style[k] = style[k];
|
|
46
|
+
}
|
|
47
|
+
catch(e) {
|
|
48
|
+
window.console.log(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 计算提示位并显示
|
|
56
|
+
*
|
|
57
|
+
* @method draw
|
|
58
|
+
*/
|
|
59
|
+
jmTooltip.prototype.draw = function() {
|
|
60
|
+
this.setPosition();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 设置提示坐标位置
|
|
65
|
+
*
|
|
66
|
+
* @method setPosition
|
|
67
|
+
* @param {number} x X轴坐标
|
|
68
|
+
* @param {number} y Y轴坐标
|
|
69
|
+
*/
|
|
70
|
+
jmTooltip.prototype.setPosition = function(x,y) {
|
|
71
|
+
this.x = x || this.x || 0;
|
|
72
|
+
this.y = y || this.y || 0;
|
|
73
|
+
//获取当前控件的绝对位置
|
|
74
|
+
var bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
75
|
+
var location = this.getLocation();
|
|
76
|
+
x = this.x + location.left + bounds.left;
|
|
77
|
+
y = this.y + location.top + bounds.top;
|
|
78
|
+
|
|
79
|
+
var graphpostion = this.graph.getPosition();
|
|
80
|
+
x += graphpostion.left;
|
|
81
|
+
y += graphpostion.top;
|
|
82
|
+
|
|
83
|
+
this.element.style.top = y + 'px';
|
|
84
|
+
this.element.style.left = x + 'px';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 移除当前控件
|
|
89
|
+
*
|
|
90
|
+
* @method remove
|
|
91
|
+
*/
|
|
92
|
+
jmTooltip.prototype.remove = function() {
|
|
93
|
+
if(this.element) {
|
|
94
|
+
document.body.removeChild(this.element);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 显示当前控件
|
|
100
|
+
*
|
|
101
|
+
* @method remove
|
|
102
|
+
*/
|
|
103
|
+
jmTooltip.prototype.show = function() {
|
|
104
|
+
if(this.element) {
|
|
105
|
+
this.element.style.display = 'inline';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 隐藏当前控件
|
|
111
|
+
*
|
|
112
|
+
* @method remove
|
|
113
|
+
*/
|
|
114
|
+
jmTooltip.prototype.hide = function() {
|
|
115
|
+
if(this.element) {
|
|
116
|
+
this.element.style.display = 'none';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 设置或获取当前值
|
|
122
|
+
*
|
|
123
|
+
* @method value
|
|
124
|
+
*/
|
|
125
|
+
jmTooltip.prototype.value = function(v) {
|
|
126
|
+
if(this.element) {
|
|
127
|
+
if(v !== undefined) {
|
|
128
|
+
this.element.innerHTML = v;
|
|
129
|
+
}
|
|
130
|
+
return this.element.innerHTML;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 设置或获取当前宽度
|
|
136
|
+
*
|
|
137
|
+
* @method width
|
|
138
|
+
* @param {number} w 宽度
|
|
139
|
+
*/
|
|
140
|
+
jmTooltip.prototype.width = function(w) {
|
|
141
|
+
if(this.element) {
|
|
142
|
+
if(w !== undefined) {
|
|
143
|
+
this.element.style.width = w + 'px';
|
|
144
|
+
}
|
|
145
|
+
return this.element.clientWidth;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 设置或获取当前高度
|
|
151
|
+
*
|
|
152
|
+
* @method width
|
|
153
|
+
* @param {number} w 宽度
|
|
154
|
+
*/
|
|
155
|
+
jmTooltip.prototype.height = function(h) {
|
|
156
|
+
if(this.element) {
|
|
157
|
+
if(h !== undefined) {
|
|
158
|
+
this.element.style.height = h + 'px';
|
|
159
|
+
}
|
|
160
|
+
return this.element.clientHeight;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
package/src/common/utils.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
export default {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @param {Array}
|
|
7
|
-
* @param {
|
|
8
|
-
* @
|
|
9
|
-
*/
|
|
10
|
-
arrayIsChange(source, target, compare) {
|
|
11
|
-
if(!source || !target) return true;
|
|
12
|
-
if(source.length !== target.length) return true;
|
|
13
|
-
|
|
14
|
-
if(typeof compare === 'function') {
|
|
15
|
-
for(let i=0; i<source.length; i++) {
|
|
16
|
-
if(!compare(source[i], target[i])) return true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
/**
|
|
4
|
+
* 对比二个数组数据是否改变
|
|
5
|
+
* @param {Array} source 被对比的数组
|
|
6
|
+
* @param {Array} target 对比数组
|
|
7
|
+
* @param {Function} compare 比较函数
|
|
8
|
+
* @return {boolean} 是否改变
|
|
9
|
+
*/
|
|
10
|
+
arrayIsChange(source, target, compare) {
|
|
11
|
+
if(!source || !target) return true;
|
|
12
|
+
if(source.length !== target.length) return true;
|
|
13
|
+
|
|
14
|
+
if(typeof compare === 'function') {
|
|
15
|
+
for(let i = 0; i < source.length; i++) {
|
|
16
|
+
if(!compare(source[i], target[i])) return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return source != target;
|
|
21
|
+
}
|
|
22
22
|
}
|
package/src/component/vchart.js
CHANGED
|
@@ -1,143 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import jmChart from '../../index.js';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
props: {
|
|
7
|
-
chartData: Array,
|
|
8
|
-
chartOptions: Object,
|
|
9
|
-
chartSeries: Array,
|
|
10
|
-
width: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: 200
|
|
13
|
-
},
|
|
14
|
-
height: {
|
|
15
|
-
type: String,
|
|
16
|
-
default: 200
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
data: function() {
|
|
20
|
-
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this
|
|
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
|
-
|
|
87
|
-
this.chartInstance.bind('
|
|
88
|
-
this.$emit('markline-
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.$emit('
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this
|
|
110
|
-
this
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.chartInstance.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
this.chartInstance.createSeries(s.type, s);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
this.chartInstance.data = this.chartData;
|
|
137
|
-
this.chartInstance.refresh();
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
template: `<div ref="jmChartContainer" :style="{width: width, height: height}"></div>`
|
|
143
|
-
}
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import jmChart from '../../index.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
props: {
|
|
7
|
+
chartData: Array,
|
|
8
|
+
chartOptions: Object,
|
|
9
|
+
chartSeries: Array,
|
|
10
|
+
width: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 200
|
|
13
|
+
},
|
|
14
|
+
height: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 200
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
data: function() {
|
|
20
|
+
return {
|
|
21
|
+
option: this.chartOptions
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
chartInstance: null,
|
|
25
|
+
|
|
26
|
+
mounted () {
|
|
27
|
+
this.option = Object.assign({
|
|
28
|
+
enableAnimate: false,
|
|
29
|
+
legendPosition: 'top',
|
|
30
|
+
legendVisible: true,
|
|
31
|
+
width: this.width,
|
|
32
|
+
height: this.height
|
|
33
|
+
}, this.chartOptions);
|
|
34
|
+
|
|
35
|
+
this.initChart();
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
updated() {
|
|
39
|
+
this.initChart();
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
destroyed() {
|
|
43
|
+
this.chartInstance && this.chartInstance.destroy();
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
watch: {
|
|
47
|
+
chartData: function(newData, oldData) {
|
|
48
|
+
this.refresh();
|
|
49
|
+
},
|
|
50
|
+
width: function(newWidth, oldWidth) {
|
|
51
|
+
if(!this.chartInstance) return;
|
|
52
|
+
this.$nextTick(() => {
|
|
53
|
+
if(!this.chartInstance || !this.$refs.jmChartContainer) return;
|
|
54
|
+
this.chartInstance.width = this.$refs.jmChartContainer.clientWidth || this.$refs.jmChartContainer.offsetWidth;
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
height: function(newHeight, oldHeight) {
|
|
58
|
+
if(!this.chartInstance) return;
|
|
59
|
+
this.$nextTick(() => {
|
|
60
|
+
if(!this.chartInstance || !this.$refs.jmChartContainer) return;
|
|
61
|
+
this.chartInstance.height = this.$refs.jmChartContainer.clientHeight || this.$refs.jmChartContainer.offsetHeight;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
methods: {
|
|
67
|
+
initChart() {
|
|
68
|
+
if(this.chartInstance) return;
|
|
69
|
+
|
|
70
|
+
this.chartInstance = new jmChart(this.$refs.jmChartContainer, this.option);
|
|
71
|
+
|
|
72
|
+
if(this.chartData && this.chartData.length) this.refresh();
|
|
73
|
+
|
|
74
|
+
this.chartInstance.bind('touchPointChange', (args) => {
|
|
75
|
+
this.$emit('touch-point-change', args);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.chartInstance.bind('marklinelongtapstart', (args) => {
|
|
79
|
+
this.$emit('markline-longtap-start', args);
|
|
80
|
+
});
|
|
81
|
+
this.chartInstance.bind('marklinestartmove', (args) => {
|
|
82
|
+
this.$emit('markline-start-move', args);
|
|
83
|
+
});
|
|
84
|
+
this.chartInstance.bind('marklinemove', (args) => {
|
|
85
|
+
this.$emit('markline-move', args);
|
|
86
|
+
});
|
|
87
|
+
this.chartInstance.bind('marklineendmove', (args) => {
|
|
88
|
+
this.$emit('markline-end-move', args);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
this.chartInstance.touchGraph.bind('touchstart mousedown', (args) => {
|
|
92
|
+
this.$emit('touchstart', args);
|
|
93
|
+
this.$emit('mousedown', args);
|
|
94
|
+
});
|
|
95
|
+
this.chartInstance.touchGraph.bind('touchmove mousemove', (args) => {
|
|
96
|
+
this.$emit('touchmove', args);
|
|
97
|
+
this.$emit('mousemove', args);
|
|
98
|
+
});
|
|
99
|
+
this.chartInstance.touchGraph.bind('touchend touchcancel mouseup', (args) => {
|
|
100
|
+
this.$emit('touchend', args);
|
|
101
|
+
this.$emit('mouseup', args);
|
|
102
|
+
});
|
|
103
|
+
this.chartInstance.touchGraph.bind('touchleave', (args) => {
|
|
104
|
+
this.$emit('touchleave', args);
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
refresh() {
|
|
109
|
+
this.$nextTick(() => {
|
|
110
|
+
this.initChart();
|
|
111
|
+
|
|
112
|
+
this.chartInstance.reset();
|
|
113
|
+
|
|
114
|
+
if(this.chartSeries && this.chartSeries.length) {
|
|
115
|
+
for(let s of this.chartSeries) {
|
|
116
|
+
if(!s.type) {
|
|
117
|
+
console.error('必须指定serie type');
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
this.chartInstance.createSeries(s.type, s);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
this.chartInstance.data = this.chartData;
|
|
124
|
+
this.chartInstance.refresh();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
template: `<div ref="jmChartContainer" :style="{width: width, height: height}"></div>`
|
|
130
|
+
}
|