jmchart 1.1.93 → 1.1.95

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.
@@ -7936,13 +7936,16 @@ define(['exports'], function (exports) { 'use strict';
7936
7936
 
7937
7937
  let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7938
7938
 
7939
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
7940
+
7939
7941
  let longtapHandler = 0;
7940
7942
  let touchStartPos = {
7941
7943
  x: 0,
7942
7944
  y: 0
7943
7945
  };
7944
7946
  graph.on('mousedown touchstart', args => {
7945
- // 如果长按才启用
7947
+ lineTouching = 0; // 如果长按才启用
7948
+
7946
7949
  if (chart.style.markLine.longtap) {
7947
7950
  longtap = 1;
7948
7951
  longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
@@ -7976,17 +7979,40 @@ define(['exports'], function (exports) { 'use strict';
7976
7979
  }); // 移动标线
7977
7980
 
7978
7981
  graph.on('mousemove touchmove', args => {
7979
- const ox = args.position.x - touchStartPos.x;
7980
- const oy = args.position.y - touchStartPos.y;
7981
- const offpos = Math.sqrt(ox * ox + oy * oy);
7982
- if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
7982
+ args.offsetInfo = {
7983
+ x: 0,
7984
+ y: 0,
7985
+ offset: 0
7986
+ };
7987
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
7988
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
7989
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y); // 记录当次滑动的位置
7990
+
7991
+ touchStartPos = args.position; // 如果是长按启用,但手指又滑动了。则取消标线
7992
+
7993
+ if (longtap === 1) {
7994
+ if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
7995
+ else lineTouching = 1;
7996
+ }
7997
+
7998
+ args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
7999
+
8000
+ if (chart.style.markLine.lock) {
8001
+ // 标线状态一直禁用系统能力
8002
+ if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8003
+ lineTouching = 1;
8004
+ args.event.preventDefault(); // 阻止默认行为
8005
+ }
8006
+ }
7983
8007
 
8008
+ if (lineTouching === 0) lineTouching = 2;
7984
8009
  args.longtap = longtap;
7985
8010
  this.move(args);
7986
8011
  }); // 取消移动
7987
8012
 
7988
8013
  graph.on('mouseup touchend touchcancel touchleave', args => {
7989
8014
  longtap = 0;
8015
+ lineTouching = 0;
7990
8016
  this.endMove(args);
7991
8017
  });
7992
8018
  }
@@ -7938,13 +7938,16 @@ class jmMarkLineManager {
7938
7938
 
7939
7939
  let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7940
7940
 
7941
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
7942
+
7941
7943
  let longtapHandler = 0;
7942
7944
  let touchStartPos = {
7943
7945
  x: 0,
7944
7946
  y: 0
7945
7947
  };
7946
7948
  graph.on('mousedown touchstart', args => {
7947
- // 如果长按才启用
7949
+ lineTouching = 0; // 如果长按才启用
7950
+
7948
7951
  if (chart.style.markLine.longtap) {
7949
7952
  longtap = 1;
7950
7953
  longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
@@ -7978,17 +7981,40 @@ class jmMarkLineManager {
7978
7981
  }); // 移动标线
7979
7982
 
7980
7983
  graph.on('mousemove touchmove', args => {
7981
- const ox = args.position.x - touchStartPos.x;
7982
- const oy = args.position.y - touchStartPos.y;
7983
- const offpos = Math.sqrt(ox * ox + oy * oy);
7984
- if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
7984
+ args.offsetInfo = {
7985
+ x: 0,
7986
+ y: 0,
7987
+ offset: 0
7988
+ };
7989
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
7990
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
7991
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y); // 记录当次滑动的位置
7992
+
7993
+ touchStartPos = args.position; // 如果是长按启用,但手指又滑动了。则取消标线
7994
+
7995
+ if (longtap === 1) {
7996
+ if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
7997
+ else lineTouching = 1;
7998
+ }
7999
+
8000
+ args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
8001
+
8002
+ if (chart.style.markLine.lock) {
8003
+ // 标线状态一直禁用系统能力
8004
+ if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8005
+ lineTouching = 1;
8006
+ args.event.preventDefault(); // 阻止默认行为
8007
+ }
8008
+ }
7985
8009
 
8010
+ if (lineTouching === 0) lineTouching = 2;
7986
8011
  args.longtap = longtap;
7987
8012
  this.move(args);
7988
8013
  }); // 取消移动
7989
8014
 
7990
8015
  graph.on('mouseup touchend touchcancel touchleave', args => {
7991
8016
  longtap = 0;
8017
+ lineTouching = 0;
7992
8018
  this.endMove(args);
7993
8019
  });
7994
8020
  }
@@ -7934,13 +7934,16 @@ class jmMarkLineManager {
7934
7934
 
7935
7935
  let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7936
7936
 
7937
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
7938
+
7937
7939
  let longtapHandler = 0;
7938
7940
  let touchStartPos = {
7939
7941
  x: 0,
7940
7942
  y: 0
7941
7943
  };
7942
7944
  graph.on('mousedown touchstart', args => {
7943
- // 如果长按才启用
7945
+ lineTouching = 0; // 如果长按才启用
7946
+
7944
7947
  if (chart.style.markLine.longtap) {
7945
7948
  longtap = 1;
7946
7949
  longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
@@ -7974,17 +7977,40 @@ class jmMarkLineManager {
7974
7977
  }); // 移动标线
7975
7978
 
7976
7979
  graph.on('mousemove touchmove', args => {
7977
- const ox = args.position.x - touchStartPos.x;
7978
- const oy = args.position.y - touchStartPos.y;
7979
- const offpos = Math.sqrt(ox * ox + oy * oy);
7980
- if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
7980
+ args.offsetInfo = {
7981
+ x: 0,
7982
+ y: 0,
7983
+ offset: 0
7984
+ };
7985
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
7986
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
7987
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y); // 记录当次滑动的位置
7988
+
7989
+ touchStartPos = args.position; // 如果是长按启用,但手指又滑动了。则取消标线
7990
+
7991
+ if (longtap === 1) {
7992
+ if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
7993
+ else lineTouching = 1;
7994
+ }
7995
+
7996
+ args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
7997
+
7998
+ if (chart.style.markLine.lock) {
7999
+ // 标线状态一直禁用系统能力
8000
+ if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8001
+ lineTouching = 1;
8002
+ args.event.preventDefault(); // 阻止默认行为
8003
+ }
8004
+ }
7981
8005
 
8006
+ if (lineTouching === 0) lineTouching = 2;
7982
8007
  args.longtap = longtap;
7983
8008
  this.move(args);
7984
8009
  }); // 取消移动
7985
8010
 
7986
8011
  graph.on('mouseup touchend touchcancel touchleave', args => {
7987
8012
  longtap = 0;
8013
+ lineTouching = 0;
7988
8014
  this.endMove(args);
7989
8015
  });
7990
8016
  }
@@ -7937,13 +7937,16 @@
7937
7937
 
7938
7938
  let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7939
7939
 
7940
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
7941
+
7940
7942
  let longtapHandler = 0;
7941
7943
  let touchStartPos = {
7942
7944
  x: 0,
7943
7945
  y: 0
7944
7946
  };
7945
7947
  graph.on('mousedown touchstart', args => {
7946
- // 如果长按才启用
7948
+ lineTouching = 0; // 如果长按才启用
7949
+
7947
7950
  if (chart.style.markLine.longtap) {
7948
7951
  longtap = 1;
7949
7952
  longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
@@ -7977,17 +7980,40 @@
7977
7980
  }); // 移动标线
7978
7981
 
7979
7982
  graph.on('mousemove touchmove', args => {
7980
- const ox = args.position.x - touchStartPos.x;
7981
- const oy = args.position.y - touchStartPos.y;
7982
- const offpos = Math.sqrt(ox * ox + oy * oy);
7983
- if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
7983
+ args.offsetInfo = {
7984
+ x: 0,
7985
+ y: 0,
7986
+ offset: 0
7987
+ };
7988
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
7989
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
7990
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y); // 记录当次滑动的位置
7991
+
7992
+ touchStartPos = args.position; // 如果是长按启用,但手指又滑动了。则取消标线
7993
+
7994
+ if (longtap === 1) {
7995
+ if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
7996
+ else lineTouching = 1;
7997
+ }
7998
+
7999
+ args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
8000
+
8001
+ if (chart.style.markLine.lock) {
8002
+ // 标线状态一直禁用系统能力
8003
+ if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8004
+ lineTouching = 1;
8005
+ args.event.preventDefault(); // 阻止默认行为
8006
+ }
8007
+ }
7984
8008
 
8009
+ if (lineTouching === 0) lineTouching = 2;
7985
8010
  args.longtap = longtap;
7986
8011
  this.move(args);
7987
8012
  }); // 取消移动
7988
8013
 
7989
8014
  graph.on('mouseup touchend touchcancel touchleave', args => {
7990
8015
  longtap = 0;
8016
+ lineTouching = 0;
7991
8017
  this.endMove(args);
7992
8018
  });
7993
8019
  }
