jmchart 1.2.0 → 1.2.2
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 +65 -86
- package/dist/jmchart.cjs.js +65 -86
- package/dist/jmchart.esm.js +65 -86
- package/dist/jmchart.iife.js +65 -86
- package/dist/jmchart.system.js +65 -86
- package/example/line.html +4 -4
- package/example/vue.html +0 -2
- package/example/wk/line.html +5 -5
- package/package.json +2 -2
- package/server.js +1 -1
- package/src/core/axis/axis.js +3 -3
- package/src/core/legend/legend.js +6 -6
- package/src/core/markLine/manager.js +2 -2
- package/src/core/markLine/markLine.js +1 -1
- package/src/jmChart.js +5 -5
- package/src/series/pieSeries.js +3 -3
- package/src/series/radarSeries.js +3 -3
package/dist/jmchart.iife.js
CHANGED
|
@@ -1666,9 +1666,6 @@
|
|
|
1666
1666
|
style = style || jmUtils.clone(this.style, true);
|
|
1667
1667
|
if(!style) return;
|
|
1668
1668
|
|
|
1669
|
-
// 当前根据屏幕放大倍数,如果有倍数,则需要对线宽等同比放大
|
|
1670
|
-
let scale = this.graph.devicePixelRatio;
|
|
1671
|
-
|
|
1672
1669
|
/**
|
|
1673
1670
|
* 样式设定
|
|
1674
1671
|
*
|
|
@@ -1718,7 +1715,7 @@
|
|
|
1718
1715
|
}
|
|
1719
1716
|
|
|
1720
1717
|
// 按比例需要放大的样式
|
|
1721
|
-
if(scale && style) {
|
|
1718
|
+
/*if(scale && style) {
|
|
1722
1719
|
switch(mpname) {
|
|
1723
1720
|
case 'lineWidth': {
|
|
1724
1721
|
style *= scale;
|
|
@@ -1735,7 +1732,7 @@
|
|
|
1735
1732
|
break;
|
|
1736
1733
|
}
|
|
1737
1734
|
}
|
|
1738
|
-
}
|
|
1735
|
+
} */
|
|
1739
1736
|
this.context[mpname] = style;
|
|
1740
1737
|
}
|
|
1741
1738
|
else {
|
|
@@ -1842,9 +1839,6 @@
|
|
|
1842
1839
|
if(typeof this.canvas.width === 'function') {
|
|
1843
1840
|
rect.right = this.canvas.width();
|
|
1844
1841
|
}
|
|
1845
|
-
else if(this.canvas.width) {
|
|
1846
|
-
rect.right = this.canvas.width;
|
|
1847
|
-
}
|
|
1848
1842
|
else if(this.width) {
|
|
1849
1843
|
rect.right = this.width;
|
|
1850
1844
|
}
|
|
@@ -1852,9 +1846,6 @@
|
|
|
1852
1846
|
if(typeof this.canvas.height === 'function') {
|
|
1853
1847
|
rect.bottom = this.canvas.height();
|
|
1854
1848
|
}
|
|
1855
|
-
else if(this.canvas.height) {
|
|
1856
|
-
rect.bottom = this.canvas.height;
|
|
1857
|
-
}
|
|
1858
1849
|
else if(this.height) {
|
|
1859
1850
|
rect.bottom = this.height;
|
|
1860
1851
|
}
|
|
@@ -1917,10 +1908,10 @@
|
|
|
1917
1908
|
local.height = this.height;
|
|
1918
1909
|
|
|
1919
1910
|
let margin = jmUtils.clone(this.style.margin, {});
|
|
1920
|
-
margin.left = (margin.left || 0)
|
|
1921
|
-
margin.top = (margin.top || 0)
|
|
1922
|
-
margin.right = (margin.right || 0)
|
|
1923
|
-
margin.bottom = (margin.bottom || 0)
|
|
1911
|
+
margin.left = (margin.left || 0);
|
|
1912
|
+
margin.top = (margin.top || 0);
|
|
1913
|
+
margin.right = (margin.right || 0);
|
|
1914
|
+
margin.bottom = (margin.bottom || 0);
|
|
1924
1915
|
|
|
1925
1916
|
//如果没有指定位置,但指定了margin。则位置取margin偏移量
|
|
1926
1917
|
if(local.position) {
|
|
@@ -2349,8 +2340,8 @@
|
|
|
2349
2340
|
//获取dom位置
|
|
2350
2341
|
let position = this.getPosition();
|
|
2351
2342
|
// 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
|
|
2352
|
-
const right = position.left +
|
|
2353
|
-
const bottom = position.top +
|
|
2343
|
+
const right = position.left + this.width;
|
|
2344
|
+
const bottom = position.top + this.height;
|
|
2354
2345
|
if(p.pageX > right || p.pageX < position.left) {
|
|
2355
2346
|
return false;
|
|
2356
2347
|
}
|
|
@@ -2439,14 +2430,7 @@
|
|
|
2439
2430
|
|
|
2440
2431
|
const srcElement = args.srcElement || args.target;
|
|
2441
2432
|
|
|
2442
|
-
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2443
|
-
|
|
2444
|
-
// 如果有指定scale高清处理,需要对坐标处理
|
|
2445
|
-
// 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
|
|
2446
|
-
if(graph.devicePixelRatio > 0) {
|
|
2447
|
-
position.x = position.offsetX = position.x * graph.devicePixelRatio;
|
|
2448
|
-
position.y = position.offsetY = position.y * graph.devicePixelRatio;
|
|
2449
|
-
}
|
|
2433
|
+
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2450
2434
|
|
|
2451
2435
|
args = {
|
|
2452
2436
|
position: position,
|
|
@@ -4722,11 +4706,19 @@
|
|
|
4722
4706
|
this.on('endDraw', function() {
|
|
4723
4707
|
this.context.translate(-0.5, -0.5);
|
|
4724
4708
|
});
|
|
4725
|
-
|
|
4709
|
+
|
|
4710
|
+
// devicePixelRatio初始化
|
|
4711
|
+
let dpr = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4712
|
+
if(this.isWXMiniApp) {
|
|
4713
|
+
dpr = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4714
|
+
}
|
|
4715
|
+
this.devicePixelRatio = dpr;
|
|
4716
|
+
// 为了解决锯齿问题,先放大canvas再缩放
|
|
4717
|
+
this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
|
|
4718
|
+
|
|
4726
4719
|
if(this.option.width > 0) this.width = this.option.width;
|
|
4727
4720
|
if(this.option.height > 0) this.height = this.option.height;
|
|
4728
|
-
|
|
4729
|
-
this.resize();
|
|
4721
|
+
this.resize();
|
|
4730
4722
|
|
|
4731
4723
|
//绑定事件
|
|
4732
4724
|
this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
|
|
@@ -4741,25 +4733,19 @@
|
|
|
4741
4733
|
|
|
4742
4734
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4743
4735
|
resize(w, h) {
|
|
4736
|
+
if(!this.canvas) return;
|
|
4744
4737
|
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4748
|
-
}
|
|
4749
|
-
else if (scale > 1) {
|
|
4750
|
-
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4751
|
-
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4738
|
+
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4739
|
+
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4752
4740
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
this.devicePixelRatio = scale;
|
|
4762
|
-
}
|
|
4741
|
+
if(w) this.__normalSize.width = w;
|
|
4742
|
+
if(h) this.__normalSize.height = h;
|
|
4743
|
+
|
|
4744
|
+
this.css('width', w + "px");
|
|
4745
|
+
this.css('height', h + "px");
|
|
4746
|
+
this.canvas.height = h * this.dprScaleSize;
|
|
4747
|
+
this.canvas.width = w * this.dprScaleSize;
|
|
4748
|
+
this.context.scale(this.dprScaleSize, this.dprScaleSize);
|
|
4763
4749
|
}
|
|
4764
4750
|
|
|
4765
4751
|
/**
|
|
@@ -4767,10 +4753,10 @@
|
|
|
4767
4753
|
* @param {x, y} point 内部坐标
|
|
4768
4754
|
*/
|
|
4769
4755
|
pointToPixes(point) {
|
|
4770
|
-
if(this.
|
|
4756
|
+
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
4771
4757
|
point = Object.assign({}, point, {
|
|
4772
|
-
x: point.x / this.
|
|
4773
|
-
y: point.y / this.
|
|
4758
|
+
x: point.x / this.dprScaleSize,
|
|
4759
|
+
y: point.y / this.dprScaleSize
|
|
4774
4760
|
});
|
|
4775
4761
|
}
|
|
4776
4762
|
return point;
|
|
@@ -4782,13 +4768,13 @@
|
|
|
4782
4768
|
* @type {number}
|
|
4783
4769
|
*/
|
|
4784
4770
|
get width() {
|
|
4771
|
+
if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
|
|
4785
4772
|
if(this.canvas) return this.canvas.width;
|
|
4786
4773
|
return 0;
|
|
4787
4774
|
}
|
|
4788
4775
|
set width(v) {
|
|
4789
4776
|
this.needUpdate = true;
|
|
4790
4777
|
if(this.canvas) {
|
|
4791
|
-
this.canvas.width = v;
|
|
4792
4778
|
this.resize(v);
|
|
4793
4779
|
}
|
|
4794
4780
|
return v;
|
|
@@ -4800,13 +4786,13 @@
|
|
|
4800
4786
|
* @type {number}
|
|
4801
4787
|
*/
|
|
4802
4788
|
get height() {
|
|
4789
|
+
if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
|
|
4803
4790
|
if(this.canvas) return this.canvas.height;
|
|
4804
4791
|
return 0;
|
|
4805
4792
|
}
|
|
4806
4793
|
set height(v) {
|
|
4807
4794
|
this.needUpdate = true;
|
|
4808
4795
|
if(this.canvas) {
|
|
4809
|
-
this.canvas.height = v;
|
|
4810
4796
|
this.resize(0, v);
|
|
4811
4797
|
}
|
|
4812
4798
|
return v;
|
|
@@ -4830,8 +4816,8 @@
|
|
|
4830
4816
|
*/
|
|
4831
4817
|
getPosition() {
|
|
4832
4818
|
let p = jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
|
|
4833
|
-
p.width = this.
|
|
4834
|
-
p.height = this.
|
|
4819
|
+
p.width = this.width;
|
|
4820
|
+
p.height = this.height;
|
|
4835
4821
|
p.right = p.left + p.width;
|
|
4836
4822
|
p.bottom = p.top + p.height;
|
|
4837
4823
|
return p;
|
|
@@ -4965,23 +4951,13 @@
|
|
|
4965
4951
|
* @param {number} [h] 清除画布的高度
|
|
4966
4952
|
*/
|
|
4967
4953
|
clear(w, h) {
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
this.
|
|
4972
|
-
this.canvas.height = h;
|
|
4973
|
-
//保留原有缩放比例
|
|
4974
|
-
if(this.scaleSize) {
|
|
4975
|
-
if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
|
|
4976
|
-
}
|
|
4977
|
-
}
|
|
4978
|
-
else {
|
|
4979
|
-
w = this.canvas.width;
|
|
4980
|
-
h = this.canvas.height;
|
|
4981
|
-
if(this.scaleSize) {
|
|
4954
|
+
if(!w || !h) {
|
|
4955
|
+
w = this.width;
|
|
4956
|
+
h = this.height;
|
|
4957
|
+
/*if(this.scaleSize) {
|
|
4982
4958
|
w = w / this.scaleSize.x;
|
|
4983
4959
|
h = h / this.scaleSize.y;
|
|
4984
|
-
}
|
|
4960
|
+
}*/
|
|
4985
4961
|
}
|
|
4986
4962
|
//如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
|
|
4987
4963
|
if(this.style && this.style.fill) {
|
|
@@ -5126,6 +5102,9 @@
|
|
|
5126
5102
|
return;// 已销毁
|
|
5127
5103
|
}
|
|
5128
5104
|
if(self.needUpdate) self.redraw();
|
|
5105
|
+
// 触发刷新事件
|
|
5106
|
+
self.emit('update');
|
|
5107
|
+
|
|
5129
5108
|
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5130
5109
|
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5131
5110
|
if(callback) callback();
|
|
@@ -5728,7 +5707,7 @@
|
|
|
5728
5707
|
//字符串轴。则显示每个标签
|
|
5729
5708
|
|
|
5730
5709
|
const format = this.option.format || this.format;
|
|
5731
|
-
const top =
|
|
5710
|
+
const top = this.style.xLabel.margin.top || 0;
|
|
5732
5711
|
|
|
5733
5712
|
for (let i = 0; i < this.data.length; i++) {
|
|
5734
5713
|
const d = this.data[i];
|
|
@@ -5824,8 +5803,8 @@
|
|
|
5824
5803
|
const mm = max - min;
|
|
5825
5804
|
let pervalue = mm / count || 1;
|
|
5826
5805
|
const format = this.option.format || this.format;
|
|
5827
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
5828
|
-
const marginRight = this.style.yLabel.margin.right
|
|
5806
|
+
const marginLeft = this.style.yLabel.margin.left || 0;
|
|
5807
|
+
const marginRight = this.style.yLabel.margin.right || 0;
|
|
5829
5808
|
let p = 0;
|
|
5830
5809
|
|
|
5831
5810
|
for (let i = 0; i < count + 1; i++) {
|
|
@@ -6253,13 +6232,13 @@
|
|
|
6253
6232
|
|
|
6254
6233
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6255
6234
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
6256
|
-
panel.position.x = this.width + 15
|
|
6235
|
+
panel.position.x = this.width + 15;
|
|
6257
6236
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
6258
6237
|
|
|
6259
6238
|
this.height = Math.max(panel.height, this.height);
|
|
6260
6239
|
} else {
|
|
6261
6240
|
//右边和左边图例竖排
|
|
6262
|
-
panel.position.y += this.height + 5
|
|
6241
|
+
panel.position.y += this.height + 5;
|
|
6263
6242
|
this.height = panel.position.y + panel.height;
|
|
6264
6243
|
this.width = Math.max(panel.width, this.width);
|
|
6265
6244
|
}
|
|
@@ -6299,21 +6278,21 @@
|
|
|
6299
6278
|
{
|
|
6300
6279
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
|
|
6301
6280
|
|
|
6302
|
-
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right
|
|
6281
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
6303
6282
|
break;
|
|
6304
6283
|
}
|
|
6305
6284
|
|
|
6306
6285
|
case 'top':
|
|
6307
6286
|
{
|
|
6308
6287
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6309
|
-
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom
|
|
6288
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
6310
6289
|
break;
|
|
6311
6290
|
}
|
|
6312
6291
|
|
|
6313
6292
|
case 'bottom':
|
|
6314
6293
|
{
|
|
6315
6294
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6316
|
-
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top
|
|
6295
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
6317
6296
|
break;
|
|
6318
6297
|
}
|
|
6319
6298
|
|
|
@@ -6321,7 +6300,7 @@
|
|
|
6321
6300
|
default:
|
|
6322
6301
|
{
|
|
6323
6302
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
6324
|
-
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left
|
|
6303
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
6325
6304
|
break;
|
|
6326
6305
|
}
|
|
6327
6306
|
}
|
|
@@ -7068,7 +7047,7 @@
|
|
|
7068
7047
|
x: this.graph.chartArea.width / 2,
|
|
7069
7048
|
y: this.graph.chartArea.height / 2
|
|
7070
7049
|
};
|
|
7071
|
-
const radius = Math.min(center.x - this.style.margin.left
|
|
7050
|
+
const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right, center.y - this.style.margin.top - this.style.margin.bottom); //生成描点位
|
|
7072
7051
|
// super.init会把参数透传给 createPoints
|
|
7073
7052
|
|
|
7074
7053
|
const {
|
|
@@ -7434,7 +7413,7 @@
|
|
|
7434
7413
|
x: this.graph.chartArea.width / 2,
|
|
7435
7414
|
y: this.graph.chartArea.height / 2
|
|
7436
7415
|
};
|
|
7437
|
-
this.radius = Math.min(this.center.x - this.style.margin.left
|
|
7416
|
+
this.radius = Math.min(this.center.x - this.style.margin.left - this.style.margin.right, this.center.y - this.style.margin.top - this.style.margin.bottom);
|
|
7438
7417
|
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7439
7418
|
// 计算最大最小值
|
|
7440
7419
|
// 当前需要先更新axis的边界值,轴好画图
|
|
@@ -8228,7 +8207,7 @@
|
|
|
8228
8207
|
if (!p || typeof p.y === 'undefined') continue;
|
|
8229
8208
|
this.markArc = graph.createShape('circle', {
|
|
8230
8209
|
style: this.style,
|
|
8231
|
-
radius:
|
|
8210
|
+
radius: this.style.radius || 5
|
|
8232
8211
|
});
|
|
8233
8212
|
this.markArc.center.y = p.y;
|
|
8234
8213
|
this.children.add(this.markArc);
|
|
@@ -8442,14 +8421,14 @@
|
|
|
8442
8421
|
else lineTouching = 1;
|
|
8443
8422
|
}
|
|
8444
8423
|
|
|
8445
|
-
args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
|
|
8424
|
+
args.event && args.event.stopPropagation && args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
|
|
8446
8425
|
|
|
8447
8426
|
if (chart.style.markLine.lock) {
|
|
8448
8427
|
// 标线状态一直禁用系统能力
|
|
8449
8428
|
// 如果指定了锁定值,只需要一项符合要求就进行锁定
|
|
8450
8429
|
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) {
|
|
8451
8430
|
lineTouching = 1;
|
|
8452
|
-
args.event.preventDefault(); // 阻止默认行为
|
|
8431
|
+
args.event && args.event.preventDefault && args.event.preventDefault(); // 阻止默认行为
|
|
8453
8432
|
}
|
|
8454
8433
|
}
|
|
8455
8434
|
|
|
@@ -8657,7 +8636,7 @@
|
|
|
8657
8636
|
this.touchGraph.chartGraph = this;
|
|
8658
8637
|
this.on('propertyChange', (name, args) => {
|
|
8659
8638
|
if (['width', 'height'].includes(name)) {
|
|
8660
|
-
this.touchGraph[name] = args.newValue
|
|
8639
|
+
this.touchGraph[name] = args.newValue;
|
|
8661
8640
|
}
|
|
8662
8641
|
}); // 把上层canvse事件传递给绘图层对象
|
|
8663
8642
|
|
|
@@ -8797,10 +8776,10 @@
|
|
|
8797
8776
|
|
|
8798
8777
|
|
|
8799
8778
|
resetAreaPosition() {
|
|
8800
|
-
this.chartArea.position.x =
|
|
8801
|
-
this.chartArea.position.y =
|
|
8802
|
-
const w = this.width - this.style.margin.right
|
|
8803
|
-
const h = this.height - this.style.margin.bottom
|
|
8779
|
+
this.chartArea.position.x = this.style.margin.left || 0;
|
|
8780
|
+
this.chartArea.position.y = this.style.margin.top || 0;
|
|
8781
|
+
const w = this.width - this.style.margin.right - this.chartArea.position.x;
|
|
8782
|
+
const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
|
|
8804
8783
|
this.chartArea.width = w;
|
|
8805
8784
|
this.chartArea.height = h;
|
|
8806
8785
|
}
|