jmchart 1.2.1 → 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 +95 -122
- package/dist/jmchart.cjs.js +95 -122
- package/dist/jmchart.esm.js +95 -122
- package/dist/jmchart.iife.js +95 -122
- package/dist/jmchart.system.js +95 -122
- package/package.json +2 -2
- package/src/core/markLine/manager.js +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.iife.js
CHANGED
|
@@ -875,21 +875,13 @@
|
|
|
875
875
|
return r;
|
|
876
876
|
}
|
|
877
877
|
// window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
|
|
878
|
-
static requestAnimationFrame(callback) {
|
|
879
|
-
|
|
880
|
-
|
|
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
|
-
|
|
888
|
-
|
|
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
|
-
|
|
1681
|
-
if(style) {
|
|
1682
|
-
|
|
1688
|
+
|
|
1689
|
+
if(style) {
|
|
1690
|
+
let styleValue = style;
|
|
1691
|
+
if(typeof styleValue === 'function') {
|
|
1683
1692
|
try {
|
|
1684
|
-
|
|
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
|
|
1692
|
-
let mpname =
|
|
1700
|
+
let t = typeof styleValue;
|
|
1701
|
+
let mpname = jmStyleMap[mpkey || name];
|
|
1693
1702
|
|
|
1694
1703
|
//如果为渐变对象
|
|
1695
|
-
if((
|
|
1704
|
+
if((styleValue instanceof jmGradient) || (t == 'string' && styleValue.indexOf('-gradient') > -1)) {
|
|
1696
1705
|
//如果是渐变,则需要转换
|
|
1697
|
-
if(t == 'string' &&
|
|
1698
|
-
|
|
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
|
-
|
|
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(
|
|
1724
|
+
__setStyle(new jmShadow(styleValue), name);
|
|
1744
1725
|
break;
|
|
1745
1726
|
}
|
|
1746
|
-
for(let k in
|
|
1747
|
-
__setStyle(
|
|
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(
|
|
1734
|
+
this.context.translate(styleValue.x, styleValue.y);
|
|
1754
1735
|
break;
|
|
1755
1736
|
}
|
|
1756
1737
|
//旋转
|
|
1757
1738
|
case 'rotation' : {
|
|
1758
|
-
if(!
|
|
1739
|
+
if(!styleValue.angle) break;
|
|
1759
1740
|
//旋 转先移位偏移量
|
|
1760
1741
|
let tranX = 0;
|
|
1761
1742
|
let tranY = 0;
|
|
1762
1743
|
//旋转,则移位,如果有中心位则按中心旋转,否则按左上角旋转
|
|
1763
1744
|
//这里只有style中的旋转才能生效,不然会导至子控件多次旋转
|
|
1764
|
-
if(
|
|
1745
|
+
if(styleValue.point) {
|
|
1765
1746
|
let bounds = this.absoluteBounds?this.absoluteBounds:this.getAbsoluteBounds();
|
|
1766
|
-
|
|
1747
|
+
styleValue = this.getRotation(styleValue);
|
|
1767
1748
|
|
|
1768
|
-
tranX =
|
|
1769
|
-
tranY =
|
|
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(
|
|
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(
|
|
1779
|
-
this.context.transform.apply(this.context,
|
|
1759
|
+
if(Array.isArray(styleValue)) {
|
|
1760
|
+
this.context.transform.apply(this.context, styleValue);
|
|
1780
1761
|
}
|
|
1781
|
-
else if(typeof
|
|
1782
|
-
this.context.transform(
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
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 =
|
|
1774
|
+
this.cursor = styleValue;
|
|
1794
1775
|
break;
|
|
1795
1776
|
}
|
|
1796
1777
|
}
|
|
@@ -1839,9 +1820,6 @@
|
|
|
1839
1820
|
if(typeof this.canvas.width === 'function') {
|
|
1840
1821
|
rect.right = this.canvas.width();
|
|
1841
1822
|
}
|
|
1842
|
-
else if(this.canvas.width) {
|
|
1843
|
-
rect.right = this.canvas.width;
|
|
1844
|
-
}
|
|
1845
1823
|
else if(this.width) {
|
|
1846
1824
|
rect.right = this.width;
|
|
1847
1825
|
}
|
|
@@ -1849,9 +1827,6 @@
|
|
|
1849
1827
|
if(typeof this.canvas.height === 'function') {
|
|
1850
1828
|
rect.bottom = this.canvas.height();
|
|
1851
1829
|
}
|
|
1852
|
-
else if(this.canvas.height) {
|
|
1853
|
-
rect.bottom = this.canvas.height;
|
|
1854
|
-
}
|
|
1855
1830
|
else if(this.height) {
|
|
1856
1831
|
rect.bottom = this.height;
|
|
1857
1832
|
}
|
|
@@ -2225,8 +2200,6 @@
|
|
|
2225
2200
|
this.emit('endDraw',this);
|
|
2226
2201
|
this.context.restore();
|
|
2227
2202
|
|
|
2228
|
-
//兼容小程序
|
|
2229
|
-
if(this.is('jmGraph') && this.context.draw) this.context.draw();
|
|
2230
2203
|
this.needUpdate = false;
|
|
2231
2204
|
}
|
|
2232
2205
|
}
|
|
@@ -2346,8 +2319,8 @@
|
|
|
2346
2319
|
//获取dom位置
|
|
2347
2320
|
let position = this.getPosition();
|
|
2348
2321
|
// 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
|
|
2349
|
-
const right = position.left +
|
|
2350
|
-
const bottom = position.top +
|
|
2322
|
+
const right = position.left + this.width;
|
|
2323
|
+
const bottom = position.top + this.height;
|
|
2351
2324
|
if(p.pageX > right || p.pageX < position.left) {
|
|
2352
2325
|
return false;
|
|
2353
2326
|
}
|
|
@@ -4822,8 +4795,8 @@
|
|
|
4822
4795
|
*/
|
|
4823
4796
|
getPosition() {
|
|
4824
4797
|
let p = jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
|
|
4825
|
-
p.width = this.
|
|
4826
|
-
p.height = this.
|
|
4798
|
+
p.width = this.width;
|
|
4799
|
+
p.height = this.height;
|
|
4827
4800
|
p.right = p.left + p.width;
|
|
4828
4801
|
p.bottom = p.top + p.height;
|
|
4829
4802
|
return p;
|
|
@@ -5111,12 +5084,12 @@
|
|
|
5111
5084
|
// 触发刷新事件
|
|
5112
5085
|
self.emit('update');
|
|
5113
5086
|
|
|
5114
|
-
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5115
|
-
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5087
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler, self.canvas);
|
|
5088
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update, self.canvas);
|
|
5116
5089
|
if(callback) callback();
|
|
5117
5090
|
}
|
|
5118
|
-
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5119
|
-
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5091
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler, self.canvas);
|
|
5092
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update, self.canvas);
|
|
5120
5093
|
return this;
|
|
5121
5094
|
}
|
|
5122
5095
|
|
|
@@ -6823,7 +6796,7 @@
|
|
|
6823
6796
|
} else {
|
|
6824
6797
|
this.___animateCounter++; // next tick 再次刷新
|
|
6825
6798
|
|
|
6826
|
-
|
|
6799
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
6827
6800
|
this.needUpdate = true; //需要刷新
|
|
6828
6801
|
});
|
|
6829
6802
|
}
|
|
@@ -6975,7 +6948,7 @@
|
|
|
6975
6948
|
} else {
|
|
6976
6949
|
this.___animateCounter++; // next tick 再次刷新
|
|
6977
6950
|
|
|
6978
|
-
|
|
6951
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
6979
6952
|
this.needUpdate = true; //需要刷新
|
|
6980
6953
|
});
|
|
6981
6954
|
}
|
|
@@ -7091,7 +7064,7 @@
|
|
|
7091
7064
|
} else {
|
|
7092
7065
|
this.___animateCounter++; // next tick 再次刷新
|
|
7093
7066
|
|
|
7094
|
-
|
|
7067
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7095
7068
|
this.needUpdate = true; //需要刷新
|
|
7096
7069
|
});
|
|
7097
7070
|
}
|
|
@@ -7733,7 +7706,7 @@
|
|
|
7733
7706
|
} else if (isRunningAni) {
|
|
7734
7707
|
this.___animateCounter += aniStep; // next tick 再次刷新
|
|
7735
7708
|
|
|
7736
|
-
|
|
7709
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7737
7710
|
this.needUpdate = true; //需要刷新
|
|
7738
7711
|
});
|
|
7739
7712
|
}
|
|
@@ -7980,7 +7953,7 @@
|
|
|
7980
7953
|
} else if (isRunningAni) {
|
|
7981
7954
|
this.___animateCounter += aniStep; // next tick 再次刷新
|
|
7982
7955
|
|
|
7983
|
-
|
|
7956
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7984
7957
|
this.needUpdate = true; //需要刷新
|
|
7985
7958
|
});
|
|
7986
7959
|
}
|
|
@@ -8235,7 +8208,7 @@
|
|
|
8235
8208
|
} // 触发touch数据点改变事件
|
|
8236
8209
|
|
|
8237
8210
|
|
|
8238
|
-
touchChange &&
|
|
8211
|
+
touchChange && this.graph.utils.requestAnimationFrame(() => {
|
|
8239
8212
|
graph.emit('touchPointChange', {
|
|
8240
8213
|
points: touchPoints
|
|
8241
8214
|
});
|
|
@@ -8427,14 +8400,14 @@
|
|
|
8427
8400
|
else lineTouching = 1;
|
|
8428
8401
|
}
|
|
8429
8402
|
|
|
8430
|
-
args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
|
|
8403
|
+
args.event && args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
|
|
8431
8404
|
|
|
8432
8405
|
if (chart.style.markLine.lock) {
|
|
8433
8406
|
// 标线状态一直禁用系统能力
|
|
8434
8407
|
// 如果指定了锁定值,只需要一项符合要求就进行锁定
|
|
8435
8408
|
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) {
|
|
8436
8409
|
lineTouching = 1;
|
|
8437
|
-
args.event.preventDefault(); // 阻止默认行为
|
|
8410
|
+
args.event && args.event.preventDefault && args.event.preventDefault(); // 阻止默认行为
|
|
8438
8411
|
}
|
|
8439
8412
|
}
|
|
8440
8413
|
|