@@ -7939,13 +7939,16 @@ System.register([], function (exports) {
7939
7939
 
7940
7940
  let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
7941
7941
 
7942
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
7943
+
7942
7944
  let longtapHandler = 0;
7943
7945
  let touchStartPos = {
7944
7946
  x: 0,
7945
7947
  y: 0
7946
7948
  };
7947
7949
  graph.on('mousedown touchstart', args => {
7948
- // 如果长按才启用
7950
+ lineTouching = 0; // 如果长按才启用
7951
+
7949
7952
  if (chart.style.markLine.longtap) {
7950
7953
  longtap = 1;
7951
7954
  longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
@@ -7979,17 +7982,40 @@ System.register([], function (exports) {
7979
7982
  }); // 移动标线
7980
7983
 
7981
7984
  graph.on('mousemove touchmove', args => {
7982
- const ox = args.position.x - touchStartPos.x;
7983
- const oy = args.position.y - touchStartPos.y;
7984
- const offpos = Math.sqrt(ox * ox + oy * oy);
7985
- if (longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
7985
+ args.offsetInfo = {
7986
+ x: 0,
7987
+ y: 0,
7988
+ offset: 0
7989
+ };
7990
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
7991
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
7992
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y); // 记录当次滑动的位置
7993
+
7994
+ touchStartPos = args.position; // 如果是长按启用,但手指又滑动了。则取消标线
7995
+
7996
+ if (longtap === 1) {
7997
+ if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
7998
+ else lineTouching = 1;
7999
+ }
8000
+
8001
+ args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
8002
+
8003
+ if (chart.style.markLine.lock) {
8004
+ // 标线状态一直禁用系统能力
8005
+ if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8006
+ lineTouching = 1;
8007
+ args.event.preventDefault(); // 阻止默认行为
8008
+ }
8009
+ }
7986
8010
 
8011
+ if (lineTouching === 0) lineTouching = 2;
7987
8012
  args.longtap = longtap;
7988
8013
  this.move(args);
7989
8014
  }); // 取消移动
7990
8015
 
7991
8016
  graph.on('mouseup touchend touchcancel touchleave', args => {
7992
8017
  longtap = 0;
8018
+ lineTouching = 0;
7993
8019
  this.endMove(args);
7994
8020
  });
7995
8021
  }
package/example/bar.html CHANGED
@@ -53,7 +53,11 @@
53
53
  y: true
54
54
  },
55
55
  markLine: {
56
- longtap: true // 长按才出现标线
56
+ longtap: false, // 长按才出现标线
57
+ lock: {
58
+ y: 10,
59
+ x: 10
60
+ }
57
61
  },
58
62
  margin: {
59
63
  bottom: 2
@@ -66,14 +70,16 @@
66
70
 
67
71
  // touch改变数据点事件
68
72
  chart.on('touchPointChange', function(args) {
69
- console.log(args);
73
+ //console.log(args);
70
74
  });
71
75
 
72
76
  chart.on('marklinestartmove', (args)=>{
73
- if(args.event) {
74
- args.event.preventDefault(); // 阻止默认行为
75
- args.event.stopPropagation();
76
- }
77
+
78
+ });
79
+
80
+
81
+ chart.on('marklinemove', (args)=>{
82
+
77
83
  });
78
84
 
79
85
 
@@ -94,7 +100,7 @@
94
100
  color: 'transparent'
95
101
  },
96
102
  fill: function(point) {
97
- console.log(point);
103
+ //console.log(point);
98
104
  if(point.yValue < 0) return 'green';
99
105
  else return 'red';
100
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmchart",
3
- "version": "1.1.93",
3
+ "version": "1.1.95",
4
4
  "description": "chart",
5
5
  "main": "./index.js",
6
6
  "directories": {
@@ -48,13 +48,15 @@ export default class jmMarkLineManager {
48
48
  area.children.add(this.yMarkLine);
49
49
  }
50
50
 
51
- let longtap = 0;// 是否有长按, 0 未开始,1已按下,2识别为长按
51
+ let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
52
+ let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
52
53
  let longtapHandler = 0;
53
54
  let touchStartPos = {
54
55
  x: 0,
55
56
  y: 0
56
57
  };
57
58
  graph.on('mousedown touchstart', (args) => {
59
+ lineTouching = 0;
58
60
  // 如果长按才启用
59
61
  if(chart.style.markLine.longtap) {
60
62
  longtap = 1;
@@ -87,10 +89,40 @@ export default class jmMarkLineManager {
87
89
  });
88
90
  // 移动标线
89
91
  graph.on('mousemove touchmove', (args) => {
90
- const ox = args.position.x - touchStartPos.x;
91
- const oy = args.position.y - touchStartPos.y;
92
- const offpos = Math.sqrt(ox * ox + oy * oy);
93
- if(longtap === 1 && offpos > 15) longtap = 0; // 如果移动了,则取消长按
92
+ args.offsetInfo = {
93
+ x: 0,
94
+ y: 0,
95
+ offset: 0
96
+ };
97
+ args.offsetInfo.x = args.position.x - touchStartPos.x;
98
+ args.offsetInfo.y = args.position.y - touchStartPos.y;
99
+ args.offsetInfo.offset = Math.sqrt(args.offsetInfo.x * args.offsetInfo.x + args.offsetInfo.y * args.offsetInfo.y);
100
+
101
+ // 记录当次滑动的位置
102
+ touchStartPos = args.position;
103
+
104
+ // 如果是长按启用,但手指又滑动了。则取消标线
105
+ if(longtap === 1) {
106
+ if(args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
107
+ else lineTouching = 1;
108
+ }
109
+
110
+ args.event.stopPropagation();
111
+ // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
112
+ if(chart.style.markLine.lock){
113
+ // 标线状态一直禁用系统能力
114
+ // 如果指定了锁定值,只需要一项符合要求就进行锁定
115
+ if((lineTouching === 0 &&
116
+ ((chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y) ||
117
+ (chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x)))
118
+ || lineTouching === 1) {
119
+
120
+ lineTouching = 1;
121
+ args.event.preventDefault(); // 阻止默认行为
122
+ }
123
+ }
124
+
125
+ if(lineTouching === 0) lineTouching = 2;
94
126
 
95
127
  args.longtap = longtap;
96
128
  this.move(args);
@@ -98,7 +130,7 @@ export default class jmMarkLineManager {
98
130
  // 取消移动
99
131
  graph.on('mouseup touchend touchcancel touchleave', (args) => {
100
132
  longtap = 0;
101
-
133
+ lineTouching = 0;
102
134
  this.endMove(args);
103
135
  });
104
136
  }