jmchart 1.2.7 → 1.2.10
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/dist/jmchart.amd.js +647 -263
- package/dist/jmchart.cjs.js +647 -263
- package/dist/jmchart.esm.js +647 -263
- package/dist/jmchart.iife.js +647 -263
- package/dist/jmchart.system.js +647 -263
- package/package.json +43 -42
- package/example/bar.html +0 -197
- package/example/candlestick.html +0 -288
- package/example/index.html +0 -294
- package/example/js/vconsole.js +0 -10
- package/example/js/vue_2.6.14.min.js +0 -6
- package/example/line.html +0 -315
- package/example/pie.html +0 -391
- package/example/radar.html +0 -162
- package/example/stackBar.html +0 -143
- package/example/stackLine.html +0 -148
- package/example/test.html +0 -94
- package/example/vue.html +0 -329
- package/example/wk/line.html +0 -327
package/package.json
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "jmchart",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "chart",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"directories": {
|
|
7
|
-
"example": "example"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"clone": "git clone https://ghproxy.com/https://github.com/jiamao/jmchart.git",
|
|
12
|
-
"dev": "node server.js",
|
|
13
|
-
"push": "npm publish --registry=https://registry.npmjs.org",
|
|
14
|
-
"build": "node build.js"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/jiamao/jmchart.git"
|
|
19
|
-
},
|
|
20
|
-
"keywords": [
|
|
21
|
-
"chart",
|
|
22
|
-
"jmgraph"
|
|
23
|
-
],
|
|
24
|
-
"author": "jiamao",
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/jiamao/jmchart/issues"
|
|
28
|
-
},
|
|
29
|
-
"homepage": "https://github.com/jiamao/jmchart#readme",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"jmgraph": "^3.2.
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@babel/core": "^7.10.2",
|
|
35
|
-
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"rollup
|
|
39
|
-
"rollup-plugin-
|
|
40
|
-
"rollup-plugin-
|
|
41
|
-
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "jmchart",
|
|
3
|
+
"version": "1.2.10",
|
|
4
|
+
"description": "chart",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"directories": {
|
|
7
|
+
"example": "example"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"clone": "git clone https://ghproxy.com/https://github.com/jiamao/jmchart.git",
|
|
12
|
+
"dev": "node server.js",
|
|
13
|
+
"push": "npm publish --registry=https://registry.npmjs.org",
|
|
14
|
+
"build": "node build.js"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/jiamao/jmchart.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"chart",
|
|
22
|
+
"jmgraph"
|
|
23
|
+
],
|
|
24
|
+
"author": "jiamao",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/jiamao/jmchart/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/jiamao/jmchart#readme",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"jmgraph": "^3.2.6"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.10.2",
|
|
35
|
+
"@babel/plugin-proposal-class-properties": "^7.10.1",
|
|
36
|
+
"canvas": "^2.11.2",
|
|
37
|
+
"express": "^4.17.1",
|
|
38
|
+
"rollup": "^2.16.1",
|
|
39
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
40
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
41
|
+
"rollup-plugin-sourcemaps": "^0.6.2"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/example/bar.html
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
|
|
7
|
-
|
|
8
|
-
<style>
|
|
9
|
-
html,body {
|
|
10
|
-
margin:0;
|
|
11
|
-
padding:0;
|
|
12
|
-
width:100%;
|
|
13
|
-
height:100%;
|
|
14
|
-
}
|
|
15
|
-
</style>
|
|
16
|
-
<script type="module">
|
|
17
|
-
//window.devicePixelRatio = 1;
|
|
18
|
-
import { jmChart } from '../dist/jmchart.esm.js';
|
|
19
|
-
|
|
20
|
-
(function load() {
|
|
21
|
-
var w = Math.max((window.innerWidth || window.document.body.clientWidth) * 0.9, 600);
|
|
22
|
-
var h = Math.max((window.innerHeight || window.document.body.clientHeight) * 0.6, 200);
|
|
23
|
-
inichart(w,h);
|
|
24
|
-
})();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function inichart(w, h) {
|
|
28
|
-
var touchCanvas = document.getElementById('mytouchcanvas');
|
|
29
|
-
var chart = new jmChart('mycanvas', {
|
|
30
|
-
width: w,
|
|
31
|
-
height: h,
|
|
32
|
-
xField: 'x',
|
|
33
|
-
baseY: 0, // Y轴基线的值 不填就会用最 小值
|
|
34
|
-
// 最大和最小X值, 这里一般不用指定,除非硬是需要
|
|
35
|
-
//minXValue : 0,
|
|
36
|
-
//maxXValue : 10,
|
|
37
|
-
//minYValue: -200,
|
|
38
|
-
//maxYValue: 300,
|
|
39
|
-
autoRefresh: true,
|
|
40
|
-
// 指定了操作层的canvas,如果不想自已指定,也可以把touchGraph设置为true也是一样的效果
|
|
41
|
-
touchCanvas,
|
|
42
|
-
style: {
|
|
43
|
-
axis: {
|
|
44
|
-
x: true,
|
|
45
|
-
y: true
|
|
46
|
-
},
|
|
47
|
-
markLine: {
|
|
48
|
-
longtap: false, // 长按才出现标线
|
|
49
|
-
lock: {
|
|
50
|
-
y: 10,
|
|
51
|
-
x: 10
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
margin: {
|
|
55
|
-
|
|
56
|
-
bottom: 2
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
chart.legend.legendPosition = 'top';
|
|
61
|
-
chart.legend.visible = true;
|
|
62
|
-
chart.enableAnimate = true;
|
|
63
|
-
|
|
64
|
-
// touch改变数据点事件
|
|
65
|
-
chart.on('touchPointChange', function(args) {
|
|
66
|
-
//console.log(args);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
chart.on('marklinestartmove', (args)=>{
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
chart.on('marklinemove', (args)=>{
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var bar1 = chart.createSeries('bar', {
|
|
80
|
-
field: 'y1',
|
|
81
|
-
style: {
|
|
82
|
-
// 渐变色
|
|
83
|
-
color: 'linear-gradient(50% 0 50% 100%, #ccc 0, #000 0.5, #fff 1)',
|
|
84
|
-
perWidth: 0.5, // 控制barWidth占比,优先级比barWidth低
|
|
85
|
-
//barWidth: 80,// 优先级最高
|
|
86
|
-
label: {
|
|
87
|
-
show: true,
|
|
88
|
-
offset: 10, // 离柱偏移量
|
|
89
|
-
shadow: {
|
|
90
|
-
x: 0,
|
|
91
|
-
y: 0,
|
|
92
|
-
blur: 0,
|
|
93
|
-
color: 'transparent'
|
|
94
|
-
},
|
|
95
|
-
fill: function(point) {
|
|
96
|
-
//console.log(point);
|
|
97
|
-
if(point.yValue < 0) return 'green';
|
|
98
|
-
else return 'red';
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
itemLabelFormat(p) {
|
|
103
|
-
return p.yValue.toFixed(2);
|
|
104
|
-
},
|
|
105
|
-
// 图例格式化,如果不给定,则采用legendLabel
|
|
106
|
-
legendFormat: function(options) {
|
|
107
|
-
return '图1';
|
|
108
|
-
},
|
|
109
|
-
yLabelFormat: (v, label) => {
|
|
110
|
-
return v.toFixed(0);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
var bar2 = chart.createSeries('bar', {
|
|
115
|
-
field: 'y8',
|
|
116
|
-
style: {
|
|
117
|
-
// 自定义单个bar的颜色
|
|
118
|
-
color: function(p) {
|
|
119
|
-
if(p && p.xValue == 3) {
|
|
120
|
-
return 'green';
|
|
121
|
-
}
|
|
122
|
-
// 默认值
|
|
123
|
-
return 'linear-gradient(50% 0 50% 100%, #ff0000 0, #00ff00 0.5, #0000ff 1)';
|
|
124
|
-
},
|
|
125
|
-
label: {
|
|
126
|
-
show: false,
|
|
127
|
-
offset: 5 // 离柱偏移量
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
// 图例格式化,如果不给定,则采用legendLabel
|
|
131
|
-
legendFormat: function(options) {
|
|
132
|
-
return '图4';
|
|
133
|
-
},
|
|
134
|
-
yLabelFormat: (v, label) => {
|
|
135
|
-
return v.toFixed(0);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const datacount = 5;
|
|
140
|
-
function animate() {
|
|
141
|
-
if(true) {
|
|
142
|
-
chart.data = [];
|
|
143
|
-
for(var i = 0;i<datacount;i++) {
|
|
144
|
-
var data = {
|
|
145
|
-
x : i,
|
|
146
|
-
y1 : Math.random() * 200 - 100,
|
|
147
|
-
y2: Math.random() * 200 + 50,
|
|
148
|
-
y3: Math.random() * 200 + 50,
|
|
149
|
-
y4:Math.random() * 200 + 50,
|
|
150
|
-
y5:Math.random() * 200 + 50,
|
|
151
|
-
y6:Math.random() * 200 + 50,
|
|
152
|
-
y7:i,
|
|
153
|
-
y8:Math.random() * 200 - 50,
|
|
154
|
-
y9:Math.random() * 200 - 50,
|
|
155
|
-
y10:Math.random() * 200 - 50
|
|
156
|
-
};
|
|
157
|
-
if(i == 3) {
|
|
158
|
-
data.y = null;
|
|
159
|
-
}
|
|
160
|
-
chart.data.push(data);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
for(var i=datacount-1;i>0;i--) {
|
|
165
|
-
var x = chart.data[i].x;
|
|
166
|
-
chart.data[i] = chart.utils.clone(chart.data[i - 1]);
|
|
167
|
-
chart.data[i].x = x;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
chart.source[0] = {
|
|
171
|
-
x : chart.data[0].x,
|
|
172
|
-
y : Math.random() * 200 - 100
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//setTimeout(animate,500);
|
|
178
|
-
chart.refresh();
|
|
179
|
-
console.log(chart.data);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
animate();
|
|
183
|
-
chart.utils.bindEvent(document.getElementById('btnRedraw'),'click',animate);
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
</script>
|
|
187
|
-
</head>
|
|
188
|
-
<body>
|
|
189
|
-
<div>
|
|
190
|
-
<canvas id="mycanvas">
|
|
191
|
-
</canvas>
|
|
192
|
-
<canvas id="mytouchcanvas" style="position: absolute; left:0; top: 0;">
|
|
193
|
-
</canvas>
|
|
194
|
-
</div>
|
|
195
|
-
<button id="btnRedraw">重绘</button>
|
|
196
|
-
</body>
|
|
197
|
-
</html>
|
package/example/candlestick.html
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<!--<script type="text/javascript" src="../src/jmchart.debug.js" id="jmgraph" ></script>-->
|
|
7
|
-
<script src="js/vconsole.js"></script>
|
|
8
|
-
|
|
9
|
-
<style>
|
|
10
|
-
html,body {
|
|
11
|
-
margin:0;
|
|
12
|
-
padding:0;
|
|
13
|
-
width:100%;
|
|
14
|
-
height:100%;
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
<script type="module">
|
|
18
|
-
import jmChart from '../dist/jmchart.esm.js';
|
|
19
|
-
(function load() {
|
|
20
|
-
var w = window.innerWidth || window.document.body.clientWidth;
|
|
21
|
-
var h = Math.min((window.innerHeight || window.document.body.clientHeight) * 0.5, 500);
|
|
22
|
-
|
|
23
|
-
var vConsole = new window.VConsole();
|
|
24
|
-
|
|
25
|
-
inichart(w,h);
|
|
26
|
-
})();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function inichart(w, h) {
|
|
30
|
-
const option = {
|
|
31
|
-
width: w,
|
|
32
|
-
height: h,
|
|
33
|
-
xField: 'day',
|
|
34
|
-
enableAnimate: false,
|
|
35
|
-
legendPosition: 'top',
|
|
36
|
-
legendVisible: false, // 不显示图例
|
|
37
|
-
touchGraph: true, // 是否依赖生成操作图层,当点比较多时,性能低下可以把它设为true
|
|
38
|
-
style: {
|
|
39
|
-
layout: 'inside', // inside 二边不对齐Y轴,内缩一个刻度 | normal
|
|
40
|
-
// 跟随标线
|
|
41
|
-
markLine: {
|
|
42
|
-
x: true, // 显示X标线
|
|
43
|
-
y: true, // 显示Y标线
|
|
44
|
-
stroke: 'red',
|
|
45
|
-
fill: '#fff',
|
|
46
|
-
lineWidth: 1,
|
|
47
|
-
longtap: true // 长按启用
|
|
48
|
-
},
|
|
49
|
-
// x轴 Y轴隐藏
|
|
50
|
-
axis: {
|
|
51
|
-
stroke: 'transparent',
|
|
52
|
-
align: 'center', // label居中对齐
|
|
53
|
-
grid: {
|
|
54
|
-
x: false, // 不显示X轴网格
|
|
55
|
-
y: false // 显示Y轴网格
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
margin: {
|
|
59
|
-
top: 30,
|
|
60
|
-
left: 50,
|
|
61
|
-
right: 10,
|
|
62
|
-
bottom: 30
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const chart1 = new jmChart('mycanvas1', option);
|
|
67
|
-
// touch改变数据点事件
|
|
68
|
-
chart1.on('touchPointChange', function(args) {
|
|
69
|
-
console.log(args);
|
|
70
|
-
document.getElementById('mydatalog').innerHTML = JSON.stringify(args.points[0].data);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const kline = chart1.createSeries('candlestick', {
|
|
75
|
-
// 如果字段名跟下面的一至,可以不指定
|
|
76
|
-
fields: [
|
|
77
|
-
'start', // 开盘
|
|
78
|
-
'end', // 收盘
|
|
79
|
-
'max', // 最大值
|
|
80
|
-
'min' // 最小值
|
|
81
|
-
],
|
|
82
|
-
style: {
|
|
83
|
-
// 阴线颜色
|
|
84
|
-
negativeColor: 'green',
|
|
85
|
-
// 阳线颜色
|
|
86
|
-
masculineColor: 'red',
|
|
87
|
-
lineWidth: 2,
|
|
88
|
-
//barWidth: 15
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const chart2 = new jmChart('mycanvas2', {
|
|
93
|
-
...option,
|
|
94
|
-
height: 200,
|
|
95
|
-
style: {
|
|
96
|
-
...option.style,
|
|
97
|
-
// 跟随标线
|
|
98
|
-
markLine: {
|
|
99
|
-
x: false, // 显示X标线
|
|
100
|
-
y: true, // 显示Y标线
|
|
101
|
-
stroke: 'red',
|
|
102
|
-
fill: '#fff',
|
|
103
|
-
lineWidth: 1,
|
|
104
|
-
longtap: true // 长按启用
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const bar1 = chart2.createSeries('bar', {
|
|
111
|
-
field: 'max',
|
|
112
|
-
style: {
|
|
113
|
-
label: {
|
|
114
|
-
show: false
|
|
115
|
-
},
|
|
116
|
-
// 跟随标线
|
|
117
|
-
markLine: {
|
|
118
|
-
x: false, // 显示X标线
|
|
119
|
-
y: true, // 显示Y标线
|
|
120
|
-
stroke: 'red',
|
|
121
|
-
fill: '#fff',
|
|
122
|
-
lineWidth: 1,
|
|
123
|
-
longtap: true // 长按启用
|
|
124
|
-
},
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// 图1的标线移动 图2跟随
|
|
129
|
-
chart1.on('marklinestartmove', (args)=>{
|
|
130
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
131
|
-
chart2.markLine.startMove(args, 'y'); //只联动y
|
|
132
|
-
});
|
|
133
|
-
chart1.on('marklinemove', (args)=>{
|
|
134
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
135
|
-
chart2.markLine.move(args);
|
|
136
|
-
});
|
|
137
|
-
chart1.on('marklineendmove', (args)=>{
|
|
138
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
139
|
-
chart2.markLine.endMove(args);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// 图2的标线移动 图1跟随
|
|
143
|
-
chart2.on('marklinestartmove', (args)=>{
|
|
144
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
145
|
-
chart1.markLine.startMove(args, 'y');//只联动y
|
|
146
|
-
});
|
|
147
|
-
chart2.on('marklinemove', (args)=>{
|
|
148
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
149
|
-
chart1.markLine.move(args);
|
|
150
|
-
});
|
|
151
|
-
chart2.on('marklineendmove', (args)=>{
|
|
152
|
-
args.cancel = true;// 终止事件继续执行,以免二个chart死循环
|
|
153
|
-
chart1.markLine.endMove(args);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const data = createData(); // 生成测试数据
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
let dataCount = 20; // 展示数据个数
|
|
161
|
-
let dataIndex = data.length - dataCount; // 展示数据起始索引
|
|
162
|
-
|
|
163
|
-
function refresh() {
|
|
164
|
-
chart2.data = chart1.data = data.filter((d, i) => {
|
|
165
|
-
if(i >= dataIndex && i < dataCount + dataIndex) return true;
|
|
166
|
-
return false;
|
|
167
|
-
});
|
|
168
|
-
chart1.refresh();
|
|
169
|
-
chart2.refresh();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
refresh(0, 20);
|
|
173
|
-
|
|
174
|
-
// 根据滑动来绘制数据
|
|
175
|
-
let dataTouchPosition = {
|
|
176
|
-
x: 0,
|
|
177
|
-
touching: false, // 是否在滑动中
|
|
178
|
-
scaleTouching : false,
|
|
179
|
-
scaleTouchOffset: 0
|
|
180
|
-
};
|
|
181
|
-
chart1.on('touchstart', (args) => {
|
|
182
|
-
// 双指滑动, 缩放
|
|
183
|
-
if(args.event.touches.length === 2) {
|
|
184
|
-
dataTouchPosition.scaleTouching = true;
|
|
185
|
-
const ox = args.event.touches[0].pageX - args.event.touches[1].pageX ;
|
|
186
|
-
const oy = args.event.touches[0].pageY - args.event.touches[1].pageY;
|
|
187
|
-
// 数据偏移距离
|
|
188
|
-
dataTouchPosition.scaleTouchOffset = Math.sqrt(ox * ox + oy * oy);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
dataTouchPosition.touching = true;
|
|
192
|
-
}
|
|
193
|
-
dataTouchPosition.x = args.position.x;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// 长按了
|
|
197
|
-
chart1.on('marklinelongtapstart', (args) => {
|
|
198
|
-
dataTouchPosition.touching = false;// 长按取消数据滑动
|
|
199
|
-
|
|
200
|
-
document.getElementById('mylog').innerHTML = 'marklinelongtapstart:';
|
|
201
|
-
console.log('marklinelongtapstart', args);
|
|
202
|
-
});
|
|
203
|
-
chart1.on('touchmove', (args) => {
|
|
204
|
-
if(!args.target || !args.target.chartGraph) return;
|
|
205
|
-
console.log('touchmove', args);
|
|
206
|
-
|
|
207
|
-
// 双指缩放
|
|
208
|
-
if(dataTouchPosition.scaleTouching && args.event.touches.length === 2) {
|
|
209
|
-
const ox = args.event.touches[0].pageX - args.event.touches[1].pageX ;
|
|
210
|
-
const oy = args.event.touches[0].pageY - args.event.touches[1].pageY;
|
|
211
|
-
// 数据偏移距离
|
|
212
|
-
const scaleOffset = Math.sqrt(ox * ox + oy * oy);
|
|
213
|
-
const dataOffset = Math.round((dataTouchPosition.scaleTouchOffset - scaleOffset) / args.target.bounds.width * dataCount);
|
|
214
|
-
|
|
215
|
-
if(Math.abs(dataOffset) > 0) {
|
|
216
|
-
let index = Math.max(dataIndex - dataOffset, 0);
|
|
217
|
-
if(index >= 0) dataIndex = index;
|
|
218
|
-
dataCount += dataOffset * 2;
|
|
219
|
-
// 展示数据个数不能越过数组上限
|
|
220
|
-
if(dataCount > data.length) dataCount = data.length;
|
|
221
|
-
if(dataCount > data.length - dataIndex) dataCount = data.length - dataIndex;
|
|
222
|
-
|
|
223
|
-
refresh();// 刷新数据
|
|
224
|
-
|
|
225
|
-
dataTouchPosition.scaleTouchOffset = scaleOffset;
|
|
226
|
-
|
|
227
|
-
document.getElementById('mylog').innerHTML = 'scaleTouching:' + dataOffset + ' index:' + dataIndex + ' dataCount:' + dataCount;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
// 在滑动标线,则不处理
|
|
231
|
-
//else if(args.target.chartGraph.yMarkLine && args.target.chartGraph.yMarkLine.visible) {
|
|
232
|
-
// dataTouchPosition.touching = false;
|
|
233
|
-
//}
|
|
234
|
-
else if(dataTouchPosition.touching) {
|
|
235
|
-
const ox = dataTouchPosition.x - args.position.x;
|
|
236
|
-
// 数据偏移量
|
|
237
|
-
const offDataCount = Math.round(ox / args.target.bounds.width * dataCount);
|
|
238
|
-
if(Math.abs(offDataCount) > 0) {
|
|
239
|
-
let index = dataIndex + offDataCount;
|
|
240
|
-
if(index < 0) index = 0
|
|
241
|
-
else if(index > data.length - dataCount) index = data.length - dataCount;
|
|
242
|
-
|
|
243
|
-
// 刷新数据
|
|
244
|
-
dataIndex = index;
|
|
245
|
-
refresh();
|
|
246
|
-
|
|
247
|
-
dataTouchPosition.x = args.position.x;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
chart1.on('touchend touchcancel touchleave', (args) => {
|
|
252
|
-
dataTouchPosition.touching = false;
|
|
253
|
-
dataTouchPosition.scaleTouching = false;
|
|
254
|
-
console.log('touchend');
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function createData() {
|
|
259
|
-
const data = [];
|
|
260
|
-
const startDate = new Date('2021/01/01 00:00:00');
|
|
261
|
-
for(var i = 0;i<365;i++) {
|
|
262
|
-
startDate.setDate(startDate.getDate() + 1);
|
|
263
|
-
const d = {
|
|
264
|
-
day : startDate.getFullYear() + '-' + ('00'+(startDate.getMonth()+1)).substr(-2) + '-' + ('00'+startDate.getDate()).substr(-2),
|
|
265
|
-
start : Math.random() * 5 + 15,
|
|
266
|
-
end: Math.random() * 5 + 15
|
|
267
|
-
};
|
|
268
|
-
d.max = Math.max(d.start, d.end) + Math.random() * 5;
|
|
269
|
-
d.min = Math.min(d.start, d.end) - Math.random() * 5;
|
|
270
|
-
data.push(d);
|
|
271
|
-
}
|
|
272
|
-
return data;
|
|
273
|
-
}
|
|
274
|
-
</script>
|
|
275
|
-
</head>
|
|
276
|
-
<body>
|
|
277
|
-
<div id="mycanvas1">
|
|
278
|
-
</div>
|
|
279
|
-
<hr />
|
|
280
|
-
<div id="mydatalog" style="word-wrap:break-word">
|
|
281
|
-
</div>
|
|
282
|
-
<hr />
|
|
283
|
-
<div id="mylog" style="word-wrap:break-word">
|
|
284
|
-
</div>
|
|
285
|
-
<div id="mycanvas2">
|
|
286
|
-
</div>
|
|
287
|
-
</body>
|
|
288
|
-
</html>
|