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.esm.js
CHANGED
|
@@ -1403,7 +1403,7 @@ class jmControl extends jmProperty {
|
|
|
1403
1403
|
get context() {
|
|
1404
1404
|
let s = this.__pro('context');
|
|
1405
1405
|
if(s) return s;
|
|
1406
|
-
else if(this.is('jmGraph') && this.canvas) {
|
|
1406
|
+
else if(this.is('jmGraph') && this.canvas && this.canvas.getContext) {
|
|
1407
1407
|
return this.context = this.canvas.getContext('2d');
|
|
1408
1408
|
}
|
|
1409
1409
|
let g = this.graph;
|
|
@@ -3754,39 +3754,21 @@ class jmImage extends jmControl {
|
|
|
3754
3754
|
*/
|
|
3755
3755
|
draw() {
|
|
3756
3756
|
try {
|
|
3757
|
-
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3758
|
-
if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
|
|
3759
|
-
let p = this.getLocation();
|
|
3760
|
-
p.left += bounds.left;
|
|
3761
|
-
p.top += bounds.top;
|
|
3762
3757
|
|
|
3763
|
-
let sp = this.sourcePosition;
|
|
3764
|
-
let sw = this.sourceWidth;
|
|
3765
|
-
let sh = this.sourceHeight;
|
|
3766
3758
|
let img = this.getImage();
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
else if(p.height) {
|
|
3778
|
-
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
|
|
3779
|
-
}
|
|
3780
|
-
else this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
|
|
3781
|
-
}
|
|
3782
|
-
else if(p) {
|
|
3783
|
-
if(p.width && p.height) this.context.drawImage(img,p.left,p.top,p.width,p.height);
|
|
3784
|
-
else if(p.width) this.context.drawImage(img,p.left,p.top,p.width,img.height);
|
|
3785
|
-
else if(p.height) this.context.drawImage(img,p.left,p.top,img.width,p.height);
|
|
3786
|
-
else this.context.drawImage(img,p.left,p.top);
|
|
3759
|
+
if(this.graph.isWXMiniApp && this.graph.canvas) {
|
|
3760
|
+
// 图片对象
|
|
3761
|
+
const image = this.graph.canvas.createImage();
|
|
3762
|
+
// 图片加载完成回调
|
|
3763
|
+
image.onload = () => {
|
|
3764
|
+
// 将图片绘制到 canvas 上
|
|
3765
|
+
this.drawImg(image);
|
|
3766
|
+
};
|
|
3767
|
+
// 设置图片src
|
|
3768
|
+
image.src = img;
|
|
3787
3769
|
}
|
|
3788
3770
|
else {
|
|
3789
|
-
this.
|
|
3771
|
+
this.drawImg(img);
|
|
3790
3772
|
}
|
|
3791
3773
|
}
|
|
3792
3774
|
catch(e) {
|
|
@@ -3794,6 +3776,43 @@ class jmImage extends jmControl {
|
|
|
3794
3776
|
}
|
|
3795
3777
|
}
|
|
3796
3778
|
|
|
3779
|
+
// 绘制
|
|
3780
|
+
drawImg(img) {
|
|
3781
|
+
let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
3782
|
+
if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
|
|
3783
|
+
let p = this.getLocation();
|
|
3784
|
+
p.left += bounds.left;
|
|
3785
|
+
p.top += bounds.top;
|
|
3786
|
+
|
|
3787
|
+
let sp = this.sourcePosition;
|
|
3788
|
+
let sw = this.sourceWidth;
|
|
3789
|
+
let sh = this.sourceHeight;
|
|
3790
|
+
|
|
3791
|
+
if(sp || typeof sw != 'undefined' || typeof sh != 'undefined') {
|
|
3792
|
+
if(typeof sw == 'undefined') sw= p.width || img.width || 0;
|
|
3793
|
+
if(typeof sh == 'undefined') sh= p.height || img.height || 0;
|
|
3794
|
+
sp = sp || {x:0, y:0};
|
|
3795
|
+
|
|
3796
|
+
if(p.width && p.height) this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,p.height);
|
|
3797
|
+
else if(p.width) {
|
|
3798
|
+
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,sh);
|
|
3799
|
+
}
|
|
3800
|
+
else if(p.height) {
|
|
3801
|
+
this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
|
|
3802
|
+
}
|
|
3803
|
+
else this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
|
|
3804
|
+
}
|
|
3805
|
+
else if(p) {
|
|
3806
|
+
if(p.width && p.height) this.context.drawImage(img,p.left,p.top,p.width,p.height);
|
|
3807
|
+
else if(p.width) this.context.drawImage(img,p.left,p.top,p.width,img.height);
|
|
3808
|
+
else if(p.height) this.context.drawImage(img,p.left,p.top,img.width,p.height);
|
|
3809
|
+
else this.context.drawImage(img,p.left,p.top);
|
|
3810
|
+
}
|
|
3811
|
+
else {
|
|
3812
|
+
this.context.drawImage(img);
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3797
3816
|
/**
|
|
3798
3817
|
* 获取当前控件的边界
|
|
3799
3818
|
*
|
|
@@ -3829,7 +3848,7 @@ class jmImage extends jmControl {
|
|
|
3829
3848
|
else if(src && src.src) {
|
|
3830
3849
|
this.__img = src;
|
|
3831
3850
|
}
|
|
3832
|
-
else if(document && document.createElement) {
|
|
3851
|
+
else if(typeof document !== 'undefined' && document.createElement) {
|
|
3833
3852
|
this.__img = document.createElement('img');
|
|
3834
3853
|
if(src && typeof src == 'string') this.__img.src = src;
|
|
3835
3854
|
}
|
|
@@ -4398,9 +4417,9 @@ class jmEvents {
|
|
|
4398
4417
|
};
|
|
4399
4418
|
|
|
4400
4419
|
// 销毁
|
|
4401
|
-
|
|
4402
|
-
this.mouseHandler.
|
|
4403
|
-
this.keyHandler.
|
|
4420
|
+
destroy() {
|
|
4421
|
+
this.mouseHandler.destroy();
|
|
4422
|
+
this.keyHandler.destroy();
|
|
4404
4423
|
}
|
|
4405
4424
|
}
|
|
4406
4425
|
|
|
@@ -4518,7 +4537,7 @@ class jmMouseEvent {
|
|
|
4518
4537
|
}
|
|
4519
4538
|
|
|
4520
4539
|
// 销毁所有事件
|
|
4521
|
-
|
|
4540
|
+
destroy() {
|
|
4522
4541
|
for(let name in this.eventEvents) {
|
|
4523
4542
|
const event = this.eventEvents[name];
|
|
4524
4543
|
if(!event || !event.fun) continue;
|
|
@@ -4594,7 +4613,7 @@ class jmKeyEvent {
|
|
|
4594
4613
|
}
|
|
4595
4614
|
|
|
4596
4615
|
// 销毁所有事件
|
|
4597
|
-
|
|
4616
|
+
destroy() {
|
|
4598
4617
|
for(let name in this.eventEvents) {
|
|
4599
4618
|
const event = this.eventEvents[name];
|
|
4600
4619
|
if(!event || !event.fun) continue;
|
|
@@ -4640,9 +4659,8 @@ class jmGraph$1 extends jmControl {
|
|
|
4640
4659
|
this.util = this.utils = jmUtils;
|
|
4641
4660
|
|
|
4642
4661
|
//如果是小程序
|
|
4643
|
-
if(typeof wx != 'undefined' && wx.
|
|
4644
|
-
|
|
4645
|
-
canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
4662
|
+
if(typeof wx != 'undefined' && wx.canIUse && wx.canIUse('canvas')) {
|
|
4663
|
+
if(typeof canvas === 'string') canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
4646
4664
|
this.isWXMiniApp = true;// 微信小程序平台
|
|
4647
4665
|
}
|
|
4648
4666
|
else {
|
|
@@ -4663,10 +4681,10 @@ class jmGraph$1 extends jmControl {
|
|
|
4663
4681
|
}
|
|
4664
4682
|
else {
|
|
4665
4683
|
this.container = canvas.parentElement;
|
|
4666
|
-
}
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
this.
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
this.canvas = canvas;
|
|
4687
|
+
this.context = canvas.getContext('2d');
|
|
4670
4688
|
this.__init(callback);
|
|
4671
4689
|
}
|
|
4672
4690
|
|
|
@@ -4717,16 +4735,19 @@ class jmGraph$1 extends jmControl {
|
|
|
4717
4735
|
// 重置canvas大小,并判断高清屏,画图先放大二倍
|
|
4718
4736
|
resize(w, h) {
|
|
4719
4737
|
|
|
4720
|
-
|
|
4721
|
-
if
|
|
4738
|
+
let scale = typeof window != 'undefined' && window.devicePixelRatio > 1? window.devicePixelRatio : 1;
|
|
4739
|
+
if(this.isWXMiniApp) {
|
|
4740
|
+
scale = wx.getSystemInfoSync().pixelRatio || 1;
|
|
4741
|
+
}
|
|
4742
|
+
else if (scale > 1) {
|
|
4722
4743
|
this.__normalSize = this.__normalSize || { width: 0, height: 0};
|
|
4723
4744
|
w = w || this.__normalSize.width || this.width, h = h || this.__normalSize.height || this.height;
|
|
4724
4745
|
|
|
4725
4746
|
if(w) this.__normalSize.width = w;
|
|
4726
4747
|
if(h) this.__normalSize.height = h;
|
|
4727
|
-
|
|
4728
|
-
this.canvas.style.width = w + "px";
|
|
4729
|
-
this.canvas.style.height = h + "px";
|
|
4748
|
+
|
|
4749
|
+
this.canvas.style && (this.canvas.style.width = w + "px");
|
|
4750
|
+
this.canvas.style && (this.canvas.style.height = h + "px");
|
|
4730
4751
|
this.canvas.height = h * scale;
|
|
4731
4752
|
this.canvas.width = w *scale;
|
|
4732
4753
|
this.context.scale(scale, scale);
|
|
@@ -5093,7 +5114,7 @@ class jmGraph$1 extends jmControl {
|
|
|
5093
5114
|
this.___isAutoRefreshing = true;
|
|
5094
5115
|
|
|
5095
5116
|
function update() {
|
|
5096
|
-
if(self.
|
|
5117
|
+
if(self.destroyed) {
|
|
5097
5118
|
self.___isAutoRefreshing = false;
|
|
5098
5119
|
return;// 已销毁
|
|
5099
5120
|
}
|
|
@@ -5108,9 +5129,9 @@ class jmGraph$1 extends jmControl {
|
|
|
5108
5129
|
}
|
|
5109
5130
|
|
|
5110
5131
|
// 销毁当前对象
|
|
5111
|
-
|
|
5112
|
-
this.eventHandler.
|
|
5113
|
-
this.
|
|
5132
|
+
destroy() {
|
|
5133
|
+
this.eventHandler.destroy();
|
|
5134
|
+
this.destroyed = true;// 标记已销毁
|
|
5114
5135
|
}
|
|
5115
5136
|
}
|
|
5116
5137
|
|
|
@@ -5374,7 +5395,6 @@ var defaultStyle = {
|
|
|
5374
5395
|
zIndex: 17,
|
|
5375
5396
|
cursor: 'default',
|
|
5376
5397
|
close: true,
|
|
5377
|
-
opacity: 0.8,
|
|
5378
5398
|
shadow: {
|
|
5379
5399
|
x: 1,
|
|
5380
5400
|
y: 1,
|
|
@@ -5403,7 +5423,34 @@ var defaultStyle = {
|
|
|
5403
5423
|
zIndex: 11,
|
|
5404
5424
|
cursor: 'default',
|
|
5405
5425
|
close: true,
|
|
5406
|
-
|
|
5426
|
+
shadow: {
|
|
5427
|
+
x: 1,
|
|
5428
|
+
y: 1,
|
|
5429
|
+
blur: 2,
|
|
5430
|
+
color: '#ccc'
|
|
5431
|
+
}
|
|
5432
|
+
},
|
|
5433
|
+
radar: {
|
|
5434
|
+
normal: {
|
|
5435
|
+
zIndex: 11,
|
|
5436
|
+
cursor: 'default',
|
|
5437
|
+
opacity: 0.8
|
|
5438
|
+
},
|
|
5439
|
+
hover: {
|
|
5440
|
+
//zIndex: 100,
|
|
5441
|
+
opacity: 1,
|
|
5442
|
+
cursor: 'pointer'
|
|
5443
|
+
},
|
|
5444
|
+
margin: {
|
|
5445
|
+
left: 10,
|
|
5446
|
+
top: 10,
|
|
5447
|
+
right: 10,
|
|
5448
|
+
bottom: 10
|
|
5449
|
+
},
|
|
5450
|
+
lineWidth: 1,
|
|
5451
|
+
zIndex: 11,
|
|
5452
|
+
cursor: 'default',
|
|
5453
|
+
close: true,
|
|
5407
5454
|
shadow: {
|
|
5408
5455
|
x: 1,
|
|
5409
5456
|
y: 1,
|
|
@@ -5457,6 +5504,8 @@ class jmAxis extends jmArrowLine {
|
|
|
5457
5504
|
|
|
5458
5505
|
_defineProperty(this, "scalePoints", []);
|
|
5459
5506
|
|
|
5507
|
+
_defineProperty(this, "labels", []);
|
|
5508
|
+
|
|
5460
5509
|
this.arrowVisible = !!options.arrowVisible;
|
|
5461
5510
|
this.zeroBase = options.zeroBase || false;
|
|
5462
5511
|
this.labelCount = options.labelCount || 5;
|
|
@@ -5470,6 +5519,8 @@ class jmAxis extends jmArrowLine {
|
|
|
5470
5519
|
|
|
5471
5520
|
this.field = options.field || '';
|
|
5472
5521
|
this.index = options.index || 0;
|
|
5522
|
+
this.gridLines = []; // 线条数组
|
|
5523
|
+
|
|
5473
5524
|
this.init(options);
|
|
5474
5525
|
} // 初始化一些参数
|
|
5475
5526
|
// 这个函数可能会重入。
|
|
@@ -5479,6 +5530,8 @@ class jmAxis extends jmArrowLine {
|
|
|
5479
5530
|
options = options || {}; // 深度组件默认样式
|
|
5480
5531
|
|
|
5481
5532
|
if (options.style) this.graph.utils.clone(options.style, this.style, true);
|
|
5533
|
+
this.field = options.field || this.field || '';
|
|
5534
|
+
this.radarOption = options.radarOption;
|
|
5482
5535
|
|
|
5483
5536
|
if (this.type == 'x') {
|
|
5484
5537
|
if (typeof options.maxXValue !== 'undefined') this.maxValue = options.maxXValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
@@ -5507,6 +5560,24 @@ class jmAxis extends jmArrowLine {
|
|
|
5507
5560
|
|
|
5508
5561
|
set data(d) {
|
|
5509
5562
|
this.graph.data = d;
|
|
5563
|
+
} // 生成绘制点,
|
|
5564
|
+
// 重写原函数
|
|
5565
|
+
|
|
5566
|
+
|
|
5567
|
+
initPoints() {
|
|
5568
|
+
// 如果是雷达图
|
|
5569
|
+
if (this.radarOption && this.type === 'x') {
|
|
5570
|
+
this.points = [];
|
|
5571
|
+
|
|
5572
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5573
|
+
axis.end && this.points.push(axis.end);
|
|
5574
|
+
}
|
|
5575
|
+
|
|
5576
|
+
this.points.push(this.points[0]);
|
|
5577
|
+
return this.points;
|
|
5578
|
+
} else {
|
|
5579
|
+
return super.initPoints();
|
|
5580
|
+
}
|
|
5510
5581
|
}
|
|
5511
5582
|
/**
|
|
5512
5583
|
* 计算当前轴的位置
|
|
@@ -5522,7 +5593,40 @@ class jmAxis extends jmArrowLine {
|
|
|
5522
5593
|
case 'x':
|
|
5523
5594
|
{
|
|
5524
5595
|
//初始化显示标签个数
|
|
5525
|
-
this.labelCount = this.style.xLabel.count || 5;
|
|
5596
|
+
this.labelCount = this.style.xLabel.count || 5; // 如果是雷达图,则画栅格线
|
|
5597
|
+
|
|
5598
|
+
if (this.radarOption) {
|
|
5599
|
+
if (this.style.grid && this.style.grid.x) {
|
|
5600
|
+
for (let i = 1; i < this.labelCount + 1; i++) {
|
|
5601
|
+
const points = [];
|
|
5602
|
+
const curRadius = this.radarOption.radius / this.labelCount * i;
|
|
5603
|
+
|
|
5604
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5605
|
+
if (!axis.radarOption) continue;
|
|
5606
|
+
const point = {};
|
|
5607
|
+
point.x = axis.radarOption.center.x + axis.radarOption.cos * curRadius + bounds.left;
|
|
5608
|
+
point.y = axis.radarOption.center.y - axis.radarOption.sin * curRadius + bounds.top;
|
|
5609
|
+
points.push(point);
|
|
5610
|
+
} // 画栅格线
|
|
5611
|
+
|
|
5612
|
+
|
|
5613
|
+
for (let j = 0; j < points.length; j++) {
|
|
5614
|
+
const start = points[j];
|
|
5615
|
+
const end = points[j + 1] || points[0];
|
|
5616
|
+
const gridLine = this.graph.createShape('line', {
|
|
5617
|
+
start,
|
|
5618
|
+
end,
|
|
5619
|
+
style: this.style.grid
|
|
5620
|
+
});
|
|
5621
|
+
this.parent.children.add(gridLine);
|
|
5622
|
+
this.gridLines.push(gridLine);
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
|
|
5627
|
+
break;
|
|
5628
|
+
}
|
|
5629
|
+
|
|
5526
5630
|
this.start.x = bounds.left;
|
|
5527
5631
|
this.start.y = bounds.bottom;
|
|
5528
5632
|
this.end.x = bounds.right;
|
|
@@ -5541,21 +5645,30 @@ class jmAxis extends jmArrowLine {
|
|
|
5541
5645
|
|
|
5542
5646
|
case 'y':
|
|
5543
5647
|
{
|
|
5544
|
-
|
|
5545
|
-
|
|
5648
|
+
//初始化显示标签个数
|
|
5649
|
+
this.labelCount = this.style.yLabel.count || 5;
|
|
5650
|
+
const index = this.index || 1; // 如果是雷达图,则画发散的线
|
|
5651
|
+
|
|
5652
|
+
if (this.radarOption) {
|
|
5653
|
+
this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left;
|
|
5654
|
+
this.end.y = this.radarOption.center.y - this.radarOption.sin * this.radarOption.radius + bounds.top;
|
|
5655
|
+
this.start.x = this.radarOption.center.x + bounds.left;
|
|
5656
|
+
this.start.y = this.radarOption.center.y + bounds.top;
|
|
5657
|
+
} else {
|
|
5658
|
+
let xoffset = bounds.left; //多Y轴时,第二个为右边第一轴,其它的依此递推
|
|
5546
5659
|
|
|
5547
|
-
|
|
5660
|
+
if (index == 2) {
|
|
5661
|
+
xoffset = bounds.right;
|
|
5662
|
+
} else if (index > 2) {
|
|
5663
|
+
xoffset = this.graph.yAxises[index - 1].start.x + this.graph.yAxises[index - 1].width + 10;
|
|
5664
|
+
}
|
|
5548
5665
|
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5666
|
+
this.start.x = xoffset;
|
|
5667
|
+
this.start.y = bounds.bottom;
|
|
5668
|
+
this.end.x = this.start.x;
|
|
5669
|
+
this.end.y = bounds.top;
|
|
5553
5670
|
}
|
|
5554
5671
|
|
|
5555
|
-
this.start.x = xoffset;
|
|
5556
|
-
this.start.y = bounds.bottom;
|
|
5557
|
-
this.end.x = this.start.x;
|
|
5558
|
-
this.end.y = bounds.top;
|
|
5559
5672
|
break;
|
|
5560
5673
|
}
|
|
5561
5674
|
}
|
|
@@ -5577,11 +5690,12 @@ class jmAxis extends jmArrowLine {
|
|
|
5577
5690
|
|
|
5578
5691
|
|
|
5579
5692
|
createLabel() {
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5693
|
+
if (this.visible === false) return; // 雷达图的标签单独处理
|
|
5694
|
+
|
|
5695
|
+
if (this.radarOption) {
|
|
5696
|
+
return this.createRadarLabel();
|
|
5697
|
+
} //如果是?X轴则执行X轴标签生成
|
|
5698
|
+
|
|
5585
5699
|
|
|
5586
5700
|
if (this.type == 'x') {
|
|
5587
5701
|
this.createXLabel();
|
|
@@ -5701,13 +5815,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5701
5815
|
|
|
5702
5816
|
let count = this.labelCount;
|
|
5703
5817
|
const mm = max - min;
|
|
5704
|
-
|
|
5705
|
-
count = mm;
|
|
5706
|
-
}*/
|
|
5707
|
-
// mm 放大10000倍,这里结果也需要除于10000
|
|
5708
|
-
|
|
5709
|
-
let pervalue = mm / count || 1; //if(pervalue > 1 || pervalue < -1) pervalue = Math.floor(pervalue);
|
|
5710
|
-
|
|
5818
|
+
let pervalue = mm / count || 1;
|
|
5711
5819
|
const format = this.option.format || this.format;
|
|
5712
5820
|
const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
|
|
5713
5821
|
const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
|
|
@@ -5718,7 +5826,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5718
5826
|
if (p > max || i === count) p = max;
|
|
5719
5827
|
const h = (p - min) * step; // 当前点的偏移高度
|
|
5720
5828
|
|
|
5721
|
-
const label = this.graph.
|
|
5829
|
+
const label = this.graph.createShape('label', {
|
|
5722
5830
|
style: this.style.yLabel
|
|
5723
5831
|
});
|
|
5724
5832
|
label.text = format.call(this, p, label); // 格式化label
|
|
@@ -5751,7 +5859,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5751
5859
|
y: offy + this.end.y
|
|
5752
5860
|
}); // 指定要显示网格
|
|
5753
5861
|
|
|
5754
|
-
if (this.style.grid && this.style.grid.x) {
|
|
5862
|
+
if (!this.radarOption && this.style.grid && this.style.grid.x) {
|
|
5755
5863
|
// 它的坐标是相对于轴的,所以Y轴会用负的区域高度
|
|
5756
5864
|
const line = this.graph.createShape('line', {
|
|
5757
5865
|
start: {
|
|
@@ -5814,6 +5922,42 @@ class jmAxis extends jmArrowLine {
|
|
|
5814
5922
|
}
|
|
5815
5923
|
}
|
|
5816
5924
|
}
|
|
5925
|
+
/**
|
|
5926
|
+
* 生成雷达图的Y轴标签
|
|
5927
|
+
*/
|
|
5928
|
+
|
|
5929
|
+
|
|
5930
|
+
createRadarLabel() {
|
|
5931
|
+
const format = this.option.format;
|
|
5932
|
+
const bounds = this.graph.chartArea.getBounds(); // 获取画图区域
|
|
5933
|
+
|
|
5934
|
+
const self = this;
|
|
5935
|
+
const label = this.graph.createShape('label', {
|
|
5936
|
+
style: this.style.yLabel,
|
|
5937
|
+
position: function () {
|
|
5938
|
+
// 因为axis是相对于chart的,而center是相对于chartArea的,所以要计算axis位置相对于chartArea来比较
|
|
5939
|
+
const pos = {
|
|
5940
|
+
x: self.end.x - bounds.left,
|
|
5941
|
+
y: self.end.y - bounds.top
|
|
5942
|
+
};
|
|
5943
|
+
const size = this.testSize();
|
|
5944
|
+
|
|
5945
|
+
if (pos.x < self.radarOption.center.x) {
|
|
5946
|
+
pos.x -= size.width;
|
|
5947
|
+
}
|
|
5948
|
+
|
|
5949
|
+
if (pos.y < self.radarOption.center.y) {
|
|
5950
|
+
pos.y -= size.height;
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5953
|
+
return pos;
|
|
5954
|
+
}
|
|
5955
|
+
});
|
|
5956
|
+
label.text = typeof format === 'function' ? format.call(this, label) : this.field; // 格式化label
|
|
5957
|
+
|
|
5958
|
+
this.labels.push(label);
|
|
5959
|
+
this.graph.chartArea.children.add(label);
|
|
5960
|
+
}
|
|
5817
5961
|
/**
|
|
5818
5962
|
* 获取当前轴所占宽
|
|
5819
5963
|
*
|
|
@@ -5961,6 +6105,18 @@ class jmAxis extends jmArrowLine {
|
|
|
5961
6105
|
clear() {
|
|
5962
6106
|
this._min = null;
|
|
5963
6107
|
this._max = null;
|
|
6108
|
+
this.children.each((i, c) => {
|
|
6109
|
+
c.remove();
|
|
6110
|
+
}, true); // 清空栅格线
|
|
6111
|
+
|
|
6112
|
+
this.gridLines && this.gridLines.forEach(line => {
|
|
6113
|
+
line.remove();
|
|
6114
|
+
});
|
|
6115
|
+
this.labels && this.labels.forEach(label => {
|
|
6116
|
+
label.remove();
|
|
6117
|
+
});
|
|
6118
|
+
this.labels = [];
|
|
6119
|
+
this.gridLines = [];
|
|
5964
6120
|
}
|
|
5965
6121
|
/**
|
|
5966
6122
|
* 计算当前轴的单位偏移量
|
|
@@ -5972,7 +6128,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5972
6128
|
|
|
5973
6129
|
step() {
|
|
5974
6130
|
if (this.type == 'x') {
|
|
5975
|
-
const w = this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
6131
|
+
const w = this.radarOption ? this.radarOption.radius : this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
5976
6132
|
//也就是起始位从一个单位开始
|
|
5977
6133
|
|
|
5978
6134
|
if (this.graph.style.layout == 'inside') {
|
|
@@ -5988,7 +6144,7 @@ class jmAxis extends jmArrowLine {
|
|
|
5988
6144
|
|
|
5989
6145
|
return w / tmp;
|
|
5990
6146
|
} else if (this.type == 'y') {
|
|
5991
|
-
const h = this.height;
|
|
6147
|
+
const h = this.radarOption ? this.radarOption.radius : this.height;
|
|
5992
6148
|
|
|
5993
6149
|
switch (this.dataType) {
|
|
5994
6150
|
case 'string':
|
|
@@ -6083,28 +6239,9 @@ jmLegend.prototype.append = function (series, shape, options = {}) {
|
|
|
6083
6239
|
}
|
|
6084
6240
|
|
|
6085
6241
|
panel.height = shape.height; //执行进入事件
|
|
6086
|
-
//触动图例后加粗显示图
|
|
6087
|
-
|
|
6088
|
-
/*const hover = options.hover || function() {
|
|
6089
|
-
//应用图的动态样式
|
|
6090
|
-
//Object.assign(series.style, series.style.hover);
|
|
6091
|
-
|
|
6092
|
-
//Object.assign(this.style, this.style.hover || {});
|
|
6093
|
-
|
|
6094
|
-
//series.graph.refresh();
|
|
6095
|
-
};
|
|
6096
|
-
panel.bind('mouseover', hover);
|
|
6097
|
-
//执行离开
|
|
6098
|
-
const leave = options.leave || function() {
|
|
6099
|
-
//应用图的普通样式
|
|
6100
|
-
//Object.assign(series.style, series.style.normal);
|
|
6101
|
-
|
|
6102
|
-
//Object.assign(this.style, this.style.normal || {});
|
|
6103
|
-
//jmUtils.apply(this.series.style.normal,this.series.style);
|
|
6104
|
-
//series.graph.refresh();
|
|
6105
|
-
};
|
|
6106
|
-
panel.bind('mouseleave', leave);*/
|
|
6107
6242
|
|
|
6243
|
+
options.hover && panel.bind('mouseover touchover', options.hover);
|
|
6244
|
+
options.leave && panel.bind('mouseleave touchleave', options.leave);
|
|
6108
6245
|
const legendPosition = this.legendPosition || this.style.legendPosition || 'right';
|
|
6109
6246
|
|
|
6110
6247
|
if (legendPosition == 'top' || legendPosition == 'bottom') {
|
|
@@ -6252,7 +6389,7 @@ class jmSeries extends jmPath {
|
|
|
6252
6389
|
}); // 初始化一些参数, 因为这里有多个Y轴的可能,所以每次都需要重调一次init
|
|
6253
6390
|
|
|
6254
6391
|
this.yAxis.init({
|
|
6255
|
-
field: this.field,
|
|
6392
|
+
field: Array.isArray(this.field) ? this.field[0] : this.field,
|
|
6256
6393
|
minYValue: options.minYValue,
|
|
6257
6394
|
maxYValue: options.maxYValue
|
|
6258
6395
|
});
|
|
@@ -6307,6 +6444,11 @@ class jmSeries extends jmPath {
|
|
|
6307
6444
|
if (dataChanged) this.___animateCounter = 0; // 数据改变。动画重新开始
|
|
6308
6445
|
} else {
|
|
6309
6446
|
this.dataPoints = this.createPoints(...args);
|
|
6447
|
+
} // 执行初始化函数回调
|
|
6448
|
+
|
|
6449
|
+
|
|
6450
|
+
if (this.option && this.option.onInit) {
|
|
6451
|
+
this.option.onInit.apply(this, args);
|
|
6310
6452
|
}
|
|
6311
6453
|
|
|
6312
6454
|
return {
|
|
@@ -6375,12 +6517,12 @@ class jmSeries extends jmPath {
|
|
|
6375
6517
|
|
|
6376
6518
|
while (shape = this.shapes.shift()) {
|
|
6377
6519
|
shape && shape.remove();
|
|
6378
|
-
}
|
|
6379
|
-
|
|
6520
|
+
}
|
|
6380
6521
|
|
|
6381
|
-
this.createLegend();
|
|
6382
6522
|
this.initAxisValue(); // 处理最大值最小值
|
|
6523
|
+
//生成图例 这里要放到shape清理后面
|
|
6383
6524
|
|
|
6525
|
+
this.createLegend();
|
|
6384
6526
|
return this.chartInfo = {
|
|
6385
6527
|
xAxis: this.xAxis,
|
|
6386
6528
|
yAxis: this.yAxis
|
|
@@ -6445,7 +6587,8 @@ class jmSeries extends jmPath {
|
|
|
6445
6587
|
|
|
6446
6588
|
p.x = xstep * i + this.xAxis.labelStart;
|
|
6447
6589
|
|
|
6448
|
-
for (
|
|
6590
|
+
for (let j = 0; j < fields.length; j++) {
|
|
6591
|
+
const f = fields[j];
|
|
6449
6592
|
const yv = s[f];
|
|
6450
6593
|
p.yLabel = p.yValue = yv; // 高度
|
|
6451
6594
|
|
|
@@ -6506,6 +6649,7 @@ class jmSeries extends jmPath {
|
|
|
6506
6649
|
style
|
|
6507
6650
|
});
|
|
6508
6651
|
this.graph.legend.append(this, shape);
|
|
6652
|
+
return shape;
|
|
6509
6653
|
} // 生成柱图的标注
|
|
6510
6654
|
|
|
6511
6655
|
|
|
@@ -6771,15 +6915,18 @@ class jmStackBarSeries extends jmBarSeries {
|
|
|
6771
6915
|
|
|
6772
6916
|
for (let index = 0; index < point.points.length; index++) {
|
|
6773
6917
|
const style = this.graph.utils.clone(this.style);
|
|
6918
|
+
const p = point.points[index];
|
|
6774
6919
|
|
|
6775
6920
|
if (style.color && typeof style.color === 'function') {
|
|
6776
|
-
style.fill = style.color.call(this,
|
|
6921
|
+
style.fill = style.color.call(this, {
|
|
6922
|
+
index,
|
|
6923
|
+
point: p
|
|
6924
|
+
});
|
|
6777
6925
|
} else {
|
|
6778
6926
|
style.fill = this.graph.getColor(index);
|
|
6779
6927
|
}
|
|
6780
6928
|
|
|
6781
6929
|
const sp = this.addShape(this.graph.createPath(null, style));
|
|
6782
|
-
const p = point.points[index];
|
|
6783
6930
|
let startY = topStartY;
|
|
6784
6931
|
if (p.yValue < this.baseYValue) startY = bottomStartY; //首先确定p1和p4,因为他们是底脚。会固定
|
|
6785
6932
|
|
|
@@ -6851,7 +6998,8 @@ class jmStackBarSeries extends jmBarSeries {
|
|
|
6851
6998
|
for (const row of this.data) {
|
|
6852
6999
|
let max, min;
|
|
6853
7000
|
|
|
6854
|
-
for (
|
|
7001
|
+
for (let i = 0; i < fields.length; i++) {
|
|
7002
|
+
const f = fields[i];
|
|
6855
7003
|
const v = Number(row[f]);
|
|
6856
7004
|
if (typeof max === 'undefined') max = v;else {
|
|
6857
7005
|
if (v < 0 || max < 0) max = Math.max(max, v);else {
|
|
@@ -6913,7 +7061,7 @@ class jmPieSeries extends jmSeries {
|
|
|
6913
7061
|
x: this.graph.chartArea.width / 2,
|
|
6914
7062
|
y: this.graph.chartArea.height / 2
|
|
6915
7063
|
};
|
|
6916
|
-
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); //生成描点位
|
|
7064
|
+
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); //生成描点位
|
|
6917
7065
|
// super.init会把参数透传给 createPoints
|
|
6918
7066
|
|
|
6919
7067
|
const {
|
|
@@ -7005,7 +7153,8 @@ class jmPieSeries extends jmSeries {
|
|
|
7005
7153
|
// 每个数值点比
|
|
7006
7154
|
style: this.graph.utils.clone(this.style),
|
|
7007
7155
|
anticlockwise
|
|
7008
|
-
};
|
|
7156
|
+
};
|
|
7157
|
+
points.push(p); //p.style.color = this.graph.getColor(index);
|
|
7009
7158
|
|
|
7010
7159
|
if (p.style.color && typeof p.style.color === 'function') {
|
|
7011
7160
|
p.style.fill = p.style.color.call(this, p);
|
|
@@ -7086,34 +7235,34 @@ class jmPieSeries extends jmSeries {
|
|
|
7086
7235
|
|
|
7087
7236
|
if (this.option.onClick) {
|
|
7088
7237
|
p.shape.on('click', e => {
|
|
7089
|
-
this.option.onClick.call(this, p, e);
|
|
7238
|
+
return this.option.onClick.call(this, p, e);
|
|
7090
7239
|
});
|
|
7091
7240
|
}
|
|
7092
7241
|
|
|
7093
7242
|
if (this.option.onOver) {
|
|
7094
7243
|
p.shape.on('mouseover touchover', e => {
|
|
7095
|
-
this.option.onOver.call(this, p, e);
|
|
7244
|
+
return this.option.onOver.call(this, p, e);
|
|
7096
7245
|
});
|
|
7097
7246
|
}
|
|
7098
7247
|
|
|
7099
7248
|
if (this.option.onLeave) {
|
|
7100
7249
|
p.shape.on('mouseleave touchleave', e => {
|
|
7101
|
-
this.option.onLeave.call(this, p, e);
|
|
7250
|
+
return this.option.onLeave.call(this, p, e);
|
|
7102
7251
|
});
|
|
7103
7252
|
}
|
|
7104
7253
|
|
|
7105
7254
|
this.createLabel(p); // 生成标签
|
|
7106
|
-
|
|
7255
|
+
// 生成标点的回调
|
|
7107
7256
|
|
|
7108
|
-
|
|
7109
|
-
|
|
7257
|
+
this.emit('onPointCreated', p);
|
|
7258
|
+
}
|
|
7110
7259
|
|
|
7111
|
-
|
|
7260
|
+
index++;
|
|
7112
7261
|
}
|
|
7113
7262
|
}
|
|
7114
7263
|
|
|
7115
7264
|
return points;
|
|
7116
|
-
} //
|
|
7265
|
+
} // 生成图的标注
|
|
7117
7266
|
|
|
7118
7267
|
|
|
7119
7268
|
createLabel(point) {
|
|
@@ -7137,7 +7286,7 @@ class jmPieSeries extends jmSeries {
|
|
|
7137
7286
|
}; // 动态计算位置
|
|
7138
7287
|
|
|
7139
7288
|
const parentRect = this.parent.getBounds(); //const rect = this.getBounds.call(this.parent);
|
|
7140
|
-
//
|
|
7289
|
+
// 圆弧的中间位,离圆心最近和最远的二个点
|
|
7141
7290
|
|
|
7142
7291
|
let centerMaxPoint = this.parent.points[Math.floor(this.parent.points.length / 2)];
|
|
7143
7292
|
let centerMinPoint = this.parent.center; // 如果是空心圆,则要计算 1/4 和 3/4位的点。顺时针和逆时针二个点大小不一样,这里只取,大小计算时处理
|
|
@@ -7179,7 +7328,7 @@ jmPieSeries.prototype.createLegend = function () {
|
|
|
7179
7328
|
const points = this.createPoints();
|
|
7180
7329
|
if (!points || !points.length) return;
|
|
7181
7330
|
|
|
7182
|
-
for (let k
|
|
7331
|
+
for (let k = 0; k < points.length; k++) {
|
|
7183
7332
|
const p = points[k];
|
|
7184
7333
|
if (!p) continue; //生成图例前的图标
|
|
7185
7334
|
|
|
@@ -7197,23 +7346,315 @@ jmPieSeries.prototype.createLegend = function () {
|
|
|
7197
7346
|
|
|
7198
7347
|
this.graph.legend.append(this, shape, {
|
|
7199
7348
|
name: this.legendLabel,
|
|
7200
|
-
hover: function () {
|
|
7201
|
-
//var sp = this.children.get(0);
|
|
7202
|
-
//应用图的动态样式
|
|
7203
|
-
Object.assign(this.targetShape.style, this.targetShape.style.hover);
|
|
7204
|
-
Object.assign(this.style, this.style.hover);
|
|
7205
|
-
},
|
|
7206
|
-
leave: function () {
|
|
7207
|
-
//var sp = this.children.get(0);
|
|
7208
|
-
//应用图的普通样式
|
|
7209
|
-
Object.assign(this.targetShape.style, this.targetShape.style.normal);
|
|
7210
|
-
Object.assign(this.style, this.style.normal);
|
|
7211
|
-
},
|
|
7212
7349
|
data: this.data[k]
|
|
7213
7350
|
});
|
|
7214
7351
|
}
|
|
7215
7352
|
};
|
|
7216
7353
|
|
|
7354
|
+
/**
|
|
7355
|
+
* 雷达图
|
|
7356
|
+
*
|
|
7357
|
+
* @class jmRadarSeries
|
|
7358
|
+
* @module jmChart
|
|
7359
|
+
* @param {jmChart} chart 当前图表
|
|
7360
|
+
* @param {array} mappings 图形字段映射
|
|
7361
|
+
* @param {style} style 样式
|
|
7362
|
+
*/
|
|
7363
|
+
//构造函数
|
|
7364
|
+
|
|
7365
|
+
class jmRadarSeries extends jmSeries {
|
|
7366
|
+
constructor(options) {
|
|
7367
|
+
super(options);
|
|
7368
|
+
} // 重新生成轴,雷达图只需要Y轴即可
|
|
7369
|
+
|
|
7370
|
+
|
|
7371
|
+
createAxises(center, radius) {
|
|
7372
|
+
this.axises = [this.yAxis];
|
|
7373
|
+
const yCount = this.field.length;
|
|
7374
|
+
if (!yCount) return; //每个维度点的角度
|
|
7375
|
+
|
|
7376
|
+
const rotateStep = Math.PI * 2 / yCount; // 清空除了一个默认外的所有Y轴
|
|
7377
|
+
|
|
7378
|
+
for (let index in this.graph.yAxises) {
|
|
7379
|
+
const axis = this.graph.yAxises[index];
|
|
7380
|
+
if (!axis || axis === this.yAxis) continue;
|
|
7381
|
+
axis.remove();
|
|
7382
|
+
delete this.graph.yAxises[index];
|
|
7383
|
+
}
|
|
7384
|
+
|
|
7385
|
+
for (let index = 0; index < yCount; index++) {
|
|
7386
|
+
if (!this.field[index]) continue;
|
|
7387
|
+
let axis = this.yAxis; // 除了默认的y轴外,其它都重新生成
|
|
7388
|
+
|
|
7389
|
+
if (index > 0) {
|
|
7390
|
+
axis = this.graph.createYAxis({
|
|
7391
|
+
index: index + 1,
|
|
7392
|
+
format: this.option.yLabelFormat || this.graph.option.yLabelFormat
|
|
7393
|
+
});
|
|
7394
|
+
this.axises.push(axis);
|
|
7395
|
+
}
|
|
7396
|
+
|
|
7397
|
+
const rotate = Math.PI / 2 + rotateStep * index; //从向上90度开始
|
|
7398
|
+
|
|
7399
|
+
axis.init({
|
|
7400
|
+
field: this.field[index],
|
|
7401
|
+
radarOption: {
|
|
7402
|
+
center,
|
|
7403
|
+
radius,
|
|
7404
|
+
yCount,
|
|
7405
|
+
rotate: rotate,
|
|
7406
|
+
cos: Math.cos(rotate),
|
|
7407
|
+
sin: Math.sin(rotate)
|
|
7408
|
+
}
|
|
7409
|
+
});
|
|
7410
|
+
} // x轴初始化
|
|
7411
|
+
|
|
7412
|
+
|
|
7413
|
+
this.xAxis.init({
|
|
7414
|
+
radarOption: {
|
|
7415
|
+
center,
|
|
7416
|
+
radius,
|
|
7417
|
+
yCount,
|
|
7418
|
+
yAxises: this.axises
|
|
7419
|
+
}
|
|
7420
|
+
});
|
|
7421
|
+
return this.axises;
|
|
7422
|
+
} // 计算最大值和最小值,一般图形直接采用最大最小值即可,有些需要多值叠加
|
|
7423
|
+
|
|
7424
|
+
|
|
7425
|
+
initAxisValue() {
|
|
7426
|
+
this.center = {
|
|
7427
|
+
x: this.graph.chartArea.width / 2,
|
|
7428
|
+
y: this.graph.chartArea.height / 2
|
|
7429
|
+
};
|
|
7430
|
+
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);
|
|
7431
|
+
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7432
|
+
// 计算最大最小值
|
|
7433
|
+
// 当前需要先更新axis的边界值,轴好画图
|
|
7434
|
+
|
|
7435
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
7436
|
+
axises.forEach(axis => {
|
|
7437
|
+
const v = this.data[i][axis.field];
|
|
7438
|
+
axis.max(v);
|
|
7439
|
+
axis.min(v);
|
|
7440
|
+
});
|
|
7441
|
+
}
|
|
7442
|
+
} // 重新初始化图形
|
|
7443
|
+
|
|
7444
|
+
|
|
7445
|
+
init() {
|
|
7446
|
+
//生成描点位
|
|
7447
|
+
// super.init会把参数透传给 createPoints
|
|
7448
|
+
const {
|
|
7449
|
+
points,
|
|
7450
|
+
dataChanged
|
|
7451
|
+
} = this.initDataPoint(this.center, this.radius); // 是否正在动画中
|
|
7452
|
+
|
|
7453
|
+
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0);
|
|
7454
|
+
const aniCount = this.style.aniCount || 20;
|
|
7455
|
+
let aniIsEnd = true; // 当次是否结束动画
|
|
7456
|
+
|
|
7457
|
+
const len = points.length;
|
|
7458
|
+
const shapeMap = {};
|
|
7459
|
+
const self = this;
|
|
7460
|
+
|
|
7461
|
+
for (let i = 0; i < len; i++) {
|
|
7462
|
+
const p = points[i];
|
|
7463
|
+
let shape = shapeMap[p.index];
|
|
7464
|
+
|
|
7465
|
+
if (!shape) {
|
|
7466
|
+
shape = shapeMap[p.index] = this.graph.createShape('path', { ...p,
|
|
7467
|
+
style: p.style,
|
|
7468
|
+
points: []
|
|
7469
|
+
});
|
|
7470
|
+
this.addShape(shape); // 如果有点击事件
|
|
7471
|
+
|
|
7472
|
+
if (this.option.onClick) {
|
|
7473
|
+
shape.on('click', function (e) {
|
|
7474
|
+
return self.option.onClick.call(this, e);
|
|
7475
|
+
});
|
|
7476
|
+
}
|
|
7477
|
+
|
|
7478
|
+
if (this.option.onOver) {
|
|
7479
|
+
shape.on('mouseover touchover', function (e) {
|
|
7480
|
+
return self.option.onOver.call(this, e);
|
|
7481
|
+
});
|
|
7482
|
+
}
|
|
7483
|
+
|
|
7484
|
+
if (this.option.onLeave) {
|
|
7485
|
+
shape.on('mouseleave touchleave', function (e) {
|
|
7486
|
+
return self.option.onLeave.call(this, e);
|
|
7487
|
+
});
|
|
7488
|
+
}
|
|
7489
|
+
|
|
7490
|
+
this.createLegend(p);
|
|
7491
|
+
}
|
|
7492
|
+
|
|
7493
|
+
shape.zIndex += p.radius / this.radius; // 用每个轴占比做为排序号,这样占面积最大的排最底层
|
|
7494
|
+
|
|
7495
|
+
let point = null; // 在动画中,则一直刷新
|
|
7496
|
+
|
|
7497
|
+
if (isRunningAni) {
|
|
7498
|
+
let step = p.radius / aniCount * this.___animateCounter;
|
|
7499
|
+
|
|
7500
|
+
if (step >= p.radius) {
|
|
7501
|
+
step = p.radius;
|
|
7502
|
+
} else {
|
|
7503
|
+
aniIsEnd = false;
|
|
7504
|
+
}
|
|
7505
|
+
|
|
7506
|
+
point = { ...p,
|
|
7507
|
+
x: this.center.x + p.axis.radarOption.cos * step,
|
|
7508
|
+
y: this.center.y - p.axis.radarOption.sin * step
|
|
7509
|
+
};
|
|
7510
|
+
} else {
|
|
7511
|
+
point = p;
|
|
7512
|
+
}
|
|
7513
|
+
|
|
7514
|
+
shape.points.push(point);
|
|
7515
|
+
this.createLabel(point); // 生成标签
|
|
7516
|
+
} // 所有动画都完成,则清空计数器
|
|
7517
|
+
|
|
7518
|
+
|
|
7519
|
+
if (aniIsEnd) {
|
|
7520
|
+
this.___animateCounter = 0;
|
|
7521
|
+
} else {
|
|
7522
|
+
this.___animateCounter++; // next tick 再次刷新
|
|
7523
|
+
|
|
7524
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7525
|
+
this.needUpdate = true; //需要刷新
|
|
7526
|
+
});
|
|
7527
|
+
}
|
|
7528
|
+
}
|
|
7529
|
+
/**
|
|
7530
|
+
* 生成序列图描点
|
|
7531
|
+
*
|
|
7532
|
+
* @method createPoints
|
|
7533
|
+
*/
|
|
7534
|
+
|
|
7535
|
+
|
|
7536
|
+
createPoints(center, radius) {
|
|
7537
|
+
if (!this.data || !this.axises) return [];
|
|
7538
|
+
center = center || this.center;
|
|
7539
|
+
const points = [];
|
|
7540
|
+
|
|
7541
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
7542
|
+
const s = this.data[i];
|
|
7543
|
+
const style = this.graph.utils.clone(this.style);
|
|
7544
|
+
|
|
7545
|
+
if (style.color && typeof style.color === 'function') {
|
|
7546
|
+
style.stroke = style.color.call(this, {
|
|
7547
|
+
data: s,
|
|
7548
|
+
index: i
|
|
7549
|
+
});
|
|
7550
|
+
} else {
|
|
7551
|
+
style.stroke = this.graph.getColor(i);
|
|
7552
|
+
}
|
|
7553
|
+
|
|
7554
|
+
if (typeof style.fill === 'function') {
|
|
7555
|
+
style.fill = style.fill.call(this, style);
|
|
7556
|
+
} else {
|
|
7557
|
+
const color = this.graph.utils.hexToRGBA(style.stroke);
|
|
7558
|
+
style.fill = `rgba(${color.r},${color.g},${color.b}, 0.2)`;
|
|
7559
|
+
}
|
|
7560
|
+
|
|
7561
|
+
const shapePoints = [];
|
|
7562
|
+
|
|
7563
|
+
for (const axis of this.axises) {
|
|
7564
|
+
if (!axis || !axis.field) continue;
|
|
7565
|
+
const yv = s[axis.field];
|
|
7566
|
+
const p = {
|
|
7567
|
+
x: center.x,
|
|
7568
|
+
y: center.y,
|
|
7569
|
+
index: i,
|
|
7570
|
+
radius: 0,
|
|
7571
|
+
data: s,
|
|
7572
|
+
yValue: yv,
|
|
7573
|
+
yLabel: yv,
|
|
7574
|
+
style,
|
|
7575
|
+
axis
|
|
7576
|
+
};
|
|
7577
|
+
shapePoints.push(p); //如果Y值不存在。则此点无效,不画图
|
|
7578
|
+
|
|
7579
|
+
if (yv == null || typeof yv == 'undefined') {
|
|
7580
|
+
continue;
|
|
7581
|
+
}
|
|
7582
|
+
|
|
7583
|
+
p.radius = Math.abs(yv - axis.min()) * axis.step();
|
|
7584
|
+
p.x = center.x + axis.radarOption.cos * p.radius;
|
|
7585
|
+
p.y = center.y - axis.radarOption.sin * p.radius; // 生成标点的回调
|
|
7586
|
+
|
|
7587
|
+
this.emit('onPointCreated', p);
|
|
7588
|
+
}
|
|
7589
|
+
|
|
7590
|
+
points.push(...shapePoints);
|
|
7591
|
+
}
|
|
7592
|
+
|
|
7593
|
+
return points;
|
|
7594
|
+
} // 生成图的标注
|
|
7595
|
+
|
|
7596
|
+
|
|
7597
|
+
createLabel(point) {
|
|
7598
|
+
if (this.style.label && this.style.label.show === false) return;
|
|
7599
|
+
const text = this.option.itemLabelFormat ? this.option.itemLabelFormat.call(this, point) : point.yValue;
|
|
7600
|
+
if (!text) return; // v如果指定了为控件,则直接加入
|
|
7601
|
+
|
|
7602
|
+
if (text instanceof jmControl) {
|
|
7603
|
+
this.addShape(text);
|
|
7604
|
+
return text;
|
|
7605
|
+
}
|
|
7606
|
+
|
|
7607
|
+
const self = this;
|
|
7608
|
+
const label = this.graph.createShape('label', {
|
|
7609
|
+
style: this.style.label,
|
|
7610
|
+
text: text,
|
|
7611
|
+
point,
|
|
7612
|
+
position: function () {
|
|
7613
|
+
const p = {
|
|
7614
|
+
x: this.option.point.x,
|
|
7615
|
+
y: this.option.point.y
|
|
7616
|
+
};
|
|
7617
|
+
|
|
7618
|
+
if (p.x < self.center.x) {
|
|
7619
|
+
p.x -= this.width;
|
|
7620
|
+
}
|
|
7621
|
+
|
|
7622
|
+
if (p.y < self.center.y) {
|
|
7623
|
+
p.y -= this.height;
|
|
7624
|
+
}
|
|
7625
|
+
|
|
7626
|
+
return p;
|
|
7627
|
+
}
|
|
7628
|
+
});
|
|
7629
|
+
this.addShape(label);
|
|
7630
|
+
}
|
|
7631
|
+
|
|
7632
|
+
}
|
|
7633
|
+
/**
|
|
7634
|
+
* 生成图例
|
|
7635
|
+
*
|
|
7636
|
+
* @method createLegend
|
|
7637
|
+
*/
|
|
7638
|
+
|
|
7639
|
+
jmRadarSeries.prototype.createLegend = function (point) {
|
|
7640
|
+
if (!point) return; //生成图例前的图标
|
|
7641
|
+
|
|
7642
|
+
const style = this.graph.utils.clone(point.style); //delete style.stroke;
|
|
7643
|
+
|
|
7644
|
+
const shape = this.graph.createShape('rect', {
|
|
7645
|
+
style: style,
|
|
7646
|
+
position: {
|
|
7647
|
+
x: 0,
|
|
7648
|
+
y: 0
|
|
7649
|
+
}
|
|
7650
|
+
}); //此处重写图例事件
|
|
7651
|
+
|
|
7652
|
+
this.graph.legend.append(this, shape, {
|
|
7653
|
+
name: this.legendLabel,
|
|
7654
|
+
data: point.data
|
|
7655
|
+
});
|
|
7656
|
+
};
|
|
7657
|
+
|
|
7217
7658
|
/**
|
|
7218
7659
|
* 图形基类
|
|
7219
7660
|
*
|
|
@@ -7777,6 +8218,7 @@ class jmMarkLine extends jmLine {
|
|
|
7777
8218
|
this.start.x = this.end.x = isTocuhGraph ? point.x + graph.chartArea.position.x : point.x;
|
|
7778
8219
|
|
|
7779
8220
|
for (const p of point.points) {
|
|
8221
|
+
if (!p || typeof p.y === 'undefined') continue;
|
|
7780
8222
|
this.markArc = graph.createShape('circle', {
|
|
7781
8223
|
style: this.style,
|
|
7782
8224
|
radius: (this.style.radius || 5) * this.graph.devicePixelRatio
|
|
@@ -7997,6 +8439,7 @@ class jmMarkLineManager {
|
|
|
7997
8439
|
|
|
7998
8440
|
if (chart.style.markLine.lock) {
|
|
7999
8441
|
// 标线状态一直禁用系统能力
|
|
8442
|
+
// 如果指定了锁定值,只需要一项符合要求就进行锁定
|
|
8000
8443
|
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) {
|
|
8001
8444
|
lineTouching = 1;
|
|
8002
8445
|
args.event.preventDefault(); // 阻止默认行为
|
|
@@ -8390,7 +8833,7 @@ class jmChart extends jmGraph {
|
|
|
8390
8833
|
type: 'x',
|
|
8391
8834
|
visible: this.style.axis.x === false ? false : true,
|
|
8392
8835
|
format: this.option.xLabelFormat,
|
|
8393
|
-
...this.option.
|
|
8836
|
+
...this.option.xAxisOption
|
|
8394
8837
|
}, options || {});
|
|
8395
8838
|
|
|
8396
8839
|
if (typeof this.option.minXValue !== 'undefined') {
|
|
@@ -8427,7 +8870,7 @@ class jmChart extends jmGraph {
|
|
|
8427
8870
|
visible: this.style.axis.y === false ? false : true,
|
|
8428
8871
|
format: this.option.yLabelFormat,
|
|
8429
8872
|
zeroBase: this.baseY === 0,
|
|
8430
|
-
...this.option.
|
|
8873
|
+
...this.option.yAxisOption
|
|
8431
8874
|
}, options || {});
|
|
8432
8875
|
|
|
8433
8876
|
if (typeof this.option.minYValue !== 'undefined') {
|
|
@@ -8459,6 +8902,7 @@ class jmChart extends jmGraph {
|
|
|
8459
8902
|
'bar': jmBarSeries,
|
|
8460
8903
|
'stackBar': jmStackBarSeries,
|
|
8461
8904
|
'pie': jmPieSeries,
|
|
8905
|
+
'radar': jmRadarSeries,
|
|
8462
8906
|
'stackLine': jmStackLineSeries,
|
|
8463
8907
|
'candlestick': jmCandlestickSeries
|
|
8464
8908
|
};
|
|
@@ -8477,6 +8921,12 @@ class jmChart extends jmGraph {
|
|
|
8477
8921
|
}
|
|
8478
8922
|
|
|
8479
8923
|
return serie;
|
|
8924
|
+
} // 销毁
|
|
8925
|
+
|
|
8926
|
+
|
|
8927
|
+
destroy() {
|
|
8928
|
+
super.destroy();
|
|
8929
|
+
this.touchGraph && this.touchGraph.destroy();
|
|
8480
8930
|
}
|
|
8481
8931
|
|
|
8482
8932
|
}
|
|
@@ -8523,8 +8973,7 @@ var vchart = {
|
|
|
8523
8973
|
|
|
8524
8974
|
// 销毁
|
|
8525
8975
|
destroyed() {
|
|
8526
|
-
this.chartInstance && this.chartInstance.
|
|
8527
|
-
this.chartInstance && this.chartInstance.touchGraph && this.chartInstance.touchGraph.destory();
|
|
8976
|
+
this.chartInstance && this.chartInstance.destroy();
|
|
8528
8977
|
},
|
|
8529
8978
|
|
|
8530
8979
|
watch: {
|