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