jmchart 1.2.0 → 1.2.1
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 +59 -74
- package/dist/jmchart.cjs.js +59 -74
- package/dist/jmchart.esm.js +59 -74
- package/dist/jmchart.iife.js +59 -74
- package/dist/jmchart.system.js +59 -74
- 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/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.amd.js
CHANGED
|
@@ -1665,9 +1665,6 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
1665
1665
|
style = style || jmUtils.clone(this.style, true);
|
|
1666
1666
|
if(!style) return;
|
|
1667
1667
|
|
|
1668
|
-
// 当前根据屏幕放大倍数,如果有倍数,则需要对线宽等同比放大
|
|
1669
|
-
let scale = this.graph.devicePixelRatio;
|
|
1670
|
-
|
|
1671
1668
|
/**
|
|
1672
1669
|
* 样式设定
|
|
1673
1670
|
*
|
|
@@ -1717,7 +1714,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
1717
1714
|
}
|
|
1718
1715
|
|
|
1719
1716
|
// 按比例需要放大的样式
|
|
1720
|
-
if(scale && style) {
|
|
1717
|
+
/*if(scale && style) {
|
|
1721
1718
|
switch(mpname) {
|
|
1722
1719
|
case 'lineWidth': {
|
|
1723
1720
|
style *= scale;
|
|
@@ -1734,7 +1731,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
1734
1731
|
break;
|
|
1735
1732
|
}
|
|
1736
1733
|
}
|
|
1737
|
-
}
|
|
1734
|
+
} */
|
|
1738
1735
|
this.context[mpname] = style;
|
|
1739
1736
|
}
|
|
1740
1737
|
else {
|
|
@@ -1916,10 +1913,10 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
1916
1913
|
local.height = this.height;
|
|
1917
1914
|
|
|
1918
1915
|
let margin = jmUtils.clone(this.style.margin, {});
|
|
1919
|
-
margin.left = (margin.left || 0)
|
|
1920
|
-
margin.top = (margin.top || 0)
|
|
1921
|
-
margin.right = (margin.right || 0)
|
|
1922
|
-
margin.bottom = (margin.bottom || 0)
|
|
1916
|
+
margin.left = (margin.left || 0);
|
|
1917
|
+
margin.top = (margin.top || 0);
|
|
1918
|
+
margin.right = (margin.right || 0);
|
|
1919
|
+
margin.bottom = (margin.bottom || 0);
|
|
1923
1920
|
|
|
1924
1921
|
//如果没有指定位置,但指定了margin。则位置取margin偏移量
|
|
1925
1922
|
if(local.position) {
|
|
@@ -2438,14 +2435,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
2438
2435
|
|
|
2439
2436
|
const srcElement = args.srcElement || args.target;
|
|
2440
2437
|
|
|
2441
|
-
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2442
|
-
|
|
2443
|
-
// 如果有指定scale高清处理,需要对坐标处理
|
|
2444
|
-
// 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
|
|
2445
|
-
if(graph.devicePixelRatio > 0) {
|
|
2446
|
-
position.x = position.offsetX = position.x * graph.devicePixelRatio;
|
|
2447
|
-
position.y = position.offsetY = position.y * graph.devicePixelRatio;
|
|
2448
|
-
}
|
|
2438
|
+
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2449
2439
|
|
|
2450
2440
|
args = {
|
|
2451
2441
|
position: position,
|
|
@@ -4721,11 +4711,19 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4721
4711
|
this.on('endDraw', function() {
|
|
4722
4712
|
this.context.translate(-0.5, -0.5);
|
|
4723
4713
|
});
|
|
4724
|
-
|
|
4714
|
+
|
|
4715
|
+
// devicePixelRatio初始化
|
|
4716
|
+
let dpr = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4717
|
+
if(this.isWXMiniApp) {
|
|
4718
|
+
dpr = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4719
|
+
}
|
|
4720
|
+
this.devicePixelRatio = dpr;
|
|
4721
|
+
// 为了解决锯齿问题,先放大canvas再缩放
|
|
4722
|
+
this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
|
|
4723
|
+
|
|
4725
4724
|
if(this.option.width > 0) this.width = this.option.width;
|
|
4726
4725
|
if(this.option.height > 0) this.height = this.option.height;
|
|
4727
|
-
|
|
4728
|
-
this.resize();
|
|
4726
|
+
this.resize();
|
|
4729
4727
|
|
|
4730
4728
|
//绑定事件
|
|
4731
4729
|
this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
|
|
@@ -4740,25 +4738,19 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4740
4738
|
|
|
4741
4739
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4742
4740
|
resize(w, h) {
|
|
4741
|
+
if(!this.canvas) return;
|
|
4743
4742
|
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4747
|
-
}
|
|
4748
|
-
else if (scale > 1) {
|
|
4749
|
-
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4750
|
-
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4743
|
+
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4744
|
+
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4751
4745
|
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
this.devicePixelRatio = scale;
|
|
4761
|
-
}
|
|
4746
|
+
if(w) this.__normalSize.width = w;
|
|
4747
|
+
if(h) this.__normalSize.height = h;
|
|
4748
|
+
|
|
4749
|
+
this.css('width', w + "px");
|
|
4750
|
+
this.css('height', h + "px");
|
|
4751
|
+
this.canvas.height = h * this.dprScaleSize;
|
|
4752
|
+
this.canvas.width = w * this.dprScaleSize;
|
|
4753
|
+
this.context.scale(this.dprScaleSize, this.dprScaleSize);
|
|
4762
4754
|
}
|
|
4763
4755
|
|
|
4764
4756
|
/**
|
|
@@ -4766,10 +4758,10 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4766
4758
|
* @param {x, y} point 内部坐标
|
|
4767
4759
|
*/
|
|
4768
4760
|
pointToPixes(point) {
|
|
4769
|
-
if(this.
|
|
4761
|
+
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
4770
4762
|
point = Object.assign({}, point, {
|
|
4771
|
-
x: point.x / this.
|
|
4772
|
-
y: point.y / this.
|
|
4763
|
+
x: point.x / this.dprScaleSize,
|
|
4764
|
+
y: point.y / this.dprScaleSize
|
|
4773
4765
|
});
|
|
4774
4766
|
}
|
|
4775
4767
|
return point;
|
|
@@ -4781,13 +4773,13 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4781
4773
|
* @type {number}
|
|
4782
4774
|
*/
|
|
4783
4775
|
get width() {
|
|
4776
|
+
if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
|
|
4784
4777
|
if(this.canvas) return this.canvas.width;
|
|
4785
4778
|
return 0;
|
|
4786
4779
|
}
|
|
4787
4780
|
set width(v) {
|
|
4788
4781
|
this.needUpdate = true;
|
|
4789
4782
|
if(this.canvas) {
|
|
4790
|
-
this.canvas.width = v;
|
|
4791
4783
|
this.resize(v);
|
|
4792
4784
|
}
|
|
4793
4785
|
return v;
|
|
@@ -4799,13 +4791,13 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4799
4791
|
* @type {number}
|
|
4800
4792
|
*/
|
|
4801
4793
|
get height() {
|
|
4794
|
+
if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
|
|
4802
4795
|
if(this.canvas) return this.canvas.height;
|
|
4803
4796
|
return 0;
|
|
4804
4797
|
}
|
|
4805
4798
|
set height(v) {
|
|
4806
4799
|
this.needUpdate = true;
|
|
4807
4800
|
if(this.canvas) {
|
|
4808
|
-
this.canvas.height = v;
|
|
4809
4801
|
this.resize(0, v);
|
|
4810
4802
|
}
|
|
4811
4803
|
return v;
|
|
@@ -4964,23 +4956,13 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
4964
4956
|
* @param {number} [h] 清除画布的高度
|
|
4965
4957
|
*/
|
|
4966
4958
|
clear(w, h) {
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
this.
|
|
4971
|
-
this.canvas.height = h;
|
|
4972
|
-
//保留原有缩放比例
|
|
4973
|
-
if(this.scaleSize) {
|
|
4974
|
-
if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
|
|
4975
|
-
}
|
|
4976
|
-
}
|
|
4977
|
-
else {
|
|
4978
|
-
w = this.canvas.width;
|
|
4979
|
-
h = this.canvas.height;
|
|
4980
|
-
if(this.scaleSize) {
|
|
4959
|
+
if(!w || !h) {
|
|
4960
|
+
w = this.width;
|
|
4961
|
+
h = this.height;
|
|
4962
|
+
/*if(this.scaleSize) {
|
|
4981
4963
|
w = w / this.scaleSize.x;
|
|
4982
4964
|
h = h / this.scaleSize.y;
|
|
4983
|
-
}
|
|
4965
|
+
}*/
|
|
4984
4966
|
}
|
|
4985
4967
|
//如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
|
|
4986
4968
|
if(this.style && this.style.fill) {
|
|
@@ -5125,6 +5107,9 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5125
5107
|
return;// 已销毁
|
|
5126
5108
|
}
|
|
5127
5109
|
if(self.needUpdate) self.redraw();
|
|
5110
|
+
// 触发刷新事件
|
|
5111
|
+
self.emit('update');
|
|
5112
|
+
|
|
5128
5113
|
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5129
5114
|
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5130
5115
|
if(callback) callback();
|
|
@@ -5727,7 +5712,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5727
5712
|
//字符串轴。则显示每个标签
|
|
5728
5713
|
|
|
5729
5714
|
const format = this.option.format || this.format;
|
|
5730
|
-
const top =
|
|
5715
|
+
const top = this.style.xLabel.margin.top || 0;
|
|
5731
5716
|
|
|
5732
5717
|
for (let i = 0; i < this.data.length; i++) {
|
|
5733
5718
|
const d = this.data[i];
|
|
@@ -5823,8 +5808,8 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5823
5808
|
const mm = max - min;
|
|
5824
5809
|
let pervalue = mm / count || 1;
|
|
5825
5810
|
const format = this.option.format || this.format;
|
|
5826
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
5827
|
-
const marginRight = this.style.yLabel.margin.right
|
|
5811
|
+
const marginLeft = this.style.yLabel.margin.left || 0;
|
|
5812
|
+
const marginRight = this.style.yLabel.margin.right || 0;
|
|
5828
5813
|
let p = 0;
|
|
5829
5814
|
|
|
5830
5815
|
for (let i = 0; i < count + 1; i++) {
|
|
@@ -6252,13 +6237,13 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6252
6237
|
|
|
6253
6238
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6254
6239
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
6255
|
-
panel.position.x = this.width + 15
|
|
6240
|
+
panel.position.x = this.width + 15;
|
|
6256
6241
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
6257
6242
|
|
|
6258
6243
|
this.height = Math.max(panel.height, this.height);
|
|
6259
6244
|
} else {
|
|
6260
6245
|
//右边和左边图例竖排
|
|
6261
|
-
panel.position.y += this.height + 5
|
|
6246
|
+
panel.position.y += this.height + 5;
|
|
6262
6247
|
this.height = panel.position.y + panel.height;
|
|
6263
6248
|
this.width = Math.max(panel.width, this.width);
|
|
6264
6249
|
}
|
|
@@ -6298,21 +6283,21 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6298
6283
|
{
|
|
6299
6284
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
|
|
6300
6285
|
|
|
6301
|
-
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right
|
|
6286
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
6302
6287
|
break;
|
|
6303
6288
|
}
|
|
6304
6289
|
|
|
6305
6290
|
case 'top':
|
|
6306
6291
|
{
|
|
6307
6292
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6308
|
-
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom
|
|
6293
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
6309
6294
|
break;
|
|
6310
6295
|
}
|
|
6311
6296
|
|
|
6312
6297
|
case 'bottom':
|
|
6313
6298
|
{
|
|
6314
6299
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6315
|
-
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top
|
|
6300
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
6316
6301
|
break;
|
|
6317
6302
|
}
|
|
6318
6303
|
|
|
@@ -6320,7 +6305,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6320
6305
|
default:
|
|
6321
6306
|
{
|
|
6322
6307
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
6323
|
-
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left
|
|
6308
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
6324
6309
|
break;
|
|
6325
6310
|
}
|
|
6326
6311
|
}
|
|
@@ -7067,7 +7052,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7067
7052
|
x: this.graph.chartArea.width / 2,
|
|
7068
7053
|
y: this.graph.chartArea.height / 2
|
|
7069
7054
|
};
|
|
7070
|
-
const radius = Math.min(center.x - this.style.margin.left
|
|
7055
|
+
const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right, center.y - this.style.margin.top - this.style.margin.bottom); //生成描点位
|
|
7071
7056
|
// super.init会把参数透传给 createPoints
|
|
7072
7057
|
|
|
7073
7058
|
const {
|
|
@@ -7433,7 +7418,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7433
7418
|
x: this.graph.chartArea.width / 2,
|
|
7434
7419
|
y: this.graph.chartArea.height / 2
|
|
7435
7420
|
};
|
|
7436
|
-
this.radius = Math.min(this.center.x - this.style.margin.left
|
|
7421
|
+
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);
|
|
7437
7422
|
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7438
7423
|
// 计算最大最小值
|
|
7439
7424
|
// 当前需要先更新axis的边界值,轴好画图
|
|
@@ -8227,7 +8212,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8227
8212
|
if (!p || typeof p.y === 'undefined') continue;
|
|
8228
8213
|
this.markArc = graph.createShape('circle', {
|
|
8229
8214
|
style: this.style,
|
|
8230
|
-
radius:
|
|
8215
|
+
radius: this.style.radius || 5
|
|
8231
8216
|
});
|
|
8232
8217
|
this.markArc.center.y = p.y;
|
|
8233
8218
|
this.children.add(this.markArc);
|
|
@@ -8656,7 +8641,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8656
8641
|
this.touchGraph.chartGraph = this;
|
|
8657
8642
|
this.on('propertyChange', (name, args) => {
|
|
8658
8643
|
if (['width', 'height'].includes(name)) {
|
|
8659
|
-
this.touchGraph[name] = args.newValue
|
|
8644
|
+
this.touchGraph[name] = args.newValue;
|
|
8660
8645
|
}
|
|
8661
8646
|
}); // 把上层canvse事件传递给绘图层对象
|
|
8662
8647
|
|
|
@@ -8796,10 +8781,10 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8796
8781
|
|
|
8797
8782
|
|
|
8798
8783
|
resetAreaPosition() {
|
|
8799
|
-
this.chartArea.position.x =
|
|
8800
|
-
this.chartArea.position.y =
|
|
8801
|
-
const w = this.width - this.style.margin.right
|
|
8802
|
-
const h = this.height - this.style.margin.bottom
|
|
8784
|
+
this.chartArea.position.x = this.style.margin.left || 0;
|
|
8785
|
+
this.chartArea.position.y = this.style.margin.top || 0;
|
|
8786
|
+
const w = this.width - this.style.margin.right - this.chartArea.position.x;
|
|
8787
|
+
const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
|
|
8803
8788
|
this.chartArea.width = w;
|
|
8804
8789
|
this.chartArea.height = h;
|
|
8805
8790
|
}
|
package/dist/jmchart.cjs.js
CHANGED
|
@@ -1667,9 +1667,6 @@ class jmControl extends jmProperty {
|
|
|
1667
1667
|
style = style || jmUtils.clone(this.style, true);
|
|
1668
1668
|
if(!style) return;
|
|
1669
1669
|
|
|
1670
|
-
// 当前根据屏幕放大倍数,如果有倍数,则需要对线宽等同比放大
|
|
1671
|
-
let scale = this.graph.devicePixelRatio;
|
|
1672
|
-
|
|
1673
1670
|
/**
|
|
1674
1671
|
* 样式设定
|
|
1675
1672
|
*
|
|
@@ -1719,7 +1716,7 @@ class jmControl extends jmProperty {
|
|
|
1719
1716
|
}
|
|
1720
1717
|
|
|
1721
1718
|
// 按比例需要放大的样式
|
|
1722
|
-
if(scale && style) {
|
|
1719
|
+
/*if(scale && style) {
|
|
1723
1720
|
switch(mpname) {
|
|
1724
1721
|
case 'lineWidth': {
|
|
1725
1722
|
style *= scale;
|
|
@@ -1736,7 +1733,7 @@ class jmControl extends jmProperty {
|
|
|
1736
1733
|
break;
|
|
1737
1734
|
}
|
|
1738
1735
|
}
|
|
1739
|
-
}
|
|
1736
|
+
} */
|
|
1740
1737
|
this.context[mpname] = style;
|
|
1741
1738
|
}
|
|
1742
1739
|
else {
|
|
@@ -1918,10 +1915,10 @@ class jmControl extends jmProperty {
|
|
|
1918
1915
|
local.height = this.height;
|
|
1919
1916
|
|
|
1920
1917
|
let margin = jmUtils.clone(this.style.margin, {});
|
|
1921
|
-
margin.left = (margin.left || 0)
|
|
1922
|
-
margin.top = (margin.top || 0)
|
|
1923
|
-
margin.right = (margin.right || 0)
|
|
1924
|
-
margin.bottom = (margin.bottom || 0)
|
|
1918
|
+
margin.left = (margin.left || 0);
|
|
1919
|
+
margin.top = (margin.top || 0);
|
|
1920
|
+
margin.right = (margin.right || 0);
|
|
1921
|
+
margin.bottom = (margin.bottom || 0);
|
|
1925
1922
|
|
|
1926
1923
|
//如果没有指定位置,但指定了margin。则位置取margin偏移量
|
|
1927
1924
|
if(local.position) {
|
|
@@ -2440,14 +2437,7 @@ class jmControl extends jmProperty {
|
|
|
2440
2437
|
|
|
2441
2438
|
const srcElement = args.srcElement || args.target;
|
|
2442
2439
|
|
|
2443
|
-
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2444
|
-
|
|
2445
|
-
// 如果有指定scale高清处理,需要对坐标处理
|
|
2446
|
-
// 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
|
|
2447
|
-
if(graph.devicePixelRatio > 0) {
|
|
2448
|
-
position.x = position.offsetX = position.x * graph.devicePixelRatio;
|
|
2449
|
-
position.y = position.offsetY = position.y * graph.devicePixelRatio;
|
|
2450
|
-
}
|
|
2440
|
+
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2451
2441
|
|
|
2452
2442
|
args = {
|
|
2453
2443
|
position: position,
|
|
@@ -4723,11 +4713,19 @@ class jmGraph$1 extends jmControl {
|
|
|
4723
4713
|
this.on('endDraw', function() {
|
|
4724
4714
|
this.context.translate(-0.5, -0.5);
|
|
4725
4715
|
});
|
|
4726
|
-
|
|
4716
|
+
|
|
4717
|
+
// devicePixelRatio初始化
|
|
4718
|
+
let dpr = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4719
|
+
if(this.isWXMiniApp) {
|
|
4720
|
+
dpr = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4721
|
+
}
|
|
4722
|
+
this.devicePixelRatio = dpr;
|
|
4723
|
+
// 为了解决锯齿问题,先放大canvas再缩放
|
|
4724
|
+
this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
|
|
4725
|
+
|
|
4727
4726
|
if(this.option.width > 0) this.width = this.option.width;
|
|
4728
4727
|
if(this.option.height > 0) this.height = this.option.height;
|
|
4729
|
-
|
|
4730
|
-
this.resize();
|
|
4728
|
+
this.resize();
|
|
4731
4729
|
|
|
4732
4730
|
//绑定事件
|
|
4733
4731
|
this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
|
|
@@ -4742,25 +4740,19 @@ class jmGraph$1 extends jmControl {
|
|
|
4742
4740
|
|
|
4743
4741
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4744
4742
|
resize(w, h) {
|
|
4743
|
+
if(!this.canvas) return;
|
|
4745
4744
|
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4749
|
-
}
|
|
4750
|
-
else if (scale > 1) {
|
|
4751
|
-
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4752
|
-
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4745
|
+
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4746
|
+
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4753
4747
|
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
this.devicePixelRatio = scale;
|
|
4763
|
-
}
|
|
4748
|
+
if(w) this.__normalSize.width = w;
|
|
4749
|
+
if(h) this.__normalSize.height = h;
|
|
4750
|
+
|
|
4751
|
+
this.css('width', w + "px");
|
|
4752
|
+
this.css('height', h + "px");
|
|
4753
|
+
this.canvas.height = h * this.dprScaleSize;
|
|
4754
|
+
this.canvas.width = w * this.dprScaleSize;
|
|
4755
|
+
this.context.scale(this.dprScaleSize, this.dprScaleSize);
|
|
4764
4756
|
}
|
|
4765
4757
|
|
|
4766
4758
|
/**
|
|
@@ -4768,10 +4760,10 @@ class jmGraph$1 extends jmControl {
|
|
|
4768
4760
|
* @param {x, y} point 内部坐标
|
|
4769
4761
|
*/
|
|
4770
4762
|
pointToPixes(point) {
|
|
4771
|
-
if(this.
|
|
4763
|
+
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
4772
4764
|
point = Object.assign({}, point, {
|
|
4773
|
-
x: point.x / this.
|
|
4774
|
-
y: point.y / this.
|
|
4765
|
+
x: point.x / this.dprScaleSize,
|
|
4766
|
+
y: point.y / this.dprScaleSize
|
|
4775
4767
|
});
|
|
4776
4768
|
}
|
|
4777
4769
|
return point;
|
|
@@ -4783,13 +4775,13 @@ class jmGraph$1 extends jmControl {
|
|
|
4783
4775
|
* @type {number}
|
|
4784
4776
|
*/
|
|
4785
4777
|
get width() {
|
|
4778
|
+
if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
|
|
4786
4779
|
if(this.canvas) return this.canvas.width;
|
|
4787
4780
|
return 0;
|
|
4788
4781
|
}
|
|
4789
4782
|
set width(v) {
|
|
4790
4783
|
this.needUpdate = true;
|
|
4791
4784
|
if(this.canvas) {
|
|
4792
|
-
this.canvas.width = v;
|
|
4793
4785
|
this.resize(v);
|
|
4794
4786
|
}
|
|
4795
4787
|
return v;
|
|
@@ -4801,13 +4793,13 @@ class jmGraph$1 extends jmControl {
|
|
|
4801
4793
|
* @type {number}
|
|
4802
4794
|
*/
|
|
4803
4795
|
get height() {
|
|
4796
|
+
if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
|
|
4804
4797
|
if(this.canvas) return this.canvas.height;
|
|
4805
4798
|
return 0;
|
|
4806
4799
|
}
|
|
4807
4800
|
set height(v) {
|
|
4808
4801
|
this.needUpdate = true;
|
|
4809
4802
|
if(this.canvas) {
|
|
4810
|
-
this.canvas.height = v;
|
|
4811
4803
|
this.resize(0, v);
|
|
4812
4804
|
}
|
|
4813
4805
|
return v;
|
|
@@ -4966,23 +4958,13 @@ class jmGraph$1 extends jmControl {
|
|
|
4966
4958
|
* @param {number} [h] 清除画布的高度
|
|
4967
4959
|
*/
|
|
4968
4960
|
clear(w, h) {
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
this.
|
|
4973
|
-
this.canvas.height = h;
|
|
4974
|
-
//保留原有缩放比例
|
|
4975
|
-
if(this.scaleSize) {
|
|
4976
|
-
if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
|
|
4977
|
-
}
|
|
4978
|
-
}
|
|
4979
|
-
else {
|
|
4980
|
-
w = this.canvas.width;
|
|
4981
|
-
h = this.canvas.height;
|
|
4982
|
-
if(this.scaleSize) {
|
|
4961
|
+
if(!w || !h) {
|
|
4962
|
+
w = this.width;
|
|
4963
|
+
h = this.height;
|
|
4964
|
+
/*if(this.scaleSize) {
|
|
4983
4965
|
w = w / this.scaleSize.x;
|
|
4984
4966
|
h = h / this.scaleSize.y;
|
|
4985
|
-
}
|
|
4967
|
+
}*/
|
|
4986
4968
|
}
|
|
4987
4969
|
//如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
|
|
4988
4970
|
if(this.style && this.style.fill) {
|
|
@@ -5127,6 +5109,9 @@ class jmGraph$1 extends jmControl {
|
|
|
5127
5109
|
return;// 已销毁
|
|
5128
5110
|
}
|
|
5129
5111
|
if(self.needUpdate) self.redraw();
|
|
5112
|
+
// 触发刷新事件
|
|
5113
|
+
self.emit('update');
|
|
5114
|
+
|
|
5130
5115
|
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5131
5116
|
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5132
5117
|
if(callback) callback();
|
|
@@ -5729,7 +5714,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5729
5714
|
//字符串轴。则显示每个标签
|
|
5730
5715
|
|
|
5731
5716
|
const format = this.option.format || this.format;
|
|
5732
|
-
const top =
|
|
5717
|
+
const top = this.style.xLabel.margin.top || 0;
|
|
5733
5718
|
|
|
5734
5719
|
for (let i = 0; i < this.data.length; i++) {
|
|
5735
5720
|
const d = this.data[i];
|
|
@@ -5825,8 +5810,8 @@ class jmAxis extends jmArrowLine {
|
|
|
5825
5810
|
const mm = max - min;
|
|
5826
5811
|
let pervalue = mm / count || 1;
|
|
5827
5812
|
const format = this.option.format || this.format;
|
|
5828
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
5829
|
-
const marginRight = this.style.yLabel.margin.right
|
|
5813
|
+
const marginLeft = this.style.yLabel.margin.left || 0;
|
|
5814
|
+
const marginRight = this.style.yLabel.margin.right || 0;
|
|
5830
5815
|
let p = 0;
|
|
5831
5816
|
|
|
5832
5817
|
for (let i = 0; i < count + 1; i++) {
|
|
@@ -6254,13 +6239,13 @@ jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
|
6254
6239
|
|
|
6255
6240
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6256
6241
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
6257
|
-
panel.position.x = this.width + 15
|
|
6242
|
+
panel.position.x = this.width + 15;
|
|
6258
6243
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
6259
6244
|
|
|
6260
6245
|
this.height = Math.max(panel.height, this.height);
|
|
6261
6246
|
} else {
|
|
6262
6247
|
//右边和左边图例竖排
|
|
6263
|
-
panel.position.y += this.height + 5
|
|
6248
|
+
panel.position.y += this.height + 5;
|
|
6264
6249
|
this.height = panel.position.y + panel.height;
|
|
6265
6250
|
this.width = Math.max(panel.width, this.width);
|
|
6266
6251
|
}
|
|
@@ -6300,21 +6285,21 @@ jmLegend.prototype.reset = function () {
|
|
|
6300
6285
|
{
|
|
6301
6286
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
|
|
6302
6287
|
|
|
6303
|
-
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right
|
|
6288
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
6304
6289
|
break;
|
|
6305
6290
|
}
|
|
6306
6291
|
|
|
6307
6292
|
case 'top':
|
|
6308
6293
|
{
|
|
6309
6294
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6310
|
-
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom
|
|
6295
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
6311
6296
|
break;
|
|
6312
6297
|
}
|
|
6313
6298
|
|
|
6314
6299
|
case 'bottom':
|
|
6315
6300
|
{
|
|
6316
6301
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6317
|
-
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top
|
|
6302
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
6318
6303
|
break;
|
|
6319
6304
|
}
|
|
6320
6305
|
|
|
@@ -6322,7 +6307,7 @@ jmLegend.prototype.reset = function () {
|
|
|
6322
6307
|
default:
|
|
6323
6308
|
{
|
|
6324
6309
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
6325
|
-
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left
|
|
6310
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
6326
6311
|
break;
|
|
6327
6312
|
}
|
|
6328
6313
|
}
|
|
@@ -7069,7 +7054,7 @@ class jmPieSeries extends jmSeries {
|
|
|
7069
7054
|
x: this.graph.chartArea.width / 2,
|
|
7070
7055
|
y: this.graph.chartArea.height / 2
|
|
7071
7056
|
};
|
|
7072
|
-
const radius = Math.min(center.x - this.style.margin.left
|
|
7057
|
+
const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right, center.y - this.style.margin.top - this.style.margin.bottom); //生成描点位
|
|
7073
7058
|
// super.init会把参数透传给 createPoints
|
|
7074
7059
|
|
|
7075
7060
|
const {
|
|
@@ -7435,7 +7420,7 @@ class jmRadarSeries extends jmSeries {
|
|
|
7435
7420
|
x: this.graph.chartArea.width / 2,
|
|
7436
7421
|
y: this.graph.chartArea.height / 2
|
|
7437
7422
|
};
|
|
7438
|
-
this.radius = Math.min(this.center.x - this.style.margin.left
|
|
7423
|
+
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);
|
|
7439
7424
|
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7440
7425
|
// 计算最大最小值
|
|
7441
7426
|
// 当前需要先更新axis的边界值,轴好画图
|
|
@@ -8229,7 +8214,7 @@ class jmMarkLine extends jmLine {
|
|
|
8229
8214
|
if (!p || typeof p.y === 'undefined') continue;
|
|
8230
8215
|
this.markArc = graph.createShape('circle', {
|
|
8231
8216
|
style: this.style,
|
|
8232
|
-
radius:
|
|
8217
|
+
radius: this.style.radius || 5
|
|
8233
8218
|
});
|
|
8234
8219
|
this.markArc.center.y = p.y;
|
|
8235
8220
|
this.children.add(this.markArc);
|
|
@@ -8658,7 +8643,7 @@ class jmChart extends jmGraph {
|
|
|
8658
8643
|
this.touchGraph.chartGraph = this;
|
|
8659
8644
|
this.on('propertyChange', (name, args) => {
|
|
8660
8645
|
if (['width', 'height'].includes(name)) {
|
|
8661
|
-
this.touchGraph[name] = args.newValue
|
|
8646
|
+
this.touchGraph[name] = args.newValue;
|
|
8662
8647
|
}
|
|
8663
8648
|
}); // 把上层canvse事件传递给绘图层对象
|
|
8664
8649
|
|
|
@@ -8798,10 +8783,10 @@ class jmChart extends jmGraph {
|
|
|
8798
8783
|
|
|
8799
8784
|
|
|
8800
8785
|
resetAreaPosition() {
|
|
8801
|
-
this.chartArea.position.x =
|
|
8802
|
-
this.chartArea.position.y =
|
|
8803
|
-
const w = this.width - this.style.margin.right
|
|
8804
|
-
const h = this.height - this.style.margin.bottom
|
|
8786
|
+
this.chartArea.position.x = this.style.margin.left || 0;
|
|
8787
|
+
this.chartArea.position.y = this.style.margin.top || 0;
|
|
8788
|
+
const w = this.width - this.style.margin.right - this.chartArea.position.x;
|
|
8789
|
+
const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
|
|
8805
8790
|
this.chartArea.width = w;
|
|
8806
8791
|
this.chartArea.height = h;
|
|
8807
8792
|
}
|