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.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,
|
|
@@ -4724,11 +4714,19 @@ System.register([], function (exports) {
|
|
|
4724
4714
|
this.on('endDraw', function() {
|
|
4725
4715
|
this.context.translate(-0.5, -0.5);
|
|
4726
4716
|
});
|
|
4727
|
-
|
|
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
|
+
|
|
4728
4727
|
if(this.option.width > 0) this.width = this.option.width;
|
|
4729
4728
|
if(this.option.height > 0) this.height = this.option.height;
|
|
4730
|
-
|
|
4731
|
-
this.resize();
|
|
4729
|
+
this.resize();
|
|
4732
4730
|
|
|
4733
4731
|
//绑定事件
|
|
4734
4732
|
this.eventHandler = new jmEvents(this, this.canvas.canvas || this.canvas);
|
|
@@ -4743,25 +4741,19 @@ System.register([], function (exports) {
|
|
|
4743
4741
|
|
|
4744
4742
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4745
4743
|
resize(w, h) {
|
|
4744
|
+
if(!this.canvas) return;
|
|
4746
4745
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4750
|
-
}
|
|
4751
|
-
else if (scale > 1) {
|
|
4752
|
-
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4753
|
-
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;
|
|
4754
4748
|
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
this.devicePixelRatio = scale;
|
|
4764
|
-
}
|
|
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);
|
|
4765
4757
|
}
|
|
4766
4758
|
|
|
4767
4759
|
/**
|
|
@@ -4769,10 +4761,10 @@ System.register([], function (exports) {
|
|
|
4769
4761
|
* @param {x, y} point 内部坐标
|
|
4770
4762
|
*/
|
|
4771
4763
|
pointToPixes(point) {
|
|
4772
|
-
if(this.
|
|
4764
|
+
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
4773
4765
|
point = Object.assign({}, point, {
|
|
4774
|
-
x: point.x / this.
|
|
4775
|
-
y: point.y / this.
|
|
4766
|
+
x: point.x / this.dprScaleSize,
|
|
4767
|
+
y: point.y / this.dprScaleSize
|
|
4776
4768
|
});
|
|
4777
4769
|
}
|
|
4778
4770
|
return point;
|
|
@@ -4784,13 +4776,13 @@ System.register([], function (exports) {
|
|
|
4784
4776
|
* @type {number}
|
|
4785
4777
|
*/
|
|
4786
4778
|
get width() {
|
|
4779
|
+
if(this.__normalSize && this.__normalSize.width) return this.__normalSize.width;
|
|
4787
4780
|
if(this.canvas) return this.canvas.width;
|
|
4788
4781
|
return 0;
|
|
4789
4782
|
}
|
|
4790
4783
|
set width(v) {
|
|
4791
4784
|
this.needUpdate = true;
|
|
4792
4785
|
if(this.canvas) {
|
|
4793
|
-
this.canvas.width = v;
|
|
4794
4786
|
this.resize(v);
|
|
4795
4787
|
}
|
|
4796
4788
|
return v;
|
|
@@ -4802,13 +4794,13 @@ System.register([], function (exports) {
|
|
|
4802
4794
|
* @type {number}
|
|
4803
4795
|
*/
|
|
4804
4796
|
get height() {
|
|
4797
|
+
if(this.__normalSize && this.__normalSize.height) return this.__normalSize.height;
|
|
4805
4798
|
if(this.canvas) return this.canvas.height;
|
|
4806
4799
|
return 0;
|
|
4807
4800
|
}
|
|
4808
4801
|
set height(v) {
|
|
4809
4802
|
this.needUpdate = true;
|
|
4810
4803
|
if(this.canvas) {
|
|
4811
|
-
this.canvas.height = v;
|
|
4812
4804
|
this.resize(0, v);
|
|
4813
4805
|
}
|
|
4814
4806
|
return v;
|
|
@@ -4967,23 +4959,13 @@ System.register([], function (exports) {
|
|
|
4967
4959
|
* @param {number} [h] 清除画布的高度
|
|
4968
4960
|
*/
|
|
4969
4961
|
clear(w, h) {
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
this.
|
|
4974
|
-
this.canvas.height = h;
|
|
4975
|
-
//保留原有缩放比例
|
|
4976
|
-
if(this.scaleSize) {
|
|
4977
|
-
if(this.context.scale) this.context.scale(this.scaleSize.x,this.scaleSize.y);
|
|
4978
|
-
}
|
|
4979
|
-
}
|
|
4980
|
-
else {
|
|
4981
|
-
w = this.canvas.width;
|
|
4982
|
-
h = this.canvas.height;
|
|
4983
|
-
if(this.scaleSize) {
|
|
4962
|
+
if(!w || !h) {
|
|
4963
|
+
w = this.width;
|
|
4964
|
+
h = this.height;
|
|
4965
|
+
/*if(this.scaleSize) {
|
|
4984
4966
|
w = w / this.scaleSize.x;
|
|
4985
4967
|
h = h / this.scaleSize.y;
|
|
4986
|
-
}
|
|
4968
|
+
}*/
|
|
4987
4969
|
}
|
|
4988
4970
|
//如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
|
|
4989
4971
|
if(this.style && this.style.fill) {
|
|
@@ -5128,6 +5110,9 @@ System.register([], function (exports) {
|
|
|
5128
5110
|
return;// 已销毁
|
|
5129
5111
|
}
|
|
5130
5112
|
if(self.needUpdate) self.redraw();
|
|
5113
|
+
// 触发刷新事件
|
|
5114
|
+
self.emit('update');
|
|
5115
|
+
|
|
5131
5116
|
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
5132
5117
|
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
5133
5118
|
if(callback) callback();
|
|
@@ -5730,7 +5715,7 @@ System.register([], function (exports) {
|
|
|
5730
5715
|
//字符串轴。则显示每个标签
|
|
5731
5716
|
|
|
5732
5717
|
const format = this.option.format || this.format;
|
|
5733
|
-
const top =
|
|
5718
|
+
const top = this.style.xLabel.margin.top || 0;
|
|
5734
5719
|
|
|
5735
5720
|
for (let i = 0; i < this.data.length; i++) {
|
|
5736
5721
|
const d = this.data[i];
|
|
@@ -5826,8 +5811,8 @@ System.register([], function (exports) {
|
|
|
5826
5811
|
const mm = max - min;
|
|
5827
5812
|
let pervalue = mm / count || 1;
|
|
5828
5813
|
const format = this.option.format || this.format;
|
|
5829
|
-
const marginLeft = this.style.yLabel.margin.left
|
|
5830
|
-
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;
|
|
5831
5816
|
let p = 0;
|
|
5832
5817
|
|
|
5833
5818
|
for (let i = 0; i < count + 1; i++) {
|
|
@@ -6255,13 +6240,13 @@ System.register([], function (exports) {
|
|
|
6255
6240
|
|
|
6256
6241
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
6257
6242
|
//顶部和底部图例横排,每次右移位一个单位图例
|
|
6258
|
-
panel.position.x = this.width + 15
|
|
6243
|
+
panel.position.x = this.width + 15;
|
|
6259
6244
|
this.width = panel.position.x + panel.width; // 把容器宽指定为所有图例宽和
|
|
6260
6245
|
|
|
6261
6246
|
this.height = Math.max(panel.height, this.height);
|
|
6262
6247
|
} else {
|
|
6263
6248
|
//右边和左边图例竖排
|
|
6264
|
-
panel.position.y += this.height + 5
|
|
6249
|
+
panel.position.y += this.height + 5;
|
|
6265
6250
|
this.height = panel.position.y + panel.height;
|
|
6266
6251
|
this.width = Math.max(panel.width, this.width);
|
|
6267
6252
|
}
|
|
@@ -6301,21 +6286,21 @@ System.register([], function (exports) {
|
|
|
6301
6286
|
{
|
|
6302
6287
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width; //画图区域向右偏移
|
|
6303
6288
|
|
|
6304
|
-
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;
|
|
6305
6290
|
break;
|
|
6306
6291
|
}
|
|
6307
6292
|
|
|
6308
6293
|
case 'top':
|
|
6309
6294
|
{
|
|
6310
6295
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6311
|
-
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;
|
|
6312
6297
|
break;
|
|
6313
6298
|
}
|
|
6314
6299
|
|
|
6315
6300
|
case 'bottom':
|
|
6316
6301
|
{
|
|
6317
6302
|
this.graph.chartArea.height = this.graph.chartArea.height - this.height;
|
|
6318
|
-
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;
|
|
6319
6304
|
break;
|
|
6320
6305
|
}
|
|
6321
6306
|
|
|
@@ -6323,7 +6308,7 @@ System.register([], function (exports) {
|
|
|
6323
6308
|
default:
|
|
6324
6309
|
{
|
|
6325
6310
|
this.graph.chartArea.width = this.graph.chartArea.width - this.width;
|
|
6326
|
-
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;
|
|
6327
6312
|
break;
|
|
6328
6313
|
}
|
|
6329
6314
|
}
|
|
@@ -7070,7 +7055,7 @@ System.register([], function (exports) {
|
|
|
7070
7055
|
x: this.graph.chartArea.width / 2,
|
|
7071
7056
|
y: this.graph.chartArea.height / 2
|
|
7072
7057
|
};
|
|
7073
|
-
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); //生成描点位
|
|
7074
7059
|
// super.init会把参数透传给 createPoints
|
|
7075
7060
|
|
|
7076
7061
|
const {
|
|
@@ -7436,7 +7421,7 @@ System.register([], function (exports) {
|
|
|
7436
7421
|
x: this.graph.chartArea.width / 2,
|
|
7437
7422
|
y: this.graph.chartArea.height / 2
|
|
7438
7423
|
};
|
|
7439
|
-
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);
|
|
7440
7425
|
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7441
7426
|
// 计算最大最小值
|
|
7442
7427
|
// 当前需要先更新axis的边界值,轴好画图
|
|
@@ -8230,7 +8215,7 @@ System.register([], function (exports) {
|
|
|
8230
8215
|
if (!p || typeof p.y === 'undefined') continue;
|
|
8231
8216
|
this.markArc = graph.createShape('circle', {
|
|
8232
8217
|
style: this.style,
|
|
8233
|
-
radius:
|
|
8218
|
+
radius: this.style.radius || 5
|
|
8234
8219
|
});
|
|
8235
8220
|
this.markArc.center.y = p.y;
|
|
8236
8221
|
this.children.add(this.markArc);
|
|
@@ -8659,7 +8644,7 @@ System.register([], function (exports) {
|
|
|
8659
8644
|
this.touchGraph.chartGraph = this;
|
|
8660
8645
|
this.on('propertyChange', (name, args) => {
|
|
8661
8646
|
if (['width', 'height'].includes(name)) {
|
|
8662
|
-
this.touchGraph[name] = args.newValue
|
|
8647
|
+
this.touchGraph[name] = args.newValue;
|
|
8663
8648
|
}
|
|
8664
8649
|
}); // 把上层canvse事件传递给绘图层对象
|
|
8665
8650
|
|
|
@@ -8799,10 +8784,10 @@ System.register([], function (exports) {
|
|
|
8799
8784
|
|
|
8800
8785
|
|
|
8801
8786
|
resetAreaPosition() {
|
|
8802
|
-
this.chartArea.position.x =
|
|
8803
|
-
this.chartArea.position.y =
|
|
8804
|
-
const w = this.width - this.style.margin.right
|
|
8805
|
-
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;
|
|
8806
8791
|
this.chartArea.width = w;
|
|
8807
8792
|
this.chartArea.height = h;
|
|
8808
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.2.
|
|
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
|
// 计算最大最小值
|