jmchart 1.2.2 → 1.2.5

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.
@@ -872,21 +872,13 @@ class jmUtils {
872
872
  return r;
873
873
  }
874
874
  // window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
875
- static requestAnimationFrame(callback) {
876
- if(typeof requestAnimationFrame === 'undefined') {
877
- return setTimeout(callback, 20);
878
- }
879
- else {
880
- return requestAnimationFrame(callback);
881
- }
875
+ static requestAnimationFrame(callback, win) {
876
+ let fun = win && win.requestAnimationFrame? win.requestAnimationFrame: (typeof window !== 'undefined' && window.requestAnimationFrame? window.requestAnimationFrame: setTimeout);
877
+ return fun(callback, 20);
882
878
  }
883
- static cancelAnimationFrame(handler) {
884
- if(typeof requestAnimationFrame === 'undefined') {
885
- return clearTimeout(handler);
886
- }
887
- else {
888
- return cancelAnimationFrame(handler);
889
- }
879
+ static cancelAnimationFrame(handler, win) {
880
+ let fun = win && win.cancelAnimationFrame? win.cancelAnimationFrame: (typeof window !== 'undefined' && window.cancelAnimationFrame? window.cancelAnimationFrame: clearTimeout);
881
+ return fun(handler);
890
882
  }
891
883
  }
892
884
 
@@ -1325,8 +1317,48 @@ class jmProperty extends jmObject {
1325
1317
  set graph(v) {
1326
1318
  return this.__pro('graph', v);
1327
1319
  }
1320
+
1321
+ /**
1322
+ * 在下次进行重绘时执行
1323
+ * @param {Function} handler
1324
+ */
1325
+ requestAnimationFrame(handler) {
1326
+ return jmUtils.requestAnimationFrame(handler, this.graph? this.graph.canvas: null);
1327
+ }
1328
+ /**
1329
+ * 清除执行回调
1330
+ * @param {Function} handler
1331
+ * @returns
1332
+ */
1333
+ cancelAnimationFrame(handler) {
1334
+ return jmUtils.cancelAnimationFrame(handler, this.graph? this.graph.canvas: null);
1335
+ }
1328
1336
  }
1329
1337
 
1338
+ //样式名称,也当做白名单使用
1339
+ const jmStyleMap = {
1340
+ 'fill':'fillStyle',
1341
+ 'stroke':'strokeStyle',
1342
+ 'shadow.blur':'shadowBlur',
1343
+ 'shadow.x':'shadowOffsetX',
1344
+ 'shadow.y':'shadowOffsetY',
1345
+ 'shadow.color':'shadowColor',
1346
+ 'lineWidth' : 'lineWidth',
1347
+ 'miterLimit': 'miterLimit',
1348
+ 'fillStyle' : 'fillStyle',
1349
+ 'strokeStyle' : 'strokeStyle',
1350
+ 'font' : 'font',
1351
+ 'opacity' : 'globalAlpha',
1352
+ 'textAlign' : 'textAlign',
1353
+ 'textBaseline' : 'textBaseline',
1354
+ 'shadowBlur' : 'shadowBlur',
1355
+ 'shadowOffsetX' : 'shadowOffsetX',
1356
+ 'shadowOffsetY' : 'shadowOffsetY',
1357
+ 'shadowColor' : 'shadowColor',
1358
+ 'lineJoin': 'lineJoin',//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
1359
+ 'lineCap':'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
1360
+ };
1361
+
1330
1362
  /**
1331
1363
  * 控件基础对象
1332
1364
  * 控件的基础属性和方法
@@ -1353,30 +1385,6 @@ class jmControl extends jmProperty {
1353
1385
  this.zIndex = params.zIndex || 0;
1354
1386
  this.interactive = typeof params.interactive == 'undefined'? true : params.interactive;
1355
1387
 
1356
- //样式名称,也当做白名单使用
1357
- this.jmStyleMap = {
1358
- 'fill':'fillStyle',
1359
- 'stroke':'strokeStyle',
1360
- 'shadow.blur':'shadowBlur',
1361
- 'shadow.x':'shadowOffsetX',
1362
- 'shadow.y':'shadowOffsetY',
1363
- 'shadow.color':'shadowColor',
1364
- 'lineWidth' : 'lineWidth',
1365
- 'miterLimit': 'miterLimit',
1366
- 'fillStyle' : 'fillStyle',
1367
- 'strokeStyle' : 'strokeStyle',
1368
- 'font' : 'font',
1369
- 'opacity' : 'globalAlpha',
1370
- 'textAlign' : 'textAlign',
1371
- 'textBaseline' : 'textBaseline',
1372
- 'shadowBlur' : 'shadowBlur',
1373
- 'shadowOffsetX' : 'shadowOffsetX',
1374
- 'shadowOffsetY' : 'shadowOffsetY',
1375
- 'shadowColor' : 'shadowColor',
1376
- 'lineJoin': 'lineJoin',//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
1377
- 'lineCap':'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
1378
- };
1379
-
1380
1388
  this.initializing();
1381
1389
 
1382
1390
  this.on = this.bind;
@@ -1674,120 +1682,93 @@ class jmControl extends jmProperty {
1674
1682
  * @param {string} mpkey 样式名称在映射中的key(例如:shadow.blur为模糊值)
1675
1683
  */
1676
1684
  let __setStyle = (style, name, mpkey) => {
1677
- //let styleValue = style[mpkey||name]||style;
1678
- if(style) {
1679
- if(typeof style === 'function') {
1685
+
1686
+ if(style) {
1687
+ let styleValue = style;
1688
+ if(typeof styleValue === 'function') {
1680
1689
  try {
1681
- style = style.call(this);
1690
+ styleValue = styleValue.call(this);
1682
1691
  }
1683
1692
  catch(e) {
1684
1693
  console.warn(e);
1685
1694
  return;
1686
1695
  }
1687
1696
  }
1688
- let t = typeof style;
1689
- let mpname = this.jmStyleMap[mpkey || name];
1697
+ let t = typeof styleValue;
1698
+ let mpname = jmStyleMap[mpkey || name];
1690
1699
 
1691
1700
  //如果为渐变对象
1692
- if((style instanceof jmGradient) || (t == 'string' && style.indexOf('-gradient') > -1)) {
1701
+ if((styleValue instanceof jmGradient) || (t == 'string' && styleValue.indexOf('-gradient') > -1)) {
1693
1702
  //如果是渐变,则需要转换
1694
- if(t == 'string' && style.indexOf('-gradient') > -1) {
1695
- style = new jmGradient(style);
1696
- }
1697
- __setStyle(style.toGradient(this), mpname||name);
1698
- }
1699
- else if(t == 'function') {
1700
- if(mpname) {
1701
- style = style.call(this, mpname);
1702
- if(style) {
1703
- __setStyle(style, mpname);
1704
- }
1703
+ if(t == 'string' && styleValue.indexOf('-gradient') > -1) {
1704
+ styleValue = new jmGradient(styleValue);
1705
1705
  }
1706
+ __setStyle(styleValue.toGradient(this), mpname||name);
1706
1707
  }
1707
1708
  else if(mpname) {
1708
1709
  //只有存在白名单中才处理
1709
1710
  //颜色转换
1710
1711
  if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
1711
- style = jmUtils.toColor(style);
1712
+ styleValue = jmUtils.toColor(styleValue);
1712
1713
  }
1713
-
1714
- // 按比例需要放大的样式
1715
- /*if(scale && style) {
1716
- switch(mpname) {
1717
- case 'lineWidth': {
1718
- style *= scale;
1719
- break;
1720
- }
1721
- // 字体放大
1722
- case 'fontSize':
1723
- case 'font': {
1724
- const ms = style.toString().match(/[\d\.]+/);
1725
- if(ms && ms.length) {
1726
- const size = Number(ms[0]) * scale;
1727
- style = style.toString().replace(ms[0], size);
1728
- }
1729
- break;
1730
- }
1731
- }
1732
- } */
1733
- this.context[mpname] = style;
1714
+ this.context[mpname] = styleValue;
1734
1715
  }
1735
1716
  else {
1736
1717
  switch(name) {
1737
1718
  //阴影样式
1738
1719
  case 'shadow' : {
1739
1720
  if(t == 'string') {
1740
- __setStyle(new jmShadow(style), name);
1721
+ __setStyle(new jmShadow(styleValue), name);
1741
1722
  break;
1742
1723
  }
1743
- for(let k in style) {
1744
- __setStyle(style[k], k, name + '.' + k);
1724
+ for(let k in styleValue) {
1725
+ __setStyle(styleValue[k], k, name + '.' + k);
1745
1726
  }
1746
1727
  break;
1747
1728
  }
1748
1729
  //平移
1749
1730
  case 'translate' : {
1750
- this.context.translate(style.x,style.y);
1731
+ this.context.translate(styleValue.x, styleValue.y);
1751
1732
  break;
1752
1733
  }
1753
1734
  //旋转
1754
1735
  case 'rotation' : {
1755
- if(!style.angle) break;
1736
+ if(!styleValue.angle) break;
1756
1737
  //旋 转先移位偏移量
1757
1738
  let tranX = 0;
1758
1739
  let tranY = 0;
1759
1740
  //旋转,则移位,如果有中心位则按中心旋转,否则按左上角旋转
1760
1741
  //这里只有style中的旋转才能生效,不然会导至子控件多次旋转
1761
- if(style.point) {
1742
+ if(styleValue.point) {
1762
1743
  let bounds = this.absoluteBounds?this.absoluteBounds:this.getAbsoluteBounds();
1763
- style = this.getRotation(style);
1744
+ styleValue = this.getRotation(styleValue);
1764
1745
 
1765
- tranX = style.rotateX + bounds.left;
1766
- tranY = style.rotateY + bounds.top;
1746
+ tranX = styleValue.rotateX + bounds.left;
1747
+ tranY = styleValue.rotateY + bounds.top;
1767
1748
  }
1768
1749
 
1769
1750
  if(tranX!=0 || tranY != 0) this.context.translate(tranX,tranY);
1770
- this.context.rotate(style.angle);
1751
+ this.context.rotate(styleValue.angle);
1771
1752
  if(tranX!=0 || tranY != 0) this.context.translate(-tranX,-tranY);
1772
1753
  break;
1773
1754
  }
1774
1755
  case 'transform' : {
1775
- if(Array.isArray(style)) {
1776
- this.context.transform.apply(this.context, style);
1756
+ if(Array.isArray(styleValue)) {
1757
+ this.context.transform.apply(this.context, styleValue);
1777
1758
  }
1778
- else if(typeof style == 'object') {
1779
- this.context.transform(style.scaleX,//水平缩放
1780
- style.skewX,//水平倾斜
1781
- style.skewY,//垂直倾斜
1782
- style.scaleY,//垂直缩放
1783
- style.offsetX,//水平位移
1784
- style.offsetY);//垂直位移
1759
+ else if(typeof styleValue == 'object') {
1760
+ this.context.transform(styleValue.scaleX,//水平缩放
1761
+ styleValue.skewX,//水平倾斜
1762
+ styleValue.skewY,//垂直倾斜
1763
+ styleValue.scaleY,//垂直缩放
1764
+ styleValue.offsetX,//水平位移
1765
+ styleValue.offsetY);//垂直位移
1785
1766
  }
1786
1767
  break;
1787
1768
  }
1788
1769
  //鼠标指针
1789
1770
  case 'cursor' : {
1790
- this.cursor = style;
1771
+ this.cursor = styleValue;
1791
1772
  break;
1792
1773
  }
1793
1774
  }
@@ -2216,8 +2197,6 @@ class jmControl extends jmProperty {
2216
2197
  this.emit('endDraw',this);
2217
2198
  this.context.restore();
2218
2199
 
2219
- //兼容小程序
2220
- if(this.is('jmGraph') && this.context.draw) this.context.draw();
2221
2200
  this.needUpdate = false;
2222
2201
  }
2223
2202
  }
@@ -5102,12 +5081,12 @@ class jmGraph$1 extends jmControl {
5102
5081
  // 触发刷新事件
5103
5082
  self.emit('update');
5104
5083
 
5105
- self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5106
- self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5084
+ self.__requestAnimationFrameFunHandler && self.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5085
+ self.__requestAnimationFrameFunHandler = self.requestAnimationFrame(update);
5107
5086
  if(callback) callback();
5108
5087
  }
5109
- self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5110
- self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5088
+ self.__requestAnimationFrameFunHandler && this.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5089
+ self.__requestAnimationFrameFunHandler = this.requestAnimationFrame(update);
5111
5090
  return this;
5112
5091
  }
5113
5092
 
@@ -6814,7 +6793,7 @@ class jmBarSeries extends jmSeries {
6814
6793
  } else {
6815
6794
  this.___animateCounter++; // next tick 再次刷新
6816
6795
 
6817
- setTimeout(() => {
6796
+ this.graph.utils.requestAnimationFrame(() => {
6818
6797
  this.needUpdate = true; //需要刷新
6819
6798
  });
6820
6799
  }
@@ -6966,7 +6945,7 @@ class jmStackBarSeries extends jmBarSeries {
6966
6945
  } else {
6967
6946
  this.___animateCounter++; // next tick 再次刷新
6968
6947
 
6969
- setTimeout(() => {
6948
+ this.graph.utils.requestAnimationFrame(() => {
6970
6949
  this.needUpdate = true; //需要刷新
6971
6950
  });
6972
6951
  }
@@ -7082,7 +7061,7 @@ class jmPieSeries extends jmSeries {
7082
7061
  } else {
7083
7062
  this.___animateCounter++; // next tick 再次刷新
7084
7063
 
7085
- setTimeout(() => {
7064
+ this.graph.utils.requestAnimationFrame(() => {
7086
7065
  this.needUpdate = true; //需要刷新
7087
7066
  });
7088
7067
  }
@@ -7724,7 +7703,7 @@ class jmLineSeries extends jmSeries {
7724
7703
  } else if (isRunningAni) {
7725
7704
  this.___animateCounter += aniStep; // next tick 再次刷新
7726
7705
 
7727
- setTimeout(() => {
7706
+ this.graph.utils.requestAnimationFrame(() => {
7728
7707
  this.needUpdate = true; //需要刷新
7729
7708
  });
7730
7709
  }
@@ -7971,7 +7950,7 @@ class jmStackLineSeries extends jmLineSeries {
7971
7950
  } else if (isRunningAni) {
7972
7951
  this.___animateCounter += aniStep; // next tick 再次刷新
7973
7952
 
7974
- setTimeout(() => {
7953
+ this.graph.utils.requestAnimationFrame(() => {
7975
7954
  this.needUpdate = true; //需要刷新
7976
7955
  });
7977
7956
  }
@@ -8226,7 +8205,7 @@ class jmMarkLine extends jmLine {
8226
8205
  } // 触发touch数据点改变事件
8227
8206
 
8228
8207
 
8229
- touchChange && setTimeout(() => {
8208
+ touchChange && this.graph.utils.requestAnimationFrame(() => {
8230
8209
  graph.emit('touchPointChange', {
8231
8210
  points: touchPoints
8232
8211
  });
@@ -875,21 +875,13 @@
875
875
  return r;
876
876
  }
877
877
  // window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
878
- static requestAnimationFrame(callback) {
879
- if(typeof requestAnimationFrame === 'undefined') {
880
- return setTimeout(callback, 20);
881
- }
882
- else {
883
- return requestAnimationFrame(callback);
884
- }
878
+ static requestAnimationFrame(callback, win) {
879
+ let fun = win && win.requestAnimationFrame? win.requestAnimationFrame: (typeof window !== 'undefined' && window.requestAnimationFrame? window.requestAnimationFrame: setTimeout);
880
+ return fun(callback, 20);
885
881
  }
886
- static cancelAnimationFrame(handler) {
887
- if(typeof requestAnimationFrame === 'undefined') {
888
- return clearTimeout(handler);
889
- }
890
- else {
891
- return cancelAnimationFrame(handler);
892
- }
882
+ static cancelAnimationFrame(handler, win) {
883
+ let fun = win && win.cancelAnimationFrame? win.cancelAnimationFrame: (typeof window !== 'undefined' && window.cancelAnimationFrame? window.cancelAnimationFrame: clearTimeout);
884
+ return fun(handler);
893
885
  }
894
886
  }
895
887
 
@@ -1328,8 +1320,48 @@
1328
1320
  set graph(v) {
1329
1321
  return this.__pro('graph', v);
1330
1322
  }
1323
+
1324
+ /**
1325
+ * 在下次进行重绘时执行
1326
+ * @param {Function} handler
1327
+ */
1328
+ requestAnimationFrame(handler) {
1329
+ return jmUtils.requestAnimationFrame(handler, this.graph? this.graph.canvas: null);
1330
+ }
1331
+ /**
1332
+ * 清除执行回调
1333
+ * @param {Function} handler
1334
+ * @returns
1335
+ */
1336
+ cancelAnimationFrame(handler) {
1337
+ return jmUtils.cancelAnimationFrame(handler, this.graph? this.graph.canvas: null);
1338
+ }
1331
1339
  }
1332
1340
 
1341
+ //样式名称,也当做白名单使用
1342
+ const jmStyleMap = {
1343
+ 'fill':'fillStyle',
1344
+ 'stroke':'strokeStyle',
1345
+ 'shadow.blur':'shadowBlur',
1346
+ 'shadow.x':'shadowOffsetX',
1347
+ 'shadow.y':'shadowOffsetY',
1348
+ 'shadow.color':'shadowColor',
1349
+ 'lineWidth' : 'lineWidth',
1350
+ 'miterLimit': 'miterLimit',
1351
+ 'fillStyle' : 'fillStyle',
1352
+ 'strokeStyle' : 'strokeStyle',
1353
+ 'font' : 'font',
1354
+ 'opacity' : 'globalAlpha',
1355
+ 'textAlign' : 'textAlign',
1356
+ 'textBaseline' : 'textBaseline',
1357
+ 'shadowBlur' : 'shadowBlur',
1358
+ 'shadowOffsetX' : 'shadowOffsetX',
1359
+ 'shadowOffsetY' : 'shadowOffsetY',
1360
+ 'shadowColor' : 'shadowColor',
1361
+ 'lineJoin': 'lineJoin',//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
1362
+ 'lineCap':'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
1363
+ };
1364
+
1333
1365
  /**
1334
1366
  * 控件基础对象
1335
1367
  * 控件的基础属性和方法
@@ -1356,30 +1388,6 @@
1356
1388
  this.zIndex = params.zIndex || 0;
1357
1389
  this.interactive = typeof params.interactive == 'undefined'? true : params.interactive;
1358
1390
 
1359
- //样式名称,也当做白名单使用
1360
- this.jmStyleMap = {
1361
- 'fill':'fillStyle',
1362
- 'stroke':'strokeStyle',
1363
- 'shadow.blur':'shadowBlur',
1364
- 'shadow.x':'shadowOffsetX',
1365
- 'shadow.y':'shadowOffsetY',
1366
- 'shadow.color':'shadowColor',
1367
- 'lineWidth' : 'lineWidth',
1368
- 'miterLimit': 'miterLimit',
1369
- 'fillStyle' : 'fillStyle',
1370
- 'strokeStyle' : 'strokeStyle',
1371
- 'font' : 'font',
1372
- 'opacity' : 'globalAlpha',
1373
- 'textAlign' : 'textAlign',
1374
- 'textBaseline' : 'textBaseline',
1375
- 'shadowBlur' : 'shadowBlur',
1376
- 'shadowOffsetX' : 'shadowOffsetX',
1377
- 'shadowOffsetY' : 'shadowOffsetY',
1378
- 'shadowColor' : 'shadowColor',
1379
- 'lineJoin': 'lineJoin',//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
1380
- 'lineCap':'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
1381
- };
1382
-
1383
1391
  this.initializing();
1384
1392
 
1385
1393
  this.on = this.bind;
@@ -1677,120 +1685,93 @@
1677
1685
  * @param {string} mpkey 样式名称在映射中的key(例如:shadow.blur为模糊值)
1678
1686
  */
1679
1687
  let __setStyle = (style, name, mpkey) => {
1680
- //let styleValue = style[mpkey||name]||style;
1681
- if(style) {
1682
- if(typeof style === 'function') {
1688
+
1689
+ if(style) {
1690
+ let styleValue = style;
1691
+ if(typeof styleValue === 'function') {
1683
1692
  try {
1684
- style = style.call(this);
1693
+ styleValue = styleValue.call(this);
1685
1694
  }
1686
1695
  catch(e) {
1687
1696
  console.warn(e);
1688
1697
  return;
1689
1698
  }
1690
1699
  }
1691
- let t = typeof style;
1692
- let mpname = this.jmStyleMap[mpkey || name];
1700
+ let t = typeof styleValue;
1701
+ let mpname = jmStyleMap[mpkey || name];
1693
1702
 
1694
1703
  //如果为渐变对象
1695
- if((style instanceof jmGradient) || (t == 'string' && style.indexOf('-gradient') > -1)) {
1704
+ if((styleValue instanceof jmGradient) || (t == 'string' && styleValue.indexOf('-gradient') > -1)) {
1696
1705
  //如果是渐变,则需要转换
1697
- if(t == 'string' && style.indexOf('-gradient') > -1) {
1698
- style = new jmGradient(style);
1699
- }
1700
- __setStyle(style.toGradient(this), mpname||name);
1701
- }
1702
- else if(t == 'function') {
1703
- if(mpname) {
1704
- style = style.call(this, mpname);
1705
- if(style) {
1706
- __setStyle(style, mpname);
1707
- }
1706
+ if(t == 'string' && styleValue.indexOf('-gradient') > -1) {
1707
+ styleValue = new jmGradient(styleValue);
1708
1708
  }
1709
+ __setStyle(styleValue.toGradient(this), mpname||name);
1709
1710
  }
1710
1711
  else if(mpname) {
1711
1712
  //只有存在白名单中才处理
1712
1713
  //颜色转换
1713
1714
  if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
1714
- style = jmUtils.toColor(style);
1715
+ styleValue = jmUtils.toColor(styleValue);
1715
1716
  }
1716
-
1717
- // 按比例需要放大的样式
1718
- /*if(scale && style) {
1719
- switch(mpname) {
1720
- case 'lineWidth': {
1721
- style *= scale;
1722
- break;
1723
- }
1724
- // 字体放大
1725
- case 'fontSize':
1726
- case 'font': {
1727
- const ms = style.toString().match(/[\d\.]+/);
1728
- if(ms && ms.length) {
1729
- const size = Number(ms[0]) * scale;
1730
- style = style.toString().replace(ms[0], size);
1731
- }
1732
- break;
1733
- }
1734
- }
1735
- } */
1736
- this.context[mpname] = style;
1717
+ this.context[mpname] = styleValue;
1737
1718
  }
1738
1719
  else {
1739
1720
  switch(name) {
1740
1721
  //阴影样式
1741
1722
  case 'shadow' : {
1742
1723
  if(t == 'string') {
1743
- __setStyle(new jmShadow(style), name);
1724
+ __setStyle(new jmShadow(styleValue), name);
1744
1725
  break;
1745
1726
  }
1746
- for(let k in style) {
1747
- __setStyle(style[k], k, name + '.' + k);
1727
+ for(let k in styleValue) {
1728
+ __setStyle(styleValue[k], k, name + '.' + k);
1748
1729
  }
1749
1730
  break;
1750
1731
  }
1751
1732
  //平移
1752
1733
  case 'translate' : {
1753
- this.context.translate(style.x,style.y);
1734
+ this.context.translate(styleValue.x, styleValue.y);
1754
1735
  break;
1755
1736
  }
1756
1737
  //旋转
1757
1738
  case 'rotation' : {
1758
- if(!style.angle) break;
1739
+ if(!styleValue.angle) break;
1759
1740
  //旋 转先移位偏移量
1760
1741
  let tranX = 0;
1761
1742
  let tranY = 0;
1762
1743
  //旋转,则移位,如果有中心位则按中心旋转,否则按左上角旋转
1763
1744
  //这里只有style中的旋转才能生效,不然会导至子控件多次旋转
1764
- if(style.point) {
1745
+ if(styleValue.point) {
1765
1746
  let bounds = this.absoluteBounds?this.absoluteBounds:this.getAbsoluteBounds();
1766
- style = this.getRotation(style);
1747
+ styleValue = this.getRotation(styleValue);
1767
1748
 
1768
- tranX = style.rotateX + bounds.left;
1769
- tranY = style.rotateY + bounds.top;
1749
+ tranX = styleValue.rotateX + bounds.left;
1750
+ tranY = styleValue.rotateY + bounds.top;
1770
1751
  }
1771
1752
 
1772
1753
  if(tranX!=0 || tranY != 0) this.context.translate(tranX,tranY);
1773
- this.context.rotate(style.angle);
1754
+ this.context.rotate(styleValue.angle);
1774
1755
  if(tranX!=0 || tranY != 0) this.context.translate(-tranX,-tranY);
1775
1756
  break;
1776
1757
  }
1777
1758
  case 'transform' : {
1778
- if(Array.isArray(style)) {
1779
- this.context.transform.apply(this.context, style);
1759
+ if(Array.isArray(styleValue)) {
1760
+ this.context.transform.apply(this.context, styleValue);
1780
1761
  }
1781
- else if(typeof style == 'object') {
1782
- this.context.transform(style.scaleX,//水平缩放
1783
- style.skewX,//水平倾斜
1784
- style.skewY,//垂直倾斜
1785
- style.scaleY,//垂直缩放
1786
- style.offsetX,//水平位移
1787
- style.offsetY);//垂直位移
1762
+ else if(typeof styleValue == 'object') {
1763
+ this.context.transform(styleValue.scaleX,//水平缩放
1764
+ styleValue.skewX,//水平倾斜
1765
+ styleValue.skewY,//垂直倾斜
1766
+ styleValue.scaleY,//垂直缩放
1767
+ styleValue.offsetX,//水平位移
1768
+ styleValue.offsetY);//垂直位移
1788
1769
  }
1789
1770
  break;
1790
1771
  }
1791
1772
  //鼠标指针
1792
1773
  case 'cursor' : {
1793
- this.cursor = style;
1774
+ this.cursor = styleValue;
1794
1775
  break;
1795
1776
  }
1796
1777
  }
@@ -2219,8 +2200,6 @@
2219
2200
  this.emit('endDraw',this);
2220
2201
  this.context.restore();
2221
2202
 
2222
- //兼容小程序
2223
- if(this.is('jmGraph') && this.context.draw) this.context.draw();
2224
2203
  this.needUpdate = false;
2225
2204
  }
2226
2205
  }
@@ -5105,12 +5084,12 @@
5105
5084
  // 触发刷新事件
5106
5085
  self.emit('update');
5107
5086
 
5108
- self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5109
- self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5087
+ self.__requestAnimationFrameFunHandler && self.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5088
+ self.__requestAnimationFrameFunHandler = self.requestAnimationFrame(update);
5110
5089
  if(callback) callback();
5111
5090
  }
5112
- self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5113
- self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
5091
+ self.__requestAnimationFrameFunHandler && this.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
5092
+ self.__requestAnimationFrameFunHandler = this.requestAnimationFrame(update);
5114
5093
  return this;
5115
5094
  }
5116
5095
 
@@ -6817,7 +6796,7 @@
6817
6796
  } else {
6818
6797
  this.___animateCounter++; // next tick 再次刷新
6819
6798
 
6820
- setTimeout(() => {
6799
+ this.graph.utils.requestAnimationFrame(() => {
6821
6800
  this.needUpdate = true; //需要刷新
6822
6801
  });
6823
6802
  }
@@ -6969,7 +6948,7 @@
6969
6948
  } else {
6970
6949
  this.___animateCounter++; // next tick 再次刷新
6971
6950
 
6972
- setTimeout(() => {
6951
+ this.graph.utils.requestAnimationFrame(() => {
6973
6952
  this.needUpdate = true; //需要刷新
6974
6953
  });
6975
6954
  }
@@ -7085,7 +7064,7 @@
7085
7064
  } else {
7086
7065
  this.___animateCounter++; // next tick 再次刷新
7087
7066
 
7088
- setTimeout(() => {
7067
+ this.graph.utils.requestAnimationFrame(() => {
7089
7068
  this.needUpdate = true; //需要刷新
7090
7069
  });
7091
7070
  }
@@ -7727,7 +7706,7 @@
7727
7706
  } else if (isRunningAni) {
7728
7707
  this.___animateCounter += aniStep; // next tick 再次刷新
7729
7708
 
7730
- setTimeout(() => {
7709
+ this.graph.utils.requestAnimationFrame(() => {
7731
7710
  this.needUpdate = true; //需要刷新
7732
7711
  });
7733
7712
  }
@@ -7974,7 +7953,7 @@
7974
7953
  } else if (isRunningAni) {
7975
7954
  this.___animateCounter += aniStep; // next tick 再次刷新
7976
7955
 
7977
- setTimeout(() => {
7956
+ this.graph.utils.requestAnimationFrame(() => {
7978
7957
  this.needUpdate = true; //需要刷新
7979
7958
  });
7980
7959
  }
@@ -8229,7 +8208,7 @@
8229
8208
  } // 触发touch数据点改变事件
8230
8209
 
8231
8210
 
8232
- touchChange && setTimeout(() => {
8211
+ touchChange && this.graph.utils.requestAnimationFrame(() => {
8233
8212
  graph.emit('touchPointChange', {
8234
8213
  points: touchPoints
8235
8214
  });