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