jmchart 1.1.99 → 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 +64 -75
- package/dist/jmchart.cjs.js +64 -75
- package/dist/jmchart.esm.js +64 -75
- package/dist/jmchart.iife.js +64 -75
- package/dist/jmchart.system.js +64 -75
- 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.system.js
CHANGED
|
@@ -1668,9 +1668,6 @@ System.register([], function (exports) {
|
|
|
1668
1668
|
style = style || jmUtils.clone(this.style, true);
|
|
1669
1669
|
if(!style) return;
|
|
1670
1670
|
|
|
1671
|
-
// 当前根据屏幕放大倍数,如果有倍数,则需要对线宽等同比放大
|
|
1672
|
-
let scale = this.graph.devicePixelRatio;
|
|
1673
|
-
|
|
1674
1671
|
/**
|
|
1675
1672
|
* 样式设定
|
|
1676
1673
|
*
|
|
@@ -1720,7 +1717,7 @@ System.register([], function (exports) {
|
|
|
1720
1717
|
}
|
|
1721
1718
|
|
|
1722
1719
|
// 按比例需要放大的样式
|
|
1723
|
-
if(scale && style) {
|
|
1720
|
+
/*if(scale && style) {
|
|
1724
1721
|
switch(mpname) {
|
|
1725
1722
|
case 'lineWidth': {
|
|
1726
1723
|
style *= scale;
|
|
@@ -1737,7 +1734,7 @@ System.register([], function (exports) {
|
|
|
1737
1734
|
break;
|
|
1738
1735
|
}
|
|
1739
1736
|
}
|
|
1740
|
-
}
|
|
1737
|
+
} */
|
|
1741
1738
|
this.context[mpname] = style;
|
|
1742
1739
|
}
|
|
1743
1740
|
else {
|
|
@@ -1919,10 +1916,10 @@ System.register([], function (exports) {
|
|
|
1919
1916
|
local.height = this.height;
|
|
1920
1917
|
|
|
1921
1918
|
let margin = jmUtils.clone(this.style.margin, {});
|
|
1922
|
-
margin.left = (margin.left || 0)
|
|
1923
|
-
margin.top = (margin.top || 0)
|
|
1924
|
-
margin.right = (margin.right || 0)
|
|
1925
|
-
margin.bottom = (margin.bottom || 0)
|
|
1919
|
+
margin.left = (margin.left || 0);
|
|
1920
|
+
margin.top = (margin.top || 0);
|
|
1921
|
+
margin.right = (margin.right || 0);
|
|
1922
|
+
margin.bottom = (margin.bottom || 0);
|
|
1926
1923
|
|
|
1927
1924
|
//如果没有指定位置,但指定了margin。则位置取margin偏移量
|
|
1928
1925
|
if(local.position) {
|
|
@@ -2441,14 +2438,7 @@ System.register([], function (exports) {
|
|
|
2441
2438
|
|
|
2442
2439
|
const srcElement = args.srcElement || args.target;
|
|
2443
2440
|
|
|
2444
|
-
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2445
|
-
|
|
2446
|
-
// 如果有指定scale高清处理,需要对坐标处理
|
|
2447
|
-
// 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
|
|
2448
|
-
if(graph.devicePixelRatio > 0) {
|
|
2449
|
-
position.x = position.offsetX = position.x * graph.devicePixelRatio;
|
|
2450
|
-
position.y = position.offsetY = position.y * graph.devicePixelRatio;
|
|
2451
|
-
}
|
|
2441
|
+
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
2452
2442
|
|
|
2453
2443
|
args = {
|
|
2454
2444
|
position: position,
|
|
@@ -3761,7 +3751,7 @@ System.register([], function (exports) {
|
|
|
3761
3751
|
try {
|
|
3762
3752
|
|
|
3763
3753
|
let img = this.getImage();
|
|
3764
|
-
if(this.graph.isWXMiniApp && this.graph.canvas) {
|
|
3754
|
+
if(this.graph.isWXMiniApp && this.graph.canvas && typeof img === 'string') {
|
|
3765
3755
|
// 图片对象
|
|
3766
3756
|
const image = this.graph.canvas.createImage();
|
|
3767
3757
|
// 图片加载完成回调
|
|
@@ -3783,6 +3773,10 @@ System.register([], function (exports) {
|
|
|
3783
3773
|
|
|
3784
3774
|
// 绘制
|
|
3785
3775
|
drawImg(img) {
|
|
3776
|
+
if(!img) {
|
|
3777
|
+
console.warn('image is empty');
|
|
3778
|
+
return;
|
|
3779
|
+
}
|
|
3786
3780
|
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3787
3781
|
if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
|
|
3788
3782
|
let p = this.getLocation();
|
|
@@ -4720,11 +4714,19 @@ System.register([], function (exports) {
|
|
|
4720
4714
|
this.on('endDraw', function() {
|
|
4721
4715
|
this.context.translate(-0.5, -0.5);
|
|
4722
4716
|
});
|
|
4723
|
-
|
|
4717
|
+
|
|
4718
|
+
// devicePixelRatio初始化
|
|
4719
|
+
let dpr = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4720
|
+
if(this.isWXMiniApp) {
|
|
4721
|
+
dpr = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4722
|
+
}
|
|
4723
|
+
this.devicePixelRatio = dpr;
|
|
4724
|
+
// 为了解决锯齿问题,先放大canvas再缩放
|
|
4725
|
+
this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
|
|
4726
|
+
|
|
4724
4727
|
if(this.option.width > 0) this.width = this.option.width;
|
|
4725
4728
|
if(this.option.height > 0) this.height = this.option.height;
|
|
4726
|
-
|
|
4727
|
-
this.resize();
|
|
4729
|
+
this.resize();
|
|
4728
4730
|
|
|
4729
4731
|
//绑定事件
|
|
4730
4732
|
this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
|
|
@@ -4739,25 +4741,19 @@ System.register([], function (exports) {
|
|
|
4739
4741
|
|
|
4740
4742
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4741
4743
|
resize(w, h) {
|
|
4744
|
+
if(!this.canvas) return;
|
|
4742
4745
|
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4746
|
-
}
|
|
4747
|
-
else if (scale > 1) {
|
|
4748
|
-
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4749
|
-
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4746
|
+
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4747
|
+
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4750
4748
|
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
this.devicePixelRatio = scale;
|
|
4760
|
-
}
|
|
4749
|
+
if(w) this.__normalSize.width = w;
|
|
4750
|
+
if(h) this.__normalSize.height = h;
|
|
4751
|
+
|
|
4752
|
+
this.css('width', w + "px");
|
|
4753
|
+
this.css('height', h + "px");
|
|
4754
|
+
this.canvas.height = h * this.dprScaleSize;
|
|
4755
|
+
this.canvas.width = w * this.dprScaleSize;
|
|
4756
|
+
this.context.scale(this.dprScaleSize, this.dprScaleSize);
|
|
4761
4757
|
}
|
|
4762
4758
|
|
|
4763
4759
|
/**
|
|
@@ -4765,10 +4761,10 @@ System.register([], function (exports) {
|
|
|
4765
4761
|
* @param {x, y} point 内部坐标
|
|
4766
4762
|
*/
|
|
4767
4763
|
pointToPixes(point) {
|
|
4768
|
-
if(this.
|
|
4764
|
+
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
4769
4765
|
point = Object.assign({}, point, {
|
|
4770
|
-
x: point.x / this.
|
|
4771
|
-
y: point.y / this.
|
|
4766
|
+
x: point.x / this.dprScaleSize,
|
|
4767
|
+
y: point.y / this.dprScaleSize
|
|
4772
4768
|
});
|
|
4773
4769
|
}
|
|
4774
4770
|
return point;
|
|
@@ -4780,13 +4776,13 @@ System.register([], function (exports) {
|
|
|
4780
4776
|
* @type {number}
|
|
4781
4777
|
*/
|
|
4782
4778
|
get width() {
|
|
4779
|
+
if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
|
|
4783
4780
|
if(this.canvas) return this.canvas.width;
|
|
4784
4781
|
return 0;
|
|
4785
4782
|
}
|
|
4786
4783
|
set width(v) {
|
|
4787
4784
|
this.needUpdate = true;
|
|
4788
4785
|
if(this.canvas) {
|
|
4789
|
-
this.canvas.width = v;
|
|
4790
4786
|
this.resize(v);
|
|
4791
4787
|
}
|
|
4792
4788
|
return v;
|
|
@@ -4798,13 +4794,13 @@ System.register([], function (exports) {
|
|
|
4798
4794
|
* @type {number}
|
|
4799
4795
|
*/
|
|
4800
4796
|
get height() {
|
|
4797
|
+
if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
|
|
4801
4798
|
if(this.canvas) return this.canvas.height;
|
|
4802
4799
|
return 0;
|
|
4803
4800
|
}
|
|
4804
4801
|
set height(v) {
|
|
4805
4802
|
this.needUpdate = true;
|
|
4806
4803
|
if(this.canvas) {
|
|
4807
|
-
this.canvas.height = v;
|
|
4808
4804
|
this.resize(0, v);
|
|
4809
4805
|
}
|
|
4810
4806
|
return v;
|
|
@@ -4963,23 +4959,13 @@ System.register([], function (exports) {
|
|
|
4963
4959
|
* @param {number} [h] 清除画布的高度
|
|
4964
4960
|
*/
|
|
4965
4961
|
clear(w, h) {
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
this.
|
|
4970
|
-
this.canvas.height = h;
|
|
4971
|
-
//保留原有缩放比例
|
|
4972
|
-
if(this.scaleSize) {
|
|
4973
|
-
if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
|
|
4974
|
-
}
|
|
4975
|
-
}
|
|
4976
|
-
else {
|
|
4977
|
-
w = this.canvas.width;
|
|
4978
|
-
h = this.canvas.height;
|
|
4979
|
-
if(this.scaleSize) {
|
|
4962
|
+
if(!w || !h) {
|
|
4963
|
+
w = this.width;
|
|
4964
|
+
h = this.height;
|
|
4965
|
+
/*if(this.scaleSize) {
|
|
4980
4966
|
w = w / this.scaleSize.x;
|
|
4981
4967
|
h = h / this.scaleSize.y;
|
|
4982
|
-
}
|
|
4968
|
+
}*/
|
|
4983
4969
|
}
|
|
4984
4970
|
//如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
|
|
4985
4971
|
if(this.style && this.style.fill) {
|
|
@@ -5124,6 +5110,9 @@ System.register([], function (exports) {
|
|
|
5124
5110
|
return;// 已销毁
|
|
5125
5111
|
}
|
|
5126
5112
|
if(self.needUpdate) self.redraw();
|
|
5113
|
+
// 触发刷新事件
|
|
5114
|
+
self.emit('update');
|
|
5115
|
+
|
|
5127
5116
|
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5128
5117
|
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5129
5118
|
if(callback) callback();
|
|
@@ -5726,7 +5715,7 @@ System.register([], function (exports) {
|
|
|
5726
5715
|
//字符串轴。则显示每个标签
|
|
5727
5716
|
|
|
5728
5717
|
const format = this.option.format || this.format;
|
|
5729
|
-
const top =
|
|
5718
|
+
const top = this.style.xLabel.margin.top || 0;
|
|
5730
5719
|
|
|
5731
5720
|
for (let i = 0; i < this.data.length; i++) {
|
|
5732
5721
|
const d = this.data[i];
|
|
@@ -5822,8 +5811,8 @@ System.register([], function (exports) {
|
|
|
5822
5811
|
const mm = max - min;
|
|
5823
5812
|
let pervalue = mm / count || 1;
|
|
5824
5813
|
const format = this.option.format || this.format;
|
|
5825
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
5826
|
-
const marginRight = this.style.yLabel.margin.right
|
|
5814
|
+
const marginLeft = this.style.yLabel.margin.left || 0;
|
|
5815
|
+
const marginRight = this.style.yLabel.margin.right || 0;
|
|
5827
5816
|
let p = 0;
|
|
5828
5817
|
|
|
5829
5818
|
for (let i = 0; i < count + 1; i++) {
|
|
@@ -6251,13 +6240,13 @@ System.register([], function (exports) {
|
|
|
6251
6240
|
|
|
6252
6241
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6253
6242
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
6254
|
-
panel.position.x = this.width + 15
|
|
6243
|
+
panel.position.x = this.width + 15;
|
|
6255
6244
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
6256
6245
|
|
|
6257
6246
|
this.height = Math.max(panel.height, this.height);
|
|
6258
6247
|
} else {
|
|
6259
6248
|
//右边和左边图例竖排
|
|
6260
|
-
panel.position.y += this.height + 5
|
|
6249
|
+
panel.position.y += this.height + 5;
|
|
6261
6250
|
this.height = panel.position.y + panel.height;
|
|
6262
6251
|
this.width = Math.max(panel.width, this.width);
|
|
6263
6252
|
}
|
|
@@ -6297,21 +6286,21 @@ System.register([], function (exports) {
|
|
|
6297
6286
|
{
|
|
6298
6287
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
|
|
6299
6288
|
|
|
6300
|
-
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right
|
|
6289
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
6301
6290
|
break;
|
|
6302
6291
|
}
|
|
6303
6292
|
|
|
6304
6293
|
case 'top':
|
|
6305
6294
|
{
|
|
6306
6295
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6307
|
-
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom
|
|
6296
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
6308
6297
|
break;
|
|
6309
6298
|
}
|
|
6310
6299
|
|
|
6311
6300
|
case 'bottom':
|
|
6312
6301
|
{
|
|
6313
6302
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6314
|
-
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top
|
|
6303
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
6315
6304
|
break;
|
|
6316
6305
|
}
|
|
6317
6306
|
|
|
@@ -6319,7 +6308,7 @@ System.register([], function (exports) {
|
|
|
6319
6308
|
default:
|
|
6320
6309
|
{
|
|
6321
6310
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
6322
|
-
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left
|
|
6311
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
6323
6312
|
break;
|
|
6324
6313
|
}
|
|
6325
6314
|
}
|
|
@@ -7066,7 +7055,7 @@ System.register([], function (exports) {
|
|
|
7066
7055
|
x: this.graph.chartArea.width / 2,
|
|
7067
7056
|
y: this.graph.chartArea.height / 2
|
|
7068
7057
|
};
|
|
7069
|
-
const radius = Math.min(center.x - this.style.margin.left
|
|
7058
|
+
const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right, center.y - this.style.margin.top - this.style.margin.bottom); //生成描点位
|
|
7070
7059
|
// super.init会把参数透传给 createPoints
|
|
7071
7060
|
|
|
7072
7061
|
const {
|
|
@@ -7432,7 +7421,7 @@ System.register([], function (exports) {
|
|
|
7432
7421
|
x: this.graph.chartArea.width / 2,
|
|
7433
7422
|
y: this.graph.chartArea.height / 2
|
|
7434
7423
|
};
|
|
7435
|
-
this.radius = Math.min(this.center.x - this.style.margin.left
|
|
7424
|
+
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);
|
|
7436
7425
|
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7437
7426
|
// 计算最大最小值
|
|
7438
7427
|
// 当前需要先更新axis的边界值,轴好画图
|
|
@@ -8226,7 +8215,7 @@ System.register([], function (exports) {
|
|
|
8226
8215
|
if (!p || typeof p.y === 'undefined') continue;
|
|
8227
8216
|
this.markArc = graph.createShape('circle', {
|
|
8228
8217
|
style: this.style,
|
|
8229
|
-
radius:
|
|
8218
|
+
radius: this.style.radius || 5
|
|
8230
8219
|
});
|
|
8231
8220
|
this.markArc.center.y = p.y;
|
|
8232
8221
|
this.children.add(this.markArc);
|
|
@@ -8655,7 +8644,7 @@ System.register([], function (exports) {
|
|
|
8655
8644
|
this.touchGraph.chartGraph = this;
|
|
8656
8645
|
this.on('propertyChange', (name, args) => {
|
|
8657
8646
|
if (['width', 'height'].includes(name)) {
|
|
8658
|
-
this.touchGraph[name] = args.newValue
|
|
8647
|
+
this.touchGraph[name] = args.newValue;
|
|
8659
8648
|
}
|
|
8660
8649
|
}); // 把上层canvse事件传递给绘图层对象
|
|
8661
8650
|
|
|
@@ -8795,10 +8784,10 @@ System.register([], function (exports) {
|
|
|
8795
8784
|
|
|
8796
8785
|
|
|
8797
8786
|
resetAreaPosition() {
|
|
8798
|
-
this.chartArea.position.x =
|
|
8799
|
-
this.chartArea.position.y =
|
|
8800
|
-
const w = this.width - this.style.margin.right
|
|
8801
|
-
const h = this.height - this.style.margin.bottom
|
|
8787
|
+
this.chartArea.position.x = this.style.margin.left || 0;
|
|
8788
|
+
this.chartArea.position.y = this.style.margin.top || 0;
|
|
8789
|
+
const w = this.width - this.style.margin.right - this.chartArea.position.x;
|
|
8790
|
+
const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
|
|
8802
8791
|
this.chartArea.width = w;
|
|
8803
8792
|
this.chartArea.height = h;
|
|
8804
8793
|
}
|
package/example/line.html
CHANGED
|
@@ -238,10 +238,10 @@
|
|
|
238
238
|
|
|
239
239
|
// 创建点的标注
|
|
240
240
|
function addPointMarkLabel(point) {
|
|
241
|
-
const w = 40
|
|
242
|
-
const h = 20
|
|
243
|
-
const bottom = 20
|
|
244
|
-
const arrowOffset = 10
|
|
241
|
+
const w = 40;
|
|
242
|
+
const h = 20;
|
|
243
|
+
const bottom = 20;
|
|
244
|
+
const arrowOffset = 10;
|
|
245
245
|
|
|
246
246
|
// 标注图形左上角
|
|
247
247
|
const p1 = {
|
package/example/vue.html
CHANGED
|
@@ -59,8 +59,6 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
<script type="module">
|
|
61
61
|
import { vChart } from '../dist/jmchart.esm.js';
|
|
62
|
-
//window.devicePixelRatio=1;
|
|
63
|
-
//if(!window.devicePixelRatio || window.devicePixelRatio<2) window.devicePixelRatio = 2; // pc状态下默认指定为2
|
|
64
62
|
|
|
65
63
|
const options = {
|
|
66
64
|
//width: 800, // 可以这里指定,也可以VUE属性指定
|
package/example/wk/line.html
CHANGED
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
|
|
239
239
|
function addPointMark(point, serie, options) {
|
|
240
240
|
const mark = serie.graph.createShape('circle', {
|
|
241
|
-
radius: 6
|
|
241
|
+
radius: 6,
|
|
242
242
|
style: {
|
|
243
243
|
fill: 'red',
|
|
244
244
|
zIndex: 18,
|
|
@@ -250,11 +250,11 @@
|
|
|
250
250
|
}
|
|
251
251
|
// 创建点的标注
|
|
252
252
|
function addPointMarkLabel(point, serie, options = {index:0}) {
|
|
253
|
-
const w = 40
|
|
254
|
-
const h = 20
|
|
255
|
-
const arrowOffset = 10
|
|
253
|
+
const w = 40;
|
|
254
|
+
const h = 20;
|
|
255
|
+
const arrowOffset = 10;
|
|
256
256
|
|
|
257
|
-
const bottom = 20
|
|
257
|
+
const bottom = 20 + (h + arrowOffset) * options.index;
|
|
258
258
|
|
|
259
259
|
// 标注图形左上角
|
|
260
260
|
const p1 = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jmchart",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "chart",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"directories": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/jiamao/jmchart#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"jmgraph": "^3.1.
|
|
31
|
+
"jmgraph": "^3.1.96"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/core": "^7.10.2",
|
package/server.js
CHANGED
package/src/core/axis/axis.js
CHANGED
|
@@ -269,7 +269,7 @@ export default class jmAxis extends jmArrowLine {
|
|
|
269
269
|
//var count = this.style.xLabel.count || this.data.length;
|
|
270
270
|
//字符串轴。则显示每个标签
|
|
271
271
|
const format = this.option.format || this.format;
|
|
272
|
-
const top = (this.style.xLabel.margin.top || 0)
|
|
272
|
+
const top = (this.style.xLabel.margin.top || 0);
|
|
273
273
|
for(let i=0; i< this.data.length;i++) {
|
|
274
274
|
const d = this.data[i];
|
|
275
275
|
const v = d[this.field];
|
|
@@ -372,8 +372,8 @@ export default class jmAxis extends jmArrowLine {
|
|
|
372
372
|
let pervalue = (mm / count) || 1;
|
|
373
373
|
|
|
374
374
|
const format = this.option.format || this.format;
|
|
375
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
376
|
-
const marginRight = this.style.yLabel.margin.right
|
|
375
|
+
const marginLeft = this.style.yLabel.margin.left || 0;
|
|
376
|
+
const marginRight = this.style.yLabel.margin.right || 0;
|
|
377
377
|
let p = 0;
|
|
378
378
|
|
|
379
379
|
for(let i=0; i<count+1; i++) {
|
|
@@ -79,13 +79,13 @@ jmLegend.prototype.append = function(series, shape, options = {}) {
|
|
|
79
79
|
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
80
80
|
if(legendPosition == 'top' || legendPosition == 'bottom') {
|
|
81
81
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
82
|
-
panel.position.x = this.width + 15
|
|
82
|
+
panel.position.x = this.width + 15;
|
|
83
83
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
84
84
|
this.height = Math.max(panel.height, this.height);
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
87
|
//右边和左边图例竖排
|
|
88
|
-
panel.position.y += this.height + 5
|
|
88
|
+
panel.position.y += this.height + 5;
|
|
89
89
|
this.height = panel.position.y + panel.height;
|
|
90
90
|
this.width = Math.max(panel.width, this.width);
|
|
91
91
|
}
|
|
@@ -122,23 +122,23 @@ jmLegend.prototype.reset = function() {
|
|
|
122
122
|
case 'left': {
|
|
123
123
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
124
124
|
//画图区域向右偏移
|
|
125
|
-
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right
|
|
125
|
+
this.graph.chartArea.position.x = this.position.x + this.width + this.style.margin.right;
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
case 'top': {
|
|
129
129
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
130
|
-
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom
|
|
130
|
+
this.graph.chartArea.position.y = this.position.y + this.height + this.style.margin.bottom;
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
case 'bottom': {
|
|
134
134
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
135
|
-
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top
|
|
135
|
+
this.position.y = this.graph.chartArea.position.y + this.graph.chartArea.height + this.style.margin.top;
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
138
|
case 'right':
|
|
139
139
|
default: {
|
|
140
140
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
141
|
-
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left
|
|
141
|
+
this.position.x = this.graph.chartArea.position.x + this.graph.chartArea.width + this.style.margin.left;
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -73,7 +73,7 @@ export default class jmMarkLine extends jmLine {
|
|
|
73
73
|
if(!p || typeof p.y === 'undefined') continue;
|
|
74
74
|
this.markArc = graph.createShape('circle', {
|
|
75
75
|
style: this.style,
|
|
76
|
-
radius: (this.style.radius || 5)
|
|
76
|
+
radius: (this.style.radius || 5)
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
this.markArc.center.y = p.y;
|
package/src/jmChart.js
CHANGED
|
@@ -158,7 +158,7 @@ export default class jmChart extends jmGraph {
|
|
|
158
158
|
|
|
159
159
|
this.on('propertyChange', (name, args) => {
|
|
160
160
|
if(['width', 'height'].includes(name)) {
|
|
161
|
-
this.touchGraph[name] = args.newValue
|
|
161
|
+
this.touchGraph[name] = args.newValue;
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
// 把上层canvse事件传递给绘图层对象
|
|
@@ -290,10 +290,10 @@ export default class jmChart extends jmGraph {
|
|
|
290
290
|
* @method resetAreaPosition
|
|
291
291
|
*/
|
|
292
292
|
resetAreaPosition() {
|
|
293
|
-
this.chartArea.position.x = (this.style.margin.left || 0)
|
|
294
|
-
this.chartArea.position.y = (this.style.margin.top || 0)
|
|
295
|
-
const w = this.width -
|
|
296
|
-
const h = this.height -
|
|
293
|
+
this.chartArea.position.x = (this.style.margin.left || 0);
|
|
294
|
+
this.chartArea.position.y = (this.style.margin.top || 0);
|
|
295
|
+
const w = this.width - this.style.margin.right - this.chartArea.position.x;
|
|
296
|
+
const h = this.height - this.style.margin.bottom - this.chartArea.position.y;
|
|
297
297
|
|
|
298
298
|
this.chartArea.width = w;
|
|
299
299
|
this.chartArea.height = h;
|
package/src/series/pieSeries.js
CHANGED
|
@@ -43,9 +43,9 @@ export default class jmPieSeries extends jmSeries {
|
|
|
43
43
|
y: this.graph.chartArea.height / 2
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const radius = Math.min(center.x - this.style.margin.left
|
|
47
|
-
this.style.margin.right
|
|
48
|
-
center.y - this.style.margin.top
|
|
46
|
+
const radius = Math.min(center.x - this.style.margin.left -
|
|
47
|
+
this.style.margin.right,
|
|
48
|
+
center.y - this.style.margin.top - this.style.margin.bottom);
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
//生成描点位
|
|
@@ -86,9 +86,9 @@ export default class jmRadarSeries extends jmSeries {
|
|
|
86
86
|
y: this.graph.chartArea.height / 2
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
this.radius = Math.min(this.center.x - this.style.margin.left
|
|
90
|
-
this.style.margin.right
|
|
91
|
-
this.center.y - this.style.margin.top
|
|
89
|
+
this.radius = Math.min(this.center.x - this.style.margin.left -
|
|
90
|
+
this.style.margin.right,
|
|
91
|
+
this.center.y - this.style.margin.top - this.style.margin.bottom);
|
|
92
92
|
|
|
93
93
|
const axises = this.createAxises(this.center, this.radius);// 重置所有轴
|
|
94
94
|
// 计算最大最小值
|