jmchart 1.1.95 → 1.1.98
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/README.md +13 -2
- package/dist/jmchart.amd.js +588 -139
- package/dist/jmchart.cjs.js +588 -139
- package/dist/jmchart.esm.js +588 -139
- package/dist/jmchart.iife.js +588 -139
- package/dist/jmchart.system.js +588 -139
- package/example/bar.html +4 -3
- package/example/line.html +17 -3
- package/example/pie.html +37 -0
- package/example/radar.html +162 -0
- package/example/wk/line.html +13 -1
- package/package.json +2 -2
- package/src/common/style.js +28 -2
- package/src/component/vchart.js +1 -2
- package/src/core/axis/axis.js +143 -38
- package/src/core/legend/legend.js +2 -20
- package/src/core/markLine/markLine.js +1 -0
- package/src/jmChart.js +10 -3
- package/src/series/pieSeries.js +11 -24
- package/src/series/radarSeries.js +313 -0
- package/src/series/series.js +11 -4
- package/src/series/stackBarSeries.js +9 -4
package/dist/jmchart.system.js
CHANGED
|
@@ -1408,7 +1408,7 @@ System.register([], function (exports) {
|
|
|
1408
1408
|
get context() {
|
|
1409
1409
|
let s = this.__pro('context');
|
|
1410
1410
|
if(s) return s;
|
|
1411
|
-
else if(this.is('jmGraph') && this.canvas) {
|
|
1411
|
+
else if(this.is('jmGraph') && this.canvas && this.canvas.getContext) {
|
|
1412
1412
|
return this.context = this.canvas.getContext('2d');
|
|
1413
1413
|
}
|
|
1414
1414
|
let g = this.graph;
|
|
@@ -3759,39 +3759,21 @@ System.register([], function (exports) {
|
|
|
3759
3759
|
*/
|
|
3760
3760
|
draw() {
|
|
3761
3761
|
try {
|
|
3762
|
-
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3763
|
-
if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
|
|
3764
|
-
let p = this.getLocation();
|
|
3765
|
-
p.left += bounds.left;
|
|
3766
|
-
p.top += bounds.top;
|
|
3767
3762
|
|
|
3768
|
-
let sp = this.sourcePosition;
|
|
3769
|
-
let sw = this.sourceWidth;
|
|
3770
|
-
let sh = this.sourceHeight;
|
|
3771
3763
|
let img = this.getImage();
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
else if(p.height) {
|
|
3783
|
-
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
|
|
3784
|
-
}
|
|
3785
|
-
else this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
|
|
3786
|
-
}
|
|
3787
|
-
else if(p) {
|
|
3788
|
-
if(p.width && p.height) this.context.drawImage(img,p.left,p.top,p.width,p.height);
|
|
3789
|
-
else if(p.width) this.context.drawImage(img,p.left,p.top,p.width,img.height);
|
|
3790
|
-
else if(p.height) this.context.drawImage(img,p.left,p.top,img.width,p.height);
|
|
3791
|
-
else this.context.drawImage(img,p.left,p.top);
|
|
3764
|
+
if(this.graph.isWXMiniApp && this.graph.canvas) {
|
|
3765
|
+
// 图片对象
|
|
3766
|
+
const image = this.graph.canvas.createImage();
|
|
3767
|
+
// 图片加载完成回调
|
|
3768
|
+
image.onload = () => {
|
|
3769
|
+
// 将图片绘制到 canvas 上
|
|
3770
|
+
this.drawImg(image);
|
|
3771
|
+
};
|
|
3772
|
+
// 设置图片src
|
|
3773
|
+
image.src = img;
|
|
3792
3774
|
}
|
|
3793
3775
|
else {
|
|
3794
|
-
this.
|
|
3776
|
+
this.drawImg(img);
|
|
3795
3777
|
}
|
|
3796
3778
|
}
|
|
3797
3779
|
catch(e) {
|
|
@@ -3799,6 +3781,43 @@ System.register([], function (exports) {
|
|
|
3799
3781
|
}
|
|
3800
3782
|
}
|
|
3801
3783
|
|
|
3784
|
+
// 绘制
|
|
3785
|
+
drawImg(img) {
|
|
3786
|
+
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3787
|
+
if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
|
|
3788
|
+
let p = this.getLocation();
|
|
3789
|
+
p.left += bounds.left;
|
|
3790
|
+
p.top += bounds.top;
|
|
3791
|
+
|
|
3792
|
+
let sp = this.sourcePosition;
|
|
3793
|
+
let sw = this.sourceWidth;
|
|
3794
|
+
let sh = this.sourceHeight;
|
|
3795
|
+
|
|
3796
|
+
if(sp || typeof sw != 'undefined' || typeof sh != 'undefined') {
|
|
3797
|
+
if(typeof sw == 'undefined') sw= p.width || img.width || 0;
|
|
3798
|
+
if(typeof sh == 'undefined') sh= p.height || img.height || 0;
|
|
3799
|
+
sp = sp || {x:0, y:0};
|
|
3800
|
+
|
|
3801
|
+
if(p.width && p.height) this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,p.height);
|
|
3802
|
+
else if(p.width) {
|
|
3803
|
+
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,sh);
|
|
3804
|
+
}
|
|
3805
|
+
else if(p.height) {
|
|
3806
|
+
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
|
|
3807
|
+
}
|
|
3808
|
+
else this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
|
|
3809
|
+
}
|
|
3810
|
+
else if(p) {
|
|
3811
|
+
if(p.width && p.height) this.context.drawImage(img,p.left,p.top,p.width,p.height);
|
|
3812
|
+
else if(p.width) this.context.drawImage(img,p.left,p.top,p.width,img.height);
|
|
3813
|
+
else if(p.height) this.context.drawImage(img,p.left,p.top,img.width,p.height);
|
|
3814
|
+
else this.context.drawImage(img,p.left,p.top);
|
|
3815
|
+
}
|
|
3816
|
+
else {
|
|
3817
|
+
this.context.drawImage(img);
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3802
3821
|
/**
|
|
3803
3822
|
* 获取当前控件的边界
|
|
3804
3823
|
*
|
|
@@ -3834,7 +3853,7 @@ System.register([], function (exports) {
|
|
|
3834
3853
|
else if(src && src.src) {
|
|
3835
3854
|
this.__img = src;
|
|
3836
3855
|
}
|
|
3837
|
-
else if(document && document.createElement) {
|
|
3856
|
+
else if(typeof document !== 'undefined' && document.createElement) {
|
|
3838
3857
|
this.__img = document.createElement('img');
|
|
3839
3858
|
if(src && typeof src == 'string') this.__img.src = src;
|
|
3840
3859
|
}
|
|
@@ -4403,9 +4422,9 @@ System.register([], function (exports) {
|
|
|
4403
4422
|
};
|
|
4404
4423
|
|
|
4405
4424
|
// 销毁
|
|
4406
|
-
|
|
4407
|
-
this.mouseHandler.
|
|
4408
|
-
this.keyHandler.
|
|
4425
|
+
destroy() {
|
|
4426
|
+
this.mouseHandler.destroy();
|
|
4427
|
+
this.keyHandler.destroy();
|
|
4409
4428
|
}
|
|
4410
4429
|
}
|
|
4411
4430
|
|
|
@@ -4523,7 +4542,7 @@ System.register([], function (exports) {
|
|
|
4523
4542
|
}
|
|
4524
4543
|
|
|
4525
4544
|
// 销毁所有事件
|
|
4526
|
-
|
|
4545
|
+
destroy() {
|
|
4527
4546
|
for(let name in this.eventEvents) {
|
|
4528
4547
|
const event = this.eventEvents[name];
|
|
4529
4548
|
if(!event || !event.fun) continue;
|
|
@@ -4599,7 +4618,7 @@ System.register([], function (exports) {
|
|
|
4599
4618
|
}
|
|
4600
4619
|
|
|
4601
4620
|
// 销毁所有事件
|
|
4602
|
-
|
|
4621
|
+
destroy() {
|
|
4603
4622
|
for(let name in this.eventEvents) {
|
|
4604
4623
|
const event = this.eventEvents[name];
|
|
4605
4624
|
if(!event || !event.fun) continue;
|
|
@@ -4645,9 +4664,8 @@ System.register([], function (exports) {
|
|
|
4645
4664
|
this.util = this.utils = jmUtils;
|
|
4646
4665
|
|
|
4647
4666
|
//如果是小程序
|
|
4648
|
-
if(typeof wx != 'undefined' && wx.
|
|
4649
|
-
|
|
4650
|
-
canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
4667
|
+
if(typeof wx != 'undefined' && wx.canIUse && wx.canIUse('canvas')) {
|
|
4668
|
+
if(typeof canvas === 'string') canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
4651
4669
|
this.isWXMiniApp = true;// 微信小程序平台
|
|
4652
4670
|
}
|
|
4653
4671
|
else {
|
|
@@ -4668,10 +4686,10 @@ System.register([], function (exports) {
|
|
|
4668
4686
|
}
|
|
4669
4687
|
else {
|
|
4670
4688
|
this.container = canvas.parentElement;
|
|
4671
|
-
}
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
this.
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
this.canvas = canvas;
|
|
4692
|
+
this.context = canvas.getContext('2d');
|
|
4675
4693
|
this.__init(callback);
|
|
4676
4694
|
}
|
|
4677
4695
|
|
|
@@ -4722,16 +4740,19 @@ System.register([], function (exports) {
|
|
|
4722
4740
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4723
4741
|
resize(w, h) {
|
|
4724
4742
|
|
|
4725
|
-
|
|
4726
|
-
if
|
|
4743
|
+
let scale = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4744
|
+
if(this.isWXMiniApp) {
|
|
4745
|
+
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4746
|
+
}
|
|
4747
|
+
else if (scale > 1) {
|
|
4727
4748
|
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4728
4749
|
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4729
4750
|
|
|
4730
4751
|
if(w) this.__normalSize.width = w;
|
|
4731
4752
|
if(h) this.__normalSize.height = h;
|
|
4732
|
-
|
|
4733
|
-
this.canvas.style.width = w + "px";
|
|
4734
|
-
this.canvas.style.height = h + "px";
|
|
4753
|
+
|
|
4754
|
+
this.canvas.style && (this.canvas.style.width = w + "px");
|
|
4755
|
+
this.canvas.style && (this.canvas.style.height = h + "px");
|
|
4735
4756
|
this.canvas.height = h * scale;
|
|
4736
4757
|
this.canvas.width = w *scale;
|
|
4737
4758
|
this.context.scale(scale, scale);
|
|
@@ -5098,7 +5119,7 @@ System.register([], function (exports) {
|
|
|
5098
5119
|
this.___isAutoRefreshing = true;
|
|
5099
5120
|
|
|
5100
5121
|
function update() {
|
|
5101
|
-
if(self.
|
|
5122
|
+
if(self.destroyed) {
|
|
5102
5123
|
self.___isAutoRefreshing = false;
|
|
5103
5124
|
return;// 已销毁
|
|
5104
5125
|
}
|
|
@@ -5113,9 +5134,9 @@ System.register([], function (exports) {
|
|
|
5113
5134
|
}
|
|
5114
5135
|
|
|
5115
5136
|
// 销毁当前对象
|
|
5116
|
-
|
|
5117
|
-
this.eventHandler.
|
|
5118
|
-
this.
|
|
5137
|
+
destroy() {
|
|
5138
|
+
this.eventHandler.destroy();
|
|
5139
|
+
this.destroyed = true;// 标记已销毁
|
|
5119
5140
|
}
|
|
5120
5141
|
}
|
|
5121
5142
|
|
|
@@ -5379,7 +5400,6 @@ System.register([], function (exports) {
|
|
|
5379
5400
|
zIndex: 17,
|
|
5380
5401
|
cursor: 'default',
|
|
5381
5402
|
close: true,
|
|
5382
|
-
opacity: 0.8,
|
|
5383
5403
|
shadow: {
|
|
5384
5404
|
x: 1,
|
|
5385
5405
|
y: 1,
|
|
@@ -5408,7 +5428,34 @@ System.register([], function (exports) {
|
|
|
5408
5428
|
zIndex: 11,
|
|
5409
5429
|
cursor: 'default',
|
|
5410
5430
|
close: true,
|
|
5411
|
-
|
|
5431
|
+
shadow: {
|
|
5432
|
+
x: 1,
|
|
5433
|
+
y: 1,
|
|
5434
|
+
blur: 2,
|
|
5435
|
+
color: '#ccc'
|
|
5436
|
+
}
|
|
5437
|
+
},
|
|
5438
|
+
radar: {
|
|
5439
|
+
normal: {
|
|
5440
|
+
zIndex: 11,
|
|
5441
|
+
cursor: 'default',
|
|
5442
|
+
opacity: 0.8
|
|
5443
|
+
},
|
|
5444
|
+
hover: {
|
|
5445
|
+
//zIndex: 100,
|
|
5446
|
+
opacity: 1,
|
|
5447
|
+
cursor: 'pointer'
|
|
5448
|
+
},
|
|
5449
|
+
margin: {
|
|
5450
|
+
left: 10,
|
|
5451
|
+
top: 10,
|
|
5452
|
+
right: 10,
|
|
5453
|
+
bottom: 10
|
|
5454
|
+
},
|
|
5455
|
+
lineWidth: 1,
|
|
5456
|
+
zIndex: 11,
|
|
5457
|
+
cursor: 'default',
|
|
5458
|
+
close: true,
|
|
5412
5459
|
shadow: {
|
|
5413
5460
|
x: 1,
|
|
5414
5461
|
y: 1,
|
|
@@ -5462,6 +5509,8 @@ System.register([], function (exports) {
|
|
|
5462
5509
|
|
|
5463
5510
|
_defineProperty(this, "scalePoints", []);
|
|
5464
5511
|
|
|
5512
|
+
_defineProperty(this, "labels", []);
|
|
5513
|
+
|
|
5465
5514
|
this.arrowVisible = !!options.arrowVisible;
|
|
5466
5515
|
this.zeroBase = options.zeroBase || false;
|
|
5467
5516
|
this.labelCount = options.labelCount || 5;
|
|
@@ -5475,6 +5524,8 @@ System.register([], function (exports) {
|
|
|
5475
5524
|
|
|
5476
5525
|
this.field = options.field || '';
|
|
5477
5526
|
this.index = options.index || 0;
|
|
5527
|
+
this.gridLines = []; // 线条数组
|
|
5528
|
+
|
|
5478
5529
|
this.init(options);
|
|
5479
5530
|
} // 初始化一些参数
|
|
5480
5531
|
// 这个函数可能会重入。
|
|
@@ -5484,6 +5535,8 @@ System.register([], function (exports) {
|
|
|
5484
5535
|
options = options || {}; // 深度组件默认样式
|
|
5485
5536
|
|
|
5486
5537
|
if (options.style) this.graph.utils.clone(options.style, this.style, true);
|
|
5538
|
+
this.field = options.field || this.field || '';
|
|
5539
|
+
this.radarOption = options.radarOption;
|
|
5487
5540
|
|
|
5488
5541
|
if (this.type == 'x') {
|
|
5489
5542
|
if (typeof options.maxXValue !== 'undefined') this.maxValue = options.maxXValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
@@ -5512,6 +5565,24 @@ System.register([], function (exports) {
|
|
|
5512
5565
|
|
|
5513
5566
|
set data(d) {
|
|
5514
5567
|
this.graph.data = d;
|
|
5568
|
+
} // 生成绘制点,
|
|
5569
|
+
// 重写原函数
|
|
5570
|
+
|
|
5571
|
+
|
|
5572
|
+
initPoints() {
|
|
5573
|
+
// 如果是雷达图
|
|
5574
|
+
if (this.radarOption && this.type === 'x') {
|
|
5575
|
+
this.points = [];
|
|
5576
|
+
|
|
5577
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5578
|
+
axis.end && this.points.push(axis.end);
|
|
5579
|
+
}
|
|
5580
|
+
|
|
5581
|
+
this.points.push(this.points[0]);
|
|
5582
|
+
return this.points;
|
|
5583
|
+
} else {
|
|
5584
|
+
return super.initPoints();
|
|
5585
|
+
}
|
|
5515
5586
|
}
|
|
5516
5587
|
/**
|
|
5517
5588
|
* 计算当前轴的位置
|
|
@@ -5527,7 +5598,40 @@ System.register([], function (exports) {
|
|
|
5527
5598
|
case 'x':
|
|
5528
5599
|
{
|
|
5529
5600
|
//初始化显示标签个数
|
|
5530
|
-
this.labelCount = this.style.xLabel.count || 5;
|
|
5601
|
+
this.labelCount = this.style.xLabel.count || 5; // 如果是雷达图,则画栅格线
|
|
5602
|
+
|
|
5603
|
+
if (this.radarOption) {
|
|
5604
|
+
if (this.style.grid && this.style.grid.x) {
|
|
5605
|
+
for (let i = 1; i < this.labelCount + 1; i++) {
|
|
5606
|
+
const points = [];
|
|
5607
|
+
const curRadius = this.radarOption.radius / this.labelCount * i;
|
|
5608
|
+
|
|
5609
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5610
|
+
if (!axis.radarOption) continue;
|
|
5611
|
+
const point = {};
|
|
5612
|
+
point.x = axis.radarOption.center.x + axis.radarOption.cos * curRadius + bounds.left;
|
|
5613
|
+
point.y = axis.radarOption.center.y - axis.radarOption.sin * curRadius + bounds.top;
|
|
5614
|
+
points.push(point);
|
|
5615
|
+
} // 画栅格线
|
|
5616
|
+
|
|
5617
|
+
|
|
5618
|
+
for (let j = 0; j < points.length; j++) {
|
|
5619
|
+
const start = points[j];
|
|
5620
|
+
const end = points[j + 1] || points[0];
|
|
5621
|
+
const gridLine = this.graph.createShape('line', {
|
|
5622
|
+
start,
|
|
5623
|
+
end,
|
|
5624
|
+
style: this.style.grid
|
|
5625
|
+
});
|
|
5626
|
+
this.parent.children.add(gridLine);
|
|
5627
|
+
this.gridLines.push(gridLine);
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
}
|
|
5631
|
+
|
|
5632
|
+
break;
|
|
5633
|
+
}
|
|
5634
|
+
|
|
5531
5635
|
this.start.x = bounds.left;
|
|
5532
5636
|
this.start.y = bounds.bottom;
|
|
5533
5637
|
this.end.x = bounds.right;
|
|
@@ -5546,21 +5650,30 @@ System.register([], function (exports) {
|
|
|
5546
5650
|
|
|
5547
5651
|
case 'y':
|
|
5548
5652
|
{
|
|
5549
|
-
|
|
5550
|
-
|
|
5653
|
+
//初始化显示标签个数
|
|
5654
|
+
this.labelCount = this.style.yLabel.count || 5;
|
|
5655
|
+
const index = this.index || 1; // 如果是雷达图,则画发散的线
|
|
5656
|
+
|
|
5657
|
+
if (this.radarOption) {
|
|
5658
|
+
this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left;
|
|
5659
|
+
this.end.y = this.radarOption.center.y - this.radarOption.sin * this.radarOption.radius + bounds.top;
|
|
5660
|
+
this.start.x = this.radarOption.center.x + bounds.left;
|
|
5661
|
+
this.start.y = this.radarOption.center.y + bounds.top;
|
|
5662
|
+
} else {
|
|
5663
|
+
let xoffset = bounds.left; //多Y轴时,第二个为右边第一轴,其它的依此递推
|
|
5551
5664
|
|
|
5552
|
-
|
|
5665
|
+
if (index == 2) {
|
|
5666
|
+
xoffset = bounds.right;
|
|
5667
|
+
} else if (index > 2) {
|
|
5668
|
+
xoffset = this.graph.yAxises[index - 1].start.x + this.graph.yAxises[index - 1].width + 10;
|
|
5669
|
+
}
|
|
5553
5670
|
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5671
|
+
this.start.x = xoffset;
|
|
5672
|
+
this.start.y = bounds.bottom;
|
|
5673
|
+
this.end.x = this.start.x;
|
|
5674
|
+
this.end.y = bounds.top;
|
|
5558
5675
|
}
|
|
5559
5676
|
|
|
5560
|
-
this.start.x = xoffset;
|
|
5561
|
-
this.start.y = bounds.bottom;
|
|
5562
|
-
this.end.x = this.start.x;
|
|
5563
|
-
this.end.y = bounds.top;
|
|
5564
5677
|
break;
|
|
5565
5678
|
}
|
|
5566
5679
|
}
|
|
@@ -5582,11 +5695,12 @@ System.register([], function (exports) {
|
|
|
5582
5695
|
|
|
5583
5696
|
|
|
5584
5697
|
createLabel() {
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5698
|
+
if (this.visible === false) return; // 雷达图的标签单独处理
|
|
5699
|
+
|
|
5700
|
+
if (this.radarOption) {
|
|
5701
|
+
return this.createRadarLabel();
|
|
5702
|
+
} //如果是?X轴则执行X轴标签生成
|
|
5703
|
+
|
|
5590
5704
|
|
|
5591
5705
|
if (this.type == 'x') {
|
|
5592
5706
|
this.createXLabel();
|
|
@@ -5706,13 +5820,7 @@ System.register([], function (exports) {
|
|
|
5706
5820
|
|
|
5707
5821
|
let count = this.labelCount;
|
|
5708
5822
|
const mm = max - min;
|
|
5709
|
-
|
|
5710
|
-
count = mm;
|
|
5711
|
-
}*/
|
|
5712
|
-
// mm 放大10000倍,这里结果也需要除于10000
|
|
5713
|
-
|
|
5714
|
-
let pervalue = mm / count || 1; //if(pervalue > 1 || pervalue < -1) pervalue = Math.floor(pervalue);
|
|
5715
|
-
|
|
5823
|
+
let pervalue = mm / count || 1;
|
|
5716
5824
|
const format = this.option.format || this.format;
|
|
5717
5825
|
const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
|
|
5718
5826
|
const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
|
|
@@ -5723,7 +5831,7 @@ System.register([], function (exports) {
|
|
|
5723
5831
|
if (p > max || i === count) p = max;
|
|
5724
5832
|
const h = (p - min) * step; // 当前点的偏移高度
|
|
5725
5833
|
|
|
5726
|
-
const label = this.graph.
|
|
5834
|
+
const label = this.graph.createShape('label', {
|
|
5727
5835
|
style: this.style.yLabel
|
|
5728
5836
|
});
|
|
5729
5837
|
label.text = format.call(this, p, label); // 格式化label
|
|
@@ -5756,7 +5864,7 @@ System.register([], function (exports) {
|
|
|
5756
5864
|
y: offy + this.end.y
|
|
5757
5865
|
}); // 指定要显示网格
|
|
5758
5866
|
|
|
5759
|
-
if (this.style.grid && this.style.grid.x) {
|
|
5867
|
+
if (!this.radarOption && this.style.grid && this.style.grid.x) {
|
|
5760
5868
|
// 它的坐标是相对于轴的,所以Y轴会用负的区域高度
|
|
5761
5869
|
const line = this.graph.createShape('line', {
|
|
5762
5870
|
start: {
|
|
@@ -5819,6 +5927,42 @@ System.register([], function (exports) {
|
|
|
5819
5927
|
}
|
|
5820
5928
|
}
|
|
5821
5929
|
}
|
|
5930
|
+
/**
|
|
5931
|
+
* 生成雷达图的Y轴标签
|
|
5932
|
+
*/
|
|
5933
|
+
|
|
5934
|
+
|
|
5935
|
+
createRadarLabel() {
|
|
5936
|
+
const format = this.option.format;
|
|
5937
|
+
const bounds = this.graph.chartArea.getBounds(); // 获取画图区域
|
|
5938
|
+
|
|
5939
|
+
const self = this;
|
|
5940
|
+
const label = this.graph.createShape('label', {
|
|
5941
|
+
style: this.style.yLabel,
|
|
5942
|
+
position: function () {
|
|
5943
|
+
// 因为axis是相对于chart的,而center是相对于chartArea的,所以要计算axis位置相对于chartArea来比较
|
|
5944
|
+
const pos = {
|
|
5945
|
+
x: self.end.x - bounds.left,
|
|
5946
|
+
y: self.end.y - bounds.top
|
|
5947
|
+
};
|
|
5948
|
+
const size = this.testSize();
|
|
5949
|
+
|
|
5950
|
+
if (pos.x < self.radarOption.center.x) {
|
|
5951
|
+
pos.x -= size.width;
|
|
5952
|
+
}
|
|
5953
|
+
|
|
5954
|
+
if (pos.y < self.radarOption.center.y) {
|
|
5955
|
+
pos.y -= size.height;
|
|
5956
|
+
}
|
|
5957
|
+
|
|
5958
|
+
return pos;
|
|
5959
|
+
}
|
|
5960
|
+
});
|
|
5961
|
+
label.text = typeof format === 'function' ? format.call(this, label) : this.field; // 格式化label
|
|
5962
|
+
|
|
5963
|
+
this.labels.push(label);
|
|
5964
|
+
this.graph.chartArea.children.add(label);
|
|
5965
|
+
}
|
|
5822
5966
|
/**
|
|
5823
5967
|
* 获取当前轴所占宽
|
|
5824
5968
|
*
|
|
@@ -5966,6 +6110,18 @@ System.register([], function (exports) {
|
|
|
5966
6110
|
clear() {
|
|
5967
6111
|
this._min = null;
|
|
5968
6112
|
this._max = null;
|
|
6113
|
+
this.children.each((i, c) => {
|
|
6114
|
+
c.remove();
|
|
6115
|
+
}, true); // 清空栅格线
|
|
6116
|
+
|
|
6117
|
+
this.gridLines && this.gridLines.forEach(line => {
|
|
6118
|
+
line.remove();
|
|
6119
|
+
});
|
|
6120
|
+
this.labels && this.labels.forEach(label => {
|
|
6121
|
+
label.remove();
|
|
6122
|
+
});
|
|
6123
|
+
this.labels = [];
|
|
6124
|
+
this.gridLines = [];
|
|
5969
6125
|
}
|
|
5970
6126
|
/**
|
|
5971
6127
|
* 计算当前轴的单位偏移量
|
|
@@ -5977,7 +6133,7 @@ System.register([], function (exports) {
|
|
|
5977
6133
|
|
|
5978
6134
|
step() {
|
|
5979
6135
|
if (this.type == 'x') {
|
|
5980
|
-
const w = this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
6136
|
+
const w = this.radarOption ? this.radarOption.radius : this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
5981
6137
|
//也就是起始位从一个单位开始
|
|
5982
6138
|
|
|
5983
6139
|
if (this.graph.style.layout == 'inside') {
|
|
@@ -5993,7 +6149,7 @@ System.register([], function (exports) {
|
|
|
5993
6149
|
|
|
5994
6150
|
return w / tmp;
|
|
5995
6151
|
} else if (this.type == 'y') {
|
|
5996
|
-
const h = this.height;
|
|
6152
|
+
const h = this.radarOption ? this.radarOption.radius : this.height;
|
|
5997
6153
|
|
|
5998
6154
|
switch (this.dataType) {
|
|
5999
6155
|
case 'string':
|
|
@@ -6088,28 +6244,9 @@ System.register([], function (exports) {
|
|
|
6088
6244
|
}
|
|
6089
6245
|
|
|
6090
6246
|
panel.height = shape.height; //执行进入事件
|
|
6091
|
-
//触动图例后加粗显示图
|
|
6092
|
-
|
|
6093
|
-
/*const hover = options.hover || function() {
|
|
6094
|
-
//应用图的动态样式
|
|
6095
|
-
//Object.assign(series.style, series.style.hover);
|
|
6096
|
-
|
|
6097
|
-
//Object.assign(this.style, this.style.hover || {});
|
|
6098
|
-
|
|
6099
|
-
//series.graph.refresh();
|
|
6100
|
-
};
|
|
6101
|
-
panel.bind('mouseover', hover);
|
|
6102
|
-
//执行离开
|
|
6103
|
-
const leave = options.leave || function() {
|
|
6104
|
-
//应用图的普通样式
|
|
6105
|
-
//Object.assign(series.style, series.style.normal);
|
|
6106
|
-
|
|
6107
|
-
//Object.assign(this.style, this.style.normal || {});
|
|
6108
|
-
//jmUtils.apply(this.series.style.normal,this.series.style);
|
|
6109
|
-
//series.graph.refresh();
|
|
6110
|
-
};
|
|
6111
|
-
panel.bind('mouseleave', leave);*/
|
|
6112
6247
|
|
|
6248
|
+
options.hover && panel.bind('mouseover touchover', options.hover);
|
|
6249
|
+
options.leave && panel.bind('mouseleave touchleave', options.leave);
|
|
6113
6250
|
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
6114
6251
|
|
|
6115
6252
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
@@ -6257,7 +6394,7 @@ System.register([], function (exports) {
|
|
|
6257
6394
|
}); // 初始化一些参数, 因为这里有多个Y轴的可能,所以每次都需要重调一次init
|
|
6258
6395
|
|
|
6259
6396
|
this.yAxis.init({
|
|
6260
|
-
field: this.field,
|
|
6397
|
+
field: Array.isArray(this.field) ? this.field[0] : this.field,
|
|
6261
6398
|
minYValue: options.minYValue,
|
|
6262
6399
|
maxYValue: options.maxYValue
|
|
6263
6400
|
});
|
|
@@ -6312,6 +6449,11 @@ System.register([], function (exports) {
|
|
|
6312
6449
|
if (dataChanged) this.___animateCounter = 0; // 数据改变。动画重新开始
|
|
6313
6450
|
} else {
|
|
6314
6451
|
this.dataPoints = this.createPoints(...args);
|
|
6452
|
+
} // 执行初始化函数回调
|
|
6453
|
+
|
|
6454
|
+
|
|
6455
|
+
if (this.option && this.option.onInit) {
|
|
6456
|
+
this.option.onInit.apply(this, args);
|
|
6315
6457
|
}
|
|
6316
6458
|
|
|
6317
6459
|
return {
|
|
@@ -6380,12 +6522,12 @@ System.register([], function (exports) {
|
|
|
6380
6522
|
|
|
6381
6523
|
while (shape = this.shapes.shift()) {
|
|
6382
6524
|
shape && shape.remove();
|
|
6383
|
-
}
|
|
6384
|
-
|
|
6525
|
+
}
|
|
6385
6526
|
|
|
6386
|
-
this.createLegend();
|
|
6387
6527
|
this.initAxisValue(); // 处理最大值最小值
|
|
6528
|
+
//生成图例 这里要放到shape清理后面
|
|
6388
6529
|
|
|
6530
|
+
this.createLegend();
|
|
6389
6531
|
return this.chartInfo = {
|
|
6390
6532
|
xAxis: this.xAxis,
|
|
6391
6533
|
yAxis: this.yAxis
|
|
@@ -6450,7 +6592,8 @@ System.register([], function (exports) {
|
|
|
6450
6592
|
|
|
6451
6593
|
p.x = xstep * i + this.xAxis.labelStart;
|
|
6452
6594
|
|
|
6453
|
-
for (
|
|
6595
|
+
for (let j = 0; j < fields.length; j++) {
|
|
6596
|
+
const f = fields[j];
|
|
6454
6597
|
const yv = s[f];
|
|
6455
6598
|
p.yLabel = p.yValue = yv; // 高度
|
|
6456
6599
|
|
|
@@ -6511,6 +6654,7 @@ System.register([], function (exports) {
|
|
|
6511
6654
|
style
|
|
6512
6655
|
});
|
|
6513
6656
|
this.graph.legend.append(this, shape);
|
|
6657
|
+
return shape;
|
|
6514
6658
|
} // 生成柱图的标注
|
|
6515
6659
|
|
|
6516
6660
|
|
|
@@ -6776,15 +6920,18 @@ System.register([], function (exports) {
|
|
|
6776
6920
|
|
|
6777
6921
|
for (let index = 0; index < point.points.length; index++) {
|
|
6778
6922
|
const style = this.graph.utils.clone(this.style);
|
|
6923
|
+
const p = point.points[index];
|
|
6779
6924
|
|
|
6780
6925
|
if (style.color && typeof style.color === 'function') {
|
|
6781
|
-
style.fill = style.color.call(this,
|
|
6926
|
+
style.fill = style.color.call(this, {
|
|
6927
|
+
index,
|
|
6928
|
+
point: p
|
|
6929
|
+
});
|
|
6782
6930
|
} else {
|
|
6783
6931
|
style.fill = this.graph.getColor(index);
|
|
6784
6932
|
}
|
|
6785
6933
|
|
|
6786
6934
|
const sp = this.addShape(this.graph.createPath(null, style));
|
|
6787
|
-
const p = point.points[index];
|
|
6788
6935
|
let startY = topStartY;
|
|
6789
6936
|
if (p.yValue < this.baseYValue) startY = bottomStartY; //首先确定p1和p4,因为他们是底脚。会固定
|
|
6790
6937
|
|
|
@@ -6856,7 +7003,8 @@ System.register([], function (exports) {
|
|
|
6856
7003
|
for (const row of this.data) {
|
|
6857
7004
|
let max, min;
|
|
6858
7005
|
|
|
6859
|
-
for (
|
|
7006
|
+
for (let i = 0; i < fields.length; i++) {
|
|
7007
|
+
const f = fields[i];
|
|
6860
7008
|
const v = Number(row[f]);
|
|
6861
7009
|
if (typeof max === 'undefined') max = v;else {
|
|
6862
7010
|
if (v < 0 || max < 0) max = Math.max(max, v);else {
|
|
@@ -6918,7 +7066,7 @@ System.register([], function (exports) {
|
|
|
6918
7066
|
x: this.graph.chartArea.width / 2,
|
|
6919
7067
|
y: this.graph.chartArea.height / 2
|
|
6920
7068
|
};
|
|
6921
|
-
const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right * this.graph.devicePixelRatio, center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio); //生成描点位
|
|
7069
|
+
const radius = Math.min(center.x - this.style.margin.left * this.graph.devicePixelRatio - this.style.margin.right * this.graph.devicePixelRatio, center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio); //生成描点位
|
|
6922
7070
|
// super.init会把参数透传给 createPoints
|
|
6923
7071
|
|
|
6924
7072
|
const {
|
|
@@ -7010,7 +7158,8 @@ System.register([], function (exports) {
|
|
|
7010
7158
|
// 每个数值点比
|
|
7011
7159
|
style: this.graph.utils.clone(this.style),
|
|
7012
7160
|
anticlockwise
|
|
7013
|
-
};
|
|
7161
|
+
};
|
|
7162
|
+
points.push(p); //p.style.color = this.graph.getColor(index);
|
|
7014
7163
|
|
|
7015
7164
|
if (p.style.color && typeof p.style.color === 'function') {
|
|
7016
7165
|
p.style.fill = p.style.color.call(this, p);
|
|
@@ -7091,34 +7240,34 @@ System.register([], function (exports) {
|
|
|
7091
7240
|
|
|
7092
7241
|
if (this.option.onClick) {
|
|
7093
7242
|
p.shape.on('click', e => {
|
|
7094
|
-
this.option.onClick.call(this, p, e);
|
|
7243
|
+
return this.option.onClick.call(this, p, e);
|
|
7095
7244
|
});
|
|
7096
7245
|
}
|
|
7097
7246
|
|
|
7098
7247
|
if (this.option.onOver) {
|
|
7099
7248
|
p.shape.on('mouseover touchover', e => {
|
|
7100
|
-
this.option.onOver.call(this, p, e);
|
|
7249
|
+
return this.option.onOver.call(this, p, e);
|
|
7101
7250
|
});
|
|
7102
7251
|
}
|
|
7103
7252
|
|
|
7104
7253
|
if (this.option.onLeave) {
|
|
7105
7254
|
p.shape.on('mouseleave touchleave', e => {
|
|
7106
|
-
this.option.onLeave.call(this, p, e);
|
|
7255
|
+
return this.option.onLeave.call(this, p, e);
|
|
7107
7256
|
});
|
|
7108
7257
|
}
|
|
7109
7258
|
|
|
7110
7259
|
this.createLabel(p); // 生成标签
|
|
7111
|
-
|
|
7260
|
+
// 生成标点的回调
|
|
7112
7261
|
|
|
7113
|
-
|
|
7114
|
-
|
|
7262
|
+
this.emit('onPointCreated', p);
|
|
7263
|
+
}
|
|
7115
7264
|
|
|
7116
|
-
|
|
7265
|
+
index++;
|
|
7117
7266
|
}
|
|
7118
7267
|
}
|
|
7119
7268
|
|
|
7120
7269
|
return points;
|
|
7121
|
-
} //
|
|
7270
|
+
} // 生成图的标注
|
|
7122
7271
|
|
|
7123
7272
|
|
|
7124
7273
|
createLabel(point) {
|
|
@@ -7142,7 +7291,7 @@ System.register([], function (exports) {
|
|
|
7142
7291
|
}; // 动态计算位置
|
|
7143
7292
|
|
|
7144
7293
|
const parentRect = this.parent.getBounds(); //const rect = this.getBounds.call(this.parent);
|
|
7145
|
-
//
|
|
7294
|
+
// 圆弧的中间位,离圆心最近和最远的二个点
|
|
7146
7295
|
|
|
7147
7296
|
let centerMaxPoint = this.parent.points[Math.floor(this.parent.points.length / 2)];
|
|
7148
7297
|
let centerMinPoint = this.parent.center; // 如果是空心圆,则要计算 1/4 和 3/4位的点。顺时针和逆时针二个点大小不一样,这里只取,大小计算时处理
|
|
@@ -7184,7 +7333,7 @@ System.register([], function (exports) {
|
|
|
7184
7333
|
const points = this.createPoints();
|
|
7185
7334
|
if (!points || !points.length) return;
|
|
7186
7335
|
|
|
7187
|
-
for (let k
|
|
7336
|
+
for (let k = 0; k < points.length; k++) {
|
|
7188
7337
|
const p = points[k];
|
|
7189
7338
|
if (!p) continue; //生成图例前的图标
|
|
7190
7339
|
|
|
@@ -7202,23 +7351,315 @@ System.register([], function (exports) {
|
|
|
7202
7351
|
|
|
7203
7352
|
this.graph.legend.append(this, shape, {
|
|
7204
7353
|
name: this.legendLabel,
|
|
7205
|
-
hover: function () {
|
|
7206
|
-
//var sp = this.children.get(0);
|
|
7207
|
-
//应用图的动态样式
|
|
7208
|
-
Object.assign(this.targetShape.style, this.targetShape.style.hover);
|
|
7209
|
-
Object.assign(this.style, this.style.hover);
|
|
7210
|
-
},
|
|
7211
|
-
leave: function () {
|
|
7212
|
-
//var sp = this.children.get(0);
|
|
7213
|
-
//应用图的普通样式
|
|
7214
|
-
Object.assign(this.targetShape.style, this.targetShape.style.normal);
|
|
7215
|
-
Object.assign(this.style, this.style.normal);
|
|
7216
|
-
},
|
|
7217
7354
|
data: this.data[k]
|
|
7218
7355
|
});
|
|
7219
7356
|
}
|
|
7220
7357
|
};
|
|
7221
7358
|
|
|
7359
|
+
/**
|
|
7360
|
+
* 雷达图
|
|
7361
|
+
*
|
|
7362
|
+
* @class jmRadarSeries
|
|
7363
|
+
* @module jmChart
|
|
7364
|
+
* @param {jmChart} chart 当前图表
|
|
7365
|
+
* @param {array} mappings 图形字段映射
|
|
7366
|
+
* @param {style} style 样式
|
|
7367
|
+
*/
|
|
7368
|
+
//构造函数
|
|
7369
|
+
|
|
7370
|
+
class jmRadarSeries extends jmSeries {
|
|
7371
|
+
constructor(options) {
|
|
7372
|
+
super(options);
|
|
7373
|
+
} // 重新生成轴,雷达图只需要Y轴即可
|
|
7374
|
+
|
|
7375
|
+
|
|
7376
|
+
createAxises(center, radius) {
|
|
7377
|
+
this.axises = [this.yAxis];
|
|
7378
|
+
const yCount = this.field.length;
|
|
7379
|
+
if (!yCount) return; //每个维度点的角度
|
|
7380
|
+
|
|
7381
|
+
const rotateStep = Math.PI * 2 / yCount; // 清空除了一个默认外的所有Y轴
|
|
7382
|
+
|
|
7383
|
+
for (let index in this.graph.yAxises) {
|
|
7384
|
+
const axis = this.graph.yAxises[index];
|
|
7385
|
+
if (!axis || axis === this.yAxis) continue;
|
|
7386
|
+
axis.remove();
|
|
7387
|
+
delete this.graph.yAxises[index];
|
|
7388
|
+
}
|
|
7389
|
+
|
|
7390
|
+
for (let index = 0; index < yCount; index++) {
|
|
7391
|
+
if (!this.field[index]) continue;
|
|
7392
|
+
let axis = this.yAxis; // 除了默认的y轴外,其它都重新生成
|
|
7393
|
+
|
|
7394
|
+
if (index > 0) {
|
|
7395
|
+
axis = this.graph.createYAxis({
|
|
7396
|
+
index: index + 1,
|
|
7397
|
+
format: this.option.yLabelFormat || this.graph.option.yLabelFormat
|
|
7398
|
+
});
|
|
7399
|
+
this.axises.push(axis);
|
|
7400
|
+
}
|
|
7401
|
+
|
|
7402
|
+
const rotate = Math.PI / 2 + rotateStep * index; //从向上90度开始
|
|
7403
|
+
|
|
7404
|
+
axis.init({
|
|
7405
|
+
field: this.field[index],
|
|
7406
|
+
radarOption: {
|
|
7407
|
+
center,
|
|
7408
|
+
radius,
|
|
7409
|
+
yCount,
|
|
7410
|
+
rotate: rotate,
|
|
7411
|
+
cos: Math.cos(rotate),
|
|
7412
|
+
sin: Math.sin(rotate)
|
|
7413
|
+
}
|
|
7414
|
+
});
|
|
7415
|
+
} // x轴初始化
|
|
7416
|
+
|
|
7417
|
+
|
|
7418
|
+
this.xAxis.init({
|
|
7419
|
+
radarOption: {
|
|
7420
|
+
center,
|
|
7421
|
+
radius,
|
|
7422
|
+
yCount,
|
|
7423
|
+
yAxises: this.axises
|
|
7424
|
+
}
|
|
7425
|
+
});
|
|
7426
|
+
return this.axises;
|
|
7427
|
+
} // 计算最大值和最小值,一般图形直接采用最大最小值即可,有些需要多值叠加
|
|
7428
|
+
|
|
7429
|
+
|
|
7430
|
+
initAxisValue() {
|
|
7431
|
+
this.center = {
|
|
7432
|
+
x: this.graph.chartArea.width / 2,
|
|
7433
|
+
y: this.graph.chartArea.height / 2
|
|
7434
|
+
};
|
|
7435
|
+
this.radius = Math.min(this.center.x - this.style.margin.left * this.graph.devicePixelRatio - this.style.margin.right * this.graph.devicePixelRatio, this.center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio);
|
|
7436
|
+
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7437
|
+
// 计算最大最小值
|
|
7438
|
+
// 当前需要先更新axis的边界值,轴好画图
|
|
7439
|
+
|
|
7440
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
7441
|
+
axises.forEach(axis => {
|
|
7442
|
+
const v = this.data[i][axis.field];
|
|
7443
|
+
axis.max(v);
|
|
7444
|
+
axis.min(v);
|
|
7445
|
+
});
|
|
7446
|
+
}
|
|
7447
|
+
} // 重新初始化图形
|
|
7448
|
+
|
|
7449
|
+
|
|
7450
|
+
init() {
|
|
7451
|
+
//生成描点位
|
|
7452
|
+
// super.init会把参数透传给 createPoints
|
|
7453
|
+
const {
|
|
7454
|
+
points,
|
|
7455
|
+
dataChanged
|
|
7456
|
+
} = this.initDataPoint(this.center, this.radius); // 是否正在动画中
|
|
7457
|
+
|
|
7458
|
+
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0);
|
|
7459
|
+
const aniCount = this.style.aniCount || 20;
|
|
7460
|
+
let aniIsEnd = true; // 当次是否结束动画
|
|
7461
|
+
|
|
7462
|
+
const len = points.length;
|
|
7463
|
+
const shapeMap = {};
|
|
7464
|
+
const self = this;
|
|
7465
|
+
|
|
7466
|
+
for (let i = 0; i < len; i++) {
|
|
7467
|
+
const p = points[i];
|
|
7468
|
+
let shape = shapeMap[p.index];
|
|
7469
|
+
|
|
7470
|
+
if (!shape) {
|
|
7471
|
+
shape = shapeMap[p.index] = this.graph.createShape('path', { ...p,
|
|
7472
|
+
style: p.style,
|
|
7473
|
+
points: []
|
|
7474
|
+
});
|
|
7475
|
+
this.addShape(shape); // 如果有点击事件
|
|
7476
|
+
|
|
7477
|
+
if (this.option.onClick) {
|
|
7478
|
+
shape.on('click', function (e) {
|
|
7479
|
+
return self.option.onClick.call(this, e);
|
|
7480
|
+
});
|
|
7481
|
+
}
|
|
7482
|
+
|
|
7483
|
+
if (this.option.onOver) {
|
|
7484
|
+
shape.on('mouseover touchover', function (e) {
|
|
7485
|
+
return self.option.onOver.call(this, e);
|
|
7486
|
+
});
|
|
7487
|
+
}
|
|
7488
|
+
|
|
7489
|
+
if (this.option.onLeave) {
|
|
7490
|
+
shape.on('mouseleave touchleave', function (e) {
|
|
7491
|
+
return self.option.onLeave.call(this, e);
|
|
7492
|
+
});
|
|
7493
|
+
}
|
|
7494
|
+
|
|
7495
|
+
this.createLegend(p);
|
|
7496
|
+
}
|
|
7497
|
+
|
|
7498
|
+
shape.zIndex += p.radius / this.radius; // 用每个轴占比做为排序号,这样占面积最大的排最底层
|
|
7499
|
+
|
|
7500
|
+
let point = null; // 在动画中,则一直刷新
|
|
7501
|
+
|
|
7502
|
+
if (isRunningAni) {
|
|
7503
|
+
let step = p.radius / aniCount * this.___animateCounter;
|
|
7504
|
+
|
|
7505
|
+
if (step >= p.radius) {
|
|
7506
|
+
step = p.radius;
|
|
7507
|
+
} else {
|
|
7508
|
+
aniIsEnd = false;
|
|
7509
|
+
}
|
|
7510
|
+
|
|
7511
|
+
point = { ...p,
|
|
7512
|
+
x: this.center.x + p.axis.radarOption.cos * step,
|
|
7513
|
+
y: this.center.y - p.axis.radarOption.sin * step
|
|
7514
|
+
};
|
|
7515
|
+
} else {
|
|
7516
|
+
point = p;
|
|
7517
|
+
}
|
|
7518
|
+
|
|
7519
|
+
shape.points.push(point);
|
|
7520
|
+
this.createLabel(point); // 生成标签
|
|
7521
|
+
} // 所有动画都完成,则清空计数器
|
|
7522
|
+
|
|
7523
|
+
|
|
7524
|
+
if (aniIsEnd) {
|
|
7525
|
+
this.___animateCounter = 0;
|
|
7526
|
+
} else {
|
|
7527
|
+
this.___animateCounter++; // next tick 再次刷新
|
|
7528
|
+
|
|
7529
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7530
|
+
this.needUpdate = true; //需要刷新
|
|
7531
|
+
});
|
|
7532
|
+
}
|
|
7533
|
+
}
|
|
7534
|
+
/**
|
|
7535
|
+
* 生成序列图描点
|
|
7536
|
+
*
|
|
7537
|
+
* @method createPoints
|
|
7538
|
+
*/
|
|
7539
|
+
|
|
7540
|
+
|
|
7541
|
+
createPoints(center, radius) {
|
|
7542
|
+
if (!this.data || !this.axises) return [];
|
|
7543
|
+
center = center || this.center;
|
|
7544
|
+
const points = [];
|
|
7545
|
+
|
|
7546
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
7547
|
+
const s = this.data[i];
|
|
7548
|
+
const style = this.graph.utils.clone(this.style);
|
|
7549
|
+
|
|
7550
|
+
if (style.color && typeof style.color === 'function') {
|
|
7551
|
+
style.stroke = style.color.call(this, {
|
|
7552
|
+
data: s,
|
|
7553
|
+
index: i
|
|
7554
|
+
});
|
|
7555
|
+
} else {
|
|
7556
|
+
style.stroke = this.graph.getColor(i);
|
|
7557
|
+
}
|
|
7558
|
+
|
|
7559
|
+
if (typeof style.fill === 'function') {
|
|
7560
|
+
style.fill = style.fill.call(this, style);
|
|
7561
|
+
} else {
|
|
7562
|
+
const color = this.graph.utils.hexToRGBA(style.stroke);
|
|
7563
|
+
style.fill = `rgba(${color.r},${color.g},${color.b}, 0.2)`;
|
|
7564
|
+
}
|
|
7565
|
+
|
|
7566
|
+
const shapePoints = [];
|
|
7567
|
+
|
|
7568
|
+
for (const axis of this.axises) {
|
|
7569
|
+
if (!axis || !axis.field) continue;
|
|
7570
|
+
const yv = s[axis.field];
|
|
7571
|
+
const p = {
|
|
7572
|
+
x: center.x,
|
|
7573
|
+
y: center.y,
|
|
7574
|
+
index: i,
|
|
7575
|
+
radius: 0,
|
|
7576
|
+
data: s,
|
|
7577
|
+
yValue: yv,
|
|
7578
|
+
yLabel: yv,
|
|
7579
|
+
style,
|
|
7580
|
+
axis
|
|
7581
|
+
};
|
|
7582
|
+
shapePoints.push(p); //如果Y值不存在。则此点无效,不画图
|
|
7583
|
+
|
|
7584
|
+
if (yv == null || typeof yv == 'undefined') {
|
|
7585
|
+
continue;
|
|
7586
|
+
}
|
|
7587
|
+
|
|
7588
|
+
p.radius = Math.abs(yv - axis.min()) * axis.step();
|
|
7589
|
+
p.x = center.x + axis.radarOption.cos * p.radius;
|
|
7590
|
+
p.y = center.y - axis.radarOption.sin * p.radius; // 生成标点的回调
|
|
7591
|
+
|
|
7592
|
+
this.emit('onPointCreated', p);
|
|
7593
|
+
}
|
|
7594
|
+
|
|
7595
|
+
points.push(...shapePoints);
|
|
7596
|
+
}
|
|
7597
|
+
|
|
7598
|
+
return points;
|
|
7599
|
+
} // 生成图的标注
|
|
7600
|
+
|
|
7601
|
+
|
|
7602
|
+
createLabel(point) {
|
|
7603
|
+
if (this.style.label && this.style.label.show === false) return;
|
|
7604
|
+
const text = this.option.itemLabelFormat ? this.option.itemLabelFormat.call(this, point) : point.yValue;
|
|
7605
|
+
if (!text) return; // v如果指定了为控件,则直接加入
|
|
7606
|
+
|
|
7607
|
+
if (text instanceof jmControl) {
|
|
7608
|
+
this.addShape(text);
|
|
7609
|
+
return text;
|
|
7610
|
+
}
|
|
7611
|
+
|
|
7612
|
+
const self = this;
|
|
7613
|
+
const label = this.graph.createShape('label', {
|
|
7614
|
+
style: this.style.label,
|
|
7615
|
+
text: text,
|
|
7616
|
+
point,
|
|
7617
|
+
position: function () {
|
|
7618
|
+
const p = {
|
|
7619
|
+
x: this.option.point.x,
|
|
7620
|
+
y: this.option.point.y
|
|
7621
|
+
};
|
|
7622
|
+
|
|
7623
|
+
if (p.x < self.center.x) {
|
|
7624
|
+
p.x -= this.width;
|
|
7625
|
+
}
|
|
7626
|
+
|
|
7627
|
+
if (p.y < self.center.y) {
|
|
7628
|
+
p.y -= this.height;
|
|
7629
|
+
}
|
|
7630
|
+
|
|
7631
|
+
return p;
|
|
7632
|
+
}
|
|
7633
|
+
});
|
|
7634
|
+
this.addShape(label);
|
|
7635
|
+
}
|
|
7636
|
+
|
|
7637
|
+
}
|
|
7638
|
+
/**
|
|
7639
|
+
* 生成图例
|
|
7640
|
+
*
|
|
7641
|
+
* @method createLegend
|
|
7642
|
+
*/
|
|
7643
|
+
|
|
7644
|
+
jmRadarSeries.prototype.createLegend = function (point) {
|
|
7645
|
+
if (!point) return; //生成图例前的图标
|
|
7646
|
+
|
|
7647
|
+
const style = this.graph.utils.clone(point.style); //delete style.stroke;
|
|
7648
|
+
|
|
7649
|
+
const shape = this.graph.createShape('rect', {
|
|
7650
|
+
style: style,
|
|
7651
|
+
position: {
|
|
7652
|
+
x: 0,
|
|
7653
|
+
y: 0
|
|
7654
|
+
}
|
|
7655
|
+
}); //此处重写图例事件
|
|
7656
|
+
|
|
7657
|
+
this.graph.legend.append(this, shape, {
|
|
7658
|
+
name: this.legendLabel,
|
|
7659
|
+
data: point.data
|
|
7660
|
+
});
|
|
7661
|
+
};
|
|
7662
|
+
|
|
7222
7663
|
/**
|
|
7223
7664
|
* 图形基类
|
|
7224
7665
|
*
|
|
@@ -7782,6 +8223,7 @@ System.register([], function (exports) {
|
|
|
7782
8223
|
this.start.x = this.end.x = isTocuhGraph ? point.x + graph.chartArea.position.x : point.x;
|
|
7783
8224
|
|
|
7784
8225
|
for (const p of point.points) {
|
|
8226
|
+
if (!p || typeof p.y === 'undefined') continue;
|
|
7785
8227
|
this.markArc = graph.createShape('circle', {
|
|
7786
8228
|
style: this.style,
|
|
7787
8229
|
radius: (this.style.radius || 5) * this.graph.devicePixelRatio
|
|
@@ -8002,6 +8444,7 @@ System.register([], function (exports) {
|
|
|
8002
8444
|
|
|
8003
8445
|
if (chart.style.markLine.lock) {
|
|
8004
8446
|
// 标线状态一直禁用系统能力
|
|
8447
|
+
// 如果指定了锁定值,只需要一项符合要求就进行锁定
|
|
8005
8448
|
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) {
|
|
8006
8449
|
lineTouching = 1;
|
|
8007
8450
|
args.event.preventDefault(); // 阻止默认行为
|
|
@@ -8395,7 +8838,7 @@ System.register([], function (exports) {
|
|
|
8395
8838
|
type: 'x',
|
|
8396
8839
|
visible: this.style.axis.x === false ? false : true,
|
|
8397
8840
|
format: this.option.xLabelFormat,
|
|
8398
|
-
...this.option.
|
|
8841
|
+
...this.option.xAxisOption
|
|
8399
8842
|
}, options || {});
|
|
8400
8843
|
|
|
8401
8844
|
if (typeof this.option.minXValue !== 'undefined') {
|
|
@@ -8432,7 +8875,7 @@ System.register([], function (exports) {
|
|
|
8432
8875
|
visible: this.style.axis.y === false ? false : true,
|
|
8433
8876
|
format: this.option.yLabelFormat,
|
|
8434
8877
|
zeroBase: this.baseY === 0,
|
|
8435
|
-
...this.option.
|
|
8878
|
+
...this.option.yAxisOption
|
|
8436
8879
|
}, options || {});
|
|
8437
8880
|
|
|
8438
8881
|
if (typeof this.option.minYValue !== 'undefined') {
|
|
@@ -8464,6 +8907,7 @@ System.register([], function (exports) {
|
|
|
8464
8907
|
'bar': jmBarSeries,
|
|
8465
8908
|
'stackBar': jmStackBarSeries,
|
|
8466
8909
|
'pie': jmPieSeries,
|
|
8910
|
+
'radar': jmRadarSeries,
|
|
8467
8911
|
'stackLine': jmStackLineSeries,
|
|
8468
8912
|
'candlestick': jmCandlestickSeries
|
|
8469
8913
|
};
|
|
@@ -8482,6 +8926,12 @@ System.register([], function (exports) {
|
|
|
8482
8926
|
}
|
|
8483
8927
|
|
|
8484
8928
|
return serie;
|
|
8929
|
+
} // 销毁
|
|
8930
|
+
|
|
8931
|
+
|
|
8932
|
+
destroy() {
|
|
8933
|
+
super.destroy();
|
|
8934
|
+
this.touchGraph && this.touchGraph.destroy();
|
|
8485
8935
|
}
|
|
8486
8936
|
|
|
8487
8937
|
} exports({ default: jmChart, jmChart: jmChart });
|
|
@@ -8528,8 +8978,7 @@ System.register([], function (exports) {
|
|
|
8528
8978
|
|
|
8529
8979
|
// 销毁
|
|
8530
8980
|
destroyed() {
|
|
8531
|
-
this.chartInstance && this.chartInstance.
|
|
8532
|
-
this.chartInstance && this.chartInstance.touchGraph && this.chartInstance.touchGraph.destory();
|
|
8981
|
+
this.chartInstance && this.chartInstance.destroy();
|
|
8533
8982
|
},
|
|
8534
8983
|
|
|
8535
8984
|
watch: {
|