jmchart 1.1.94 → 1.1.96
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 +11 -2
- package/dist/jmchart.amd.js +535 -50
- package/dist/jmchart.cjs.js +535 -50
- package/dist/jmchart.esm.js +535 -50
- package/dist/jmchart.iife.js +535 -50
- package/dist/jmchart.system.js +535 -50
- package/example/bar.html +11 -18
- package/example/line.html +16 -2
- package/example/pie.html +37 -0
- package/example/radar.html +160 -0
- package/example/wk/line.html +1 -1
- package/package.json +1 -1
- package/src/common/style.js +28 -2
- package/src/core/axis/axis.js +142 -38
- package/src/core/markLine/manager.js +23 -2
- package/src/jmChart.js +4 -3
- package/src/series/pieSeries.js +10 -11
- package/src/series/radarSeries.js +332 -0
- package/src/series/series.js +8 -3
- package/src/series/stackBarSeries.js +7 -3
package/dist/jmchart.amd.js
CHANGED
|
@@ -5376,7 +5376,6 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5376
5376
|
zIndex: 17,
|
|
5377
5377
|
cursor: 'default',
|
|
5378
5378
|
close: true,
|
|
5379
|
-
opacity: 0.8,
|
|
5380
5379
|
shadow: {
|
|
5381
5380
|
x: 1,
|
|
5382
5381
|
y: 1,
|
|
@@ -5405,7 +5404,34 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5405
5404
|
zIndex: 11,
|
|
5406
5405
|
cursor: 'default',
|
|
5407
5406
|
close: true,
|
|
5408
|
-
|
|
5407
|
+
shadow: {
|
|
5408
|
+
x: 1,
|
|
5409
|
+
y: 1,
|
|
5410
|
+
blur: 2,
|
|
5411
|
+
color: '#ccc'
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5414
|
+
radar: {
|
|
5415
|
+
normal: {
|
|
5416
|
+
zIndex: 11,
|
|
5417
|
+
cursor: 'default',
|
|
5418
|
+
opacity: 0.8
|
|
5419
|
+
},
|
|
5420
|
+
hover: {
|
|
5421
|
+
//zIndex: 100,
|
|
5422
|
+
opacity: 1,
|
|
5423
|
+
cursor: 'pointer'
|
|
5424
|
+
},
|
|
5425
|
+
margin: {
|
|
5426
|
+
left: 10,
|
|
5427
|
+
top: 10,
|
|
5428
|
+
right: 10,
|
|
5429
|
+
bottom: 10
|
|
5430
|
+
},
|
|
5431
|
+
lineWidth: 1,
|
|
5432
|
+
zIndex: 11,
|
|
5433
|
+
cursor: 'default',
|
|
5434
|
+
close: true,
|
|
5409
5435
|
shadow: {
|
|
5410
5436
|
x: 1,
|
|
5411
5437
|
y: 1,
|
|
@@ -5459,6 +5485,8 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5459
5485
|
|
|
5460
5486
|
_defineProperty(this, "scalePoints", []);
|
|
5461
5487
|
|
|
5488
|
+
_defineProperty(this, "labels", []);
|
|
5489
|
+
|
|
5462
5490
|
this.arrowVisible = !!options.arrowVisible;
|
|
5463
5491
|
this.zeroBase = options.zeroBase || false;
|
|
5464
5492
|
this.labelCount = options.labelCount || 5;
|
|
@@ -5472,6 +5500,8 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5472
5500
|
|
|
5473
5501
|
this.field = options.field || '';
|
|
5474
5502
|
this.index = options.index || 0;
|
|
5503
|
+
this.gridLines = []; // 线条数组
|
|
5504
|
+
|
|
5475
5505
|
this.init(options);
|
|
5476
5506
|
} // 初始化一些参数
|
|
5477
5507
|
// 这个函数可能会重入。
|
|
@@ -5481,6 +5511,8 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5481
5511
|
options = options || {}; // 深度组件默认样式
|
|
5482
5512
|
|
|
5483
5513
|
if (options.style) this.graph.utils.clone(options.style, this.style, true);
|
|
5514
|
+
this.field = options.field || this.field || '';
|
|
5515
|
+
this.radarOption = options.radarOption;
|
|
5484
5516
|
|
|
5485
5517
|
if (this.type == 'x') {
|
|
5486
5518
|
if (typeof options.maxXValue !== 'undefined') this.maxValue = options.maxXValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
|
|
@@ -5509,6 +5541,24 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5509
5541
|
|
|
5510
5542
|
set data(d) {
|
|
5511
5543
|
this.graph.data = d;
|
|
5544
|
+
} // 生成绘制点,
|
|
5545
|
+
// 重写原函数
|
|
5546
|
+
|
|
5547
|
+
|
|
5548
|
+
initPoints() {
|
|
5549
|
+
// 如果是雷达图
|
|
5550
|
+
if (this.radarOption && this.type === 'x') {
|
|
5551
|
+
this.points = [];
|
|
5552
|
+
|
|
5553
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5554
|
+
this.points.push(axis.end);
|
|
5555
|
+
}
|
|
5556
|
+
|
|
5557
|
+
this.points.push(this.points[0]);
|
|
5558
|
+
return this.points;
|
|
5559
|
+
} else {
|
|
5560
|
+
return super.initPoints();
|
|
5561
|
+
}
|
|
5512
5562
|
}
|
|
5513
5563
|
/**
|
|
5514
5564
|
* 计算当前轴的位置
|
|
@@ -5524,7 +5574,39 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5524
5574
|
case 'x':
|
|
5525
5575
|
{
|
|
5526
5576
|
//初始化显示标签个数
|
|
5527
|
-
this.labelCount = this.style.xLabel.count || 5;
|
|
5577
|
+
this.labelCount = this.style.xLabel.count || 5; // 如果是雷达图,则画栅格线
|
|
5578
|
+
|
|
5579
|
+
if (this.radarOption) {
|
|
5580
|
+
if (this.style.grid && this.style.grid.x) {
|
|
5581
|
+
for (let i = 1; i < this.labelCount + 1; i++) {
|
|
5582
|
+
const points = [];
|
|
5583
|
+
const curRadius = this.radarOption.radius / this.labelCount * i;
|
|
5584
|
+
|
|
5585
|
+
for (const axis of this.radarOption.yAxises) {
|
|
5586
|
+
const point = {};
|
|
5587
|
+
point.x = axis.radarOption.center.x + axis.radarOption.cos * curRadius + bounds.left;
|
|
5588
|
+
point.y = axis.radarOption.center.y - axis.radarOption.sin * curRadius + bounds.top;
|
|
5589
|
+
points.push(point);
|
|
5590
|
+
} // 画栅格线
|
|
5591
|
+
|
|
5592
|
+
|
|
5593
|
+
for (let j = 0; j < points.length; j++) {
|
|
5594
|
+
const start = points[j];
|
|
5595
|
+
const end = points[j + 1] || points[0];
|
|
5596
|
+
const gridLine = this.graph.createShape('line', {
|
|
5597
|
+
start,
|
|
5598
|
+
end,
|
|
5599
|
+
style: this.style.grid
|
|
5600
|
+
});
|
|
5601
|
+
this.parent.children.add(gridLine);
|
|
5602
|
+
this.gridLines.push(gridLine);
|
|
5603
|
+
}
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
|
|
5607
|
+
break;
|
|
5608
|
+
}
|
|
5609
|
+
|
|
5528
5610
|
this.start.x = bounds.left;
|
|
5529
5611
|
this.start.y = bounds.bottom;
|
|
5530
5612
|
this.end.x = bounds.right;
|
|
@@ -5543,21 +5625,30 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5543
5625
|
|
|
5544
5626
|
case 'y':
|
|
5545
5627
|
{
|
|
5546
|
-
|
|
5547
|
-
|
|
5628
|
+
//初始化显示标签个数
|
|
5629
|
+
this.labelCount = this.style.yLabel.count || 5;
|
|
5630
|
+
const index = this.index || 1; // 如果是雷达图,则画发散的线
|
|
5631
|
+
|
|
5632
|
+
if (this.radarOption) {
|
|
5633
|
+
this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left;
|
|
5634
|
+
this.end.y = this.radarOption.center.y - this.radarOption.sin * this.radarOption.radius + bounds.top;
|
|
5635
|
+
this.start.x = this.radarOption.center.x + bounds.left;
|
|
5636
|
+
this.start.y = this.radarOption.center.y + bounds.top;
|
|
5637
|
+
} else {
|
|
5638
|
+
let xoffset = bounds.left; //多Y轴时,第二个为右边第一轴,其它的依此递推
|
|
5548
5639
|
|
|
5549
|
-
|
|
5640
|
+
if (index == 2) {
|
|
5641
|
+
xoffset = bounds.right;
|
|
5642
|
+
} else if (index > 2) {
|
|
5643
|
+
xoffset = this.graph.yAxises[index - 1].start.x + this.graph.yAxises[index - 1].width + 10;
|
|
5644
|
+
}
|
|
5550
5645
|
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5646
|
+
this.start.x = xoffset;
|
|
5647
|
+
this.start.y = bounds.bottom;
|
|
5648
|
+
this.end.x = this.start.x;
|
|
5649
|
+
this.end.y = bounds.top;
|
|
5555
5650
|
}
|
|
5556
5651
|
|
|
5557
|
-
this.start.x = xoffset;
|
|
5558
|
-
this.start.y = bounds.bottom;
|
|
5559
|
-
this.end.x = this.start.x;
|
|
5560
|
-
this.end.y = bounds.top;
|
|
5561
5652
|
break;
|
|
5562
5653
|
}
|
|
5563
5654
|
}
|
|
@@ -5579,11 +5670,12 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5579
5670
|
|
|
5580
5671
|
|
|
5581
5672
|
createLabel() {
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5673
|
+
if (this.visible === false) return; // 雷达图的标签单独处理
|
|
5674
|
+
|
|
5675
|
+
if (this.radarOption) {
|
|
5676
|
+
return this.createRadarLabel();
|
|
5677
|
+
} //如果是?X轴则执行X轴标签生成
|
|
5678
|
+
|
|
5587
5679
|
|
|
5588
5680
|
if (this.type == 'x') {
|
|
5589
5681
|
this.createXLabel();
|
|
@@ -5703,13 +5795,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5703
5795
|
|
|
5704
5796
|
let count = this.labelCount;
|
|
5705
5797
|
const mm = max - min;
|
|
5706
|
-
|
|
5707
|
-
count = mm;
|
|
5708
|
-
}*/
|
|
5709
|
-
// mm 放大10000倍,这里结果也需要除于10000
|
|
5710
|
-
|
|
5711
|
-
let pervalue = mm / count || 1; //if(pervalue > 1 || pervalue < -1) pervalue = Math.floor(pervalue);
|
|
5712
|
-
|
|
5798
|
+
let pervalue = mm / count || 1;
|
|
5713
5799
|
const format = this.option.format || this.format;
|
|
5714
5800
|
const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
|
|
5715
5801
|
const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
|
|
@@ -5720,7 +5806,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5720
5806
|
if (p > max || i === count) p = max;
|
|
5721
5807
|
const h = (p - min) * step; // 当前点的偏移高度
|
|
5722
5808
|
|
|
5723
|
-
const label = this.graph.
|
|
5809
|
+
const label = this.graph.createShape('label', {
|
|
5724
5810
|
style: this.style.yLabel
|
|
5725
5811
|
});
|
|
5726
5812
|
label.text = format.call(this, p, label); // 格式化label
|
|
@@ -5753,7 +5839,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5753
5839
|
y: offy + this.end.y
|
|
5754
5840
|
}); // 指定要显示网格
|
|
5755
5841
|
|
|
5756
|
-
if (this.style.grid && this.style.grid.x) {
|
|
5842
|
+
if (!this.radarOption && this.style.grid && this.style.grid.x) {
|
|
5757
5843
|
// 它的坐标是相对于轴的,所以Y轴会用负的区域高度
|
|
5758
5844
|
const line = this.graph.createShape('line', {
|
|
5759
5845
|
start: {
|
|
@@ -5816,6 +5902,42 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5816
5902
|
}
|
|
5817
5903
|
}
|
|
5818
5904
|
}
|
|
5905
|
+
/**
|
|
5906
|
+
* 生成雷达图的Y轴标签
|
|
5907
|
+
*/
|
|
5908
|
+
|
|
5909
|
+
|
|
5910
|
+
createRadarLabel() {
|
|
5911
|
+
const format = this.option.format;
|
|
5912
|
+
const bounds = this.graph.chartArea.getBounds(); // 获取画图区域
|
|
5913
|
+
|
|
5914
|
+
const self = this;
|
|
5915
|
+
const label = this.graph.createShape('label', {
|
|
5916
|
+
style: this.style.yLabel,
|
|
5917
|
+
position: function () {
|
|
5918
|
+
// 因为axis是相对于chart的,而center是相对于chartArea的,所以要计算axis位置相对于chartArea来比较
|
|
5919
|
+
const pos = {
|
|
5920
|
+
x: self.end.x - bounds.left,
|
|
5921
|
+
y: self.end.y - bounds.top
|
|
5922
|
+
};
|
|
5923
|
+
const size = this.testSize();
|
|
5924
|
+
|
|
5925
|
+
if (pos.x < self.radarOption.center.x) {
|
|
5926
|
+
pos.x -= size.width;
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5929
|
+
if (pos.y < self.radarOption.center.y) {
|
|
5930
|
+
pos.y -= size.height;
|
|
5931
|
+
}
|
|
5932
|
+
|
|
5933
|
+
return pos;
|
|
5934
|
+
}
|
|
5935
|
+
});
|
|
5936
|
+
label.text = typeof format === 'function' ? format.call(this, label) : this.field; // 格式化label
|
|
5937
|
+
|
|
5938
|
+
this.labels.push(label);
|
|
5939
|
+
this.graph.chartArea.children.add(label);
|
|
5940
|
+
}
|
|
5819
5941
|
/**
|
|
5820
5942
|
* 获取当前轴所占宽
|
|
5821
5943
|
*
|
|
@@ -5963,6 +6085,18 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5963
6085
|
clear() {
|
|
5964
6086
|
this._min = null;
|
|
5965
6087
|
this._max = null;
|
|
6088
|
+
this.children.each((i, c) => {
|
|
6089
|
+
c.remove();
|
|
6090
|
+
}, true); // 清空栅格线
|
|
6091
|
+
|
|
6092
|
+
this.gridLines && this.gridLines.forEach(line => {
|
|
6093
|
+
line.remove();
|
|
6094
|
+
});
|
|
6095
|
+
this.labels && this.labels.forEach(label => {
|
|
6096
|
+
label.remove();
|
|
6097
|
+
});
|
|
6098
|
+
this.labels = [];
|
|
6099
|
+
this.gridLines = [];
|
|
5966
6100
|
}
|
|
5967
6101
|
/**
|
|
5968
6102
|
* 计算当前轴的单位偏移量
|
|
@@ -5974,7 +6108,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5974
6108
|
|
|
5975
6109
|
step() {
|
|
5976
6110
|
if (this.type == 'x') {
|
|
5977
|
-
const w = this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
6111
|
+
const w = this.radarOption ? this.radarOption.radius : this.width; //如果排版为内联,则单位占宽减少一个单位,
|
|
5978
6112
|
//也就是起始位从一个单位开始
|
|
5979
6113
|
|
|
5980
6114
|
if (this.graph.style.layout == 'inside') {
|
|
@@ -5990,7 +6124,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
5990
6124
|
|
|
5991
6125
|
return w / tmp;
|
|
5992
6126
|
} else if (this.type == 'y') {
|
|
5993
|
-
const h = this.height;
|
|
6127
|
+
const h = this.radarOption ? this.radarOption.radius : this.height;
|
|
5994
6128
|
|
|
5995
6129
|
switch (this.dataType) {
|
|
5996
6130
|
case 'string':
|
|
@@ -6254,7 +6388,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6254
6388
|
}); // 初始化一些参数, 因为这里有多个Y轴的可能,所以每次都需要重调一次init
|
|
6255
6389
|
|
|
6256
6390
|
this.yAxis.init({
|
|
6257
|
-
field: this.field,
|
|
6391
|
+
field: Array.isArray(this.field) ? this.field[0] : this.field,
|
|
6258
6392
|
minYValue: options.minYValue,
|
|
6259
6393
|
maxYValue: options.maxYValue
|
|
6260
6394
|
});
|
|
@@ -6309,6 +6443,11 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6309
6443
|
if (dataChanged) this.___animateCounter = 0; // 数据改变。动画重新开始
|
|
6310
6444
|
} else {
|
|
6311
6445
|
this.dataPoints = this.createPoints(...args);
|
|
6446
|
+
} // 执行初始化函数回调
|
|
6447
|
+
|
|
6448
|
+
|
|
6449
|
+
if (this.option && this.option.onInit) {
|
|
6450
|
+
this.option.onInit.apply(this, args);
|
|
6312
6451
|
}
|
|
6313
6452
|
|
|
6314
6453
|
return {
|
|
@@ -6377,12 +6516,12 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6377
6516
|
|
|
6378
6517
|
while (shape = this.shapes.shift()) {
|
|
6379
6518
|
shape && shape.remove();
|
|
6380
|
-
}
|
|
6381
|
-
|
|
6519
|
+
}
|
|
6382
6520
|
|
|
6383
|
-
this.createLegend();
|
|
6384
6521
|
this.initAxisValue(); // 处理最大值最小值
|
|
6522
|
+
//生成图例 这里要放到shape清理后面
|
|
6385
6523
|
|
|
6524
|
+
this.createLegend();
|
|
6386
6525
|
return this.chartInfo = {
|
|
6387
6526
|
xAxis: this.xAxis,
|
|
6388
6527
|
yAxis: this.yAxis
|
|
@@ -6508,6 +6647,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6508
6647
|
style
|
|
6509
6648
|
});
|
|
6510
6649
|
this.graph.legend.append(this, shape);
|
|
6650
|
+
return shape;
|
|
6511
6651
|
} // 生成柱图的标注
|
|
6512
6652
|
|
|
6513
6653
|
|
|
@@ -6773,15 +6913,18 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6773
6913
|
|
|
6774
6914
|
for (let index = 0; index < point.points.length; index++) {
|
|
6775
6915
|
const style = this.graph.utils.clone(this.style);
|
|
6916
|
+
const p = point.points[index];
|
|
6776
6917
|
|
|
6777
6918
|
if (style.color && typeof style.color === 'function') {
|
|
6778
|
-
style.fill = style.color.call(this,
|
|
6919
|
+
style.fill = style.color.call(this, {
|
|
6920
|
+
index,
|
|
6921
|
+
point: p
|
|
6922
|
+
});
|
|
6779
6923
|
} else {
|
|
6780
6924
|
style.fill = this.graph.getColor(index);
|
|
6781
6925
|
}
|
|
6782
6926
|
|
|
6783
6927
|
const sp = this.addShape(this.graph.createPath(null, style));
|
|
6784
|
-
const p = point.points[index];
|
|
6785
6928
|
let startY = topStartY;
|
|
6786
6929
|
if (p.yValue < this.baseYValue) startY = bottomStartY; //首先确定p1和p4,因为他们是底脚。会固定
|
|
6787
6930
|
|
|
@@ -6915,7 +7058,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
6915
7058
|
x: this.graph.chartArea.width / 2,
|
|
6916
7059
|
y: this.graph.chartArea.height / 2
|
|
6917
7060
|
};
|
|
6918
|
-
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); //生成描点位
|
|
7061
|
+
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); //生成描点位
|
|
6919
7062
|
// super.init会把参数透传给 createPoints
|
|
6920
7063
|
|
|
6921
7064
|
const {
|
|
@@ -7007,7 +7150,8 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7007
7150
|
// 每个数值点比
|
|
7008
7151
|
style: this.graph.utils.clone(this.style),
|
|
7009
7152
|
anticlockwise
|
|
7010
|
-
};
|
|
7153
|
+
};
|
|
7154
|
+
points.push(p); //p.style.color = this.graph.getColor(index);
|
|
7011
7155
|
|
|
7012
7156
|
if (p.style.color && typeof p.style.color === 'function') {
|
|
7013
7157
|
p.style.fill = p.style.color.call(this, p);
|
|
@@ -7088,34 +7232,34 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7088
7232
|
|
|
7089
7233
|
if (this.option.onClick) {
|
|
7090
7234
|
p.shape.on('click', e => {
|
|
7091
|
-
this.option.onClick.call(this, p, e);
|
|
7235
|
+
return this.option.onClick.call(this, p, e);
|
|
7092
7236
|
});
|
|
7093
7237
|
}
|
|
7094
7238
|
|
|
7095
7239
|
if (this.option.onOver) {
|
|
7096
7240
|
p.shape.on('mouseover touchover', e => {
|
|
7097
|
-
this.option.onOver.call(this, p, e);
|
|
7241
|
+
return this.option.onOver.call(this, p, e);
|
|
7098
7242
|
});
|
|
7099
7243
|
}
|
|
7100
7244
|
|
|
7101
7245
|
if (this.option.onLeave) {
|
|
7102
7246
|
p.shape.on('mouseleave touchleave', e => {
|
|
7103
|
-
this.option.onLeave.call(this, p, e);
|
|
7247
|
+
return this.option.onLeave.call(this, p, e);
|
|
7104
7248
|
});
|
|
7105
7249
|
}
|
|
7106
7250
|
|
|
7107
7251
|
this.createLabel(p); // 生成标签
|
|
7108
|
-
|
|
7252
|
+
// 生成标点的回调
|
|
7109
7253
|
|
|
7110
|
-
|
|
7111
|
-
|
|
7254
|
+
this.emit('onPointCreated', p);
|
|
7255
|
+
}
|
|
7112
7256
|
|
|
7113
|
-
|
|
7257
|
+
index++;
|
|
7114
7258
|
}
|
|
7115
7259
|
}
|
|
7116
7260
|
|
|
7117
7261
|
return points;
|
|
7118
|
-
} //
|
|
7262
|
+
} // 生成图的标注
|
|
7119
7263
|
|
|
7120
7264
|
|
|
7121
7265
|
createLabel(point) {
|
|
@@ -7139,7 +7283,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7139
7283
|
}; // 动态计算位置
|
|
7140
7284
|
|
|
7141
7285
|
const parentRect = this.parent.getBounds(); //const rect = this.getBounds.call(this.parent);
|
|
7142
|
-
//
|
|
7286
|
+
// 圆弧的中间位,离圆心最近和最远的二个点
|
|
7143
7287
|
|
|
7144
7288
|
let centerMaxPoint = this.parent.points[Math.floor(this.parent.points.length / 2)];
|
|
7145
7289
|
let centerMinPoint = this.parent.center; // 如果是空心圆,则要计算 1/4 和 3/4位的点。顺时针和逆时针二个点大小不一样,这里只取,大小计算时处理
|
|
@@ -7216,6 +7360,329 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7216
7360
|
}
|
|
7217
7361
|
};
|
|
7218
7362
|
|
|
7363
|
+
/**
|
|
7364
|
+
* 雷达图
|
|
7365
|
+
*
|
|
7366
|
+
* @class jmRadarSeries
|
|
7367
|
+
* @module jmChart
|
|
7368
|
+
* @param {jmChart} chart 当前图表
|
|
7369
|
+
* @param {array} mappings 图形字段映射
|
|
7370
|
+
* @param {style} style 样式
|
|
7371
|
+
*/
|
|
7372
|
+
//构造函数
|
|
7373
|
+
|
|
7374
|
+
class jmRadarSeries extends jmSeries {
|
|
7375
|
+
constructor(options) {
|
|
7376
|
+
super(options);
|
|
7377
|
+
} // 重新生成轴,雷达图只需要Y轴即可
|
|
7378
|
+
|
|
7379
|
+
|
|
7380
|
+
createAxises(center, radius) {
|
|
7381
|
+
this.axises = [this.yAxis];
|
|
7382
|
+
const yCount = this.field.length;
|
|
7383
|
+
if (!yCount) return; //每个维度点的角度
|
|
7384
|
+
|
|
7385
|
+
const rotateStep = Math.PI * 2 / yCount; // 清空除了一个默认外的所有Y轴
|
|
7386
|
+
|
|
7387
|
+
for (let index in this.graph.yAxises) {
|
|
7388
|
+
const axis = this.graph.yAxises[index];
|
|
7389
|
+
if (!axis || axis === this.yAxis) continue;
|
|
7390
|
+
axis.remove();
|
|
7391
|
+
delete this.graph.yAxises[index];
|
|
7392
|
+
}
|
|
7393
|
+
|
|
7394
|
+
for (let index = 0; index < yCount; index++) {
|
|
7395
|
+
if (!this.field[index]) continue;
|
|
7396
|
+
let axis = this.yAxis; // 除了默认的y轴外,其它都重新生成
|
|
7397
|
+
|
|
7398
|
+
if (index > 0) {
|
|
7399
|
+
axis = this.graph.createYAxis({
|
|
7400
|
+
index: index + 1,
|
|
7401
|
+
format: this.option.yLabelFormat || this.graph.option.yLabelFormat
|
|
7402
|
+
});
|
|
7403
|
+
this.axises.push(axis);
|
|
7404
|
+
}
|
|
7405
|
+
|
|
7406
|
+
const rotate = Math.PI / 2 + rotateStep * index; //从向上90度开始
|
|
7407
|
+
|
|
7408
|
+
axis.init({
|
|
7409
|
+
field: this.field[index],
|
|
7410
|
+
radarOption: {
|
|
7411
|
+
center,
|
|
7412
|
+
radius,
|
|
7413
|
+
yCount,
|
|
7414
|
+
rotate: rotate,
|
|
7415
|
+
cos: Math.cos(rotate),
|
|
7416
|
+
sin: Math.sin(rotate)
|
|
7417
|
+
}
|
|
7418
|
+
});
|
|
7419
|
+
} // x轴初始化
|
|
7420
|
+
|
|
7421
|
+
|
|
7422
|
+
this.xAxis.init({
|
|
7423
|
+
radarOption: {
|
|
7424
|
+
center,
|
|
7425
|
+
radius,
|
|
7426
|
+
yCount,
|
|
7427
|
+
yAxises: this.axises
|
|
7428
|
+
}
|
|
7429
|
+
});
|
|
7430
|
+
return this.axises;
|
|
7431
|
+
} // 计算最大值和最小值,一般图形直接采用最大最小值即可,有些需要多值叠加
|
|
7432
|
+
|
|
7433
|
+
|
|
7434
|
+
initAxisValue() {
|
|
7435
|
+
this.center = {
|
|
7436
|
+
x: this.graph.chartArea.width / 2,
|
|
7437
|
+
y: this.graph.chartArea.height / 2
|
|
7438
|
+
};
|
|
7439
|
+
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);
|
|
7440
|
+
const axises = this.createAxises(this.center, this.radius); // 重置所有轴
|
|
7441
|
+
// 计算最大最小值
|
|
7442
|
+
// 当前需要先更新axis的边界值,轴好画图
|
|
7443
|
+
|
|
7444
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
7445
|
+
axises.forEach(axis => {
|
|
7446
|
+
const v = this.data[i][axis.field];
|
|
7447
|
+
axis.max(v);
|
|
7448
|
+
axis.min(v);
|
|
7449
|
+
});
|
|
7450
|
+
}
|
|
7451
|
+
} // 重新初始化图形
|
|
7452
|
+
|
|
7453
|
+
|
|
7454
|
+
init() {
|
|
7455
|
+
//生成描点位
|
|
7456
|
+
// super.init会把参数透传给 createPoints
|
|
7457
|
+
const {
|
|
7458
|
+
points,
|
|
7459
|
+
dataChanged
|
|
7460
|
+
} = this.initDataPoint(this.center, this.radius);
|
|
7461
|
+
this.createLegend(points); // 是否正在动画中
|
|
7462
|
+
|
|
7463
|
+
const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0);
|
|
7464
|
+
const aniCount = this.style.aniCount || 20;
|
|
7465
|
+
let aniIsEnd = true; // 当次是否结束动画
|
|
7466
|
+
|
|
7467
|
+
const len = points.length;
|
|
7468
|
+
const shapeMap = {};
|
|
7469
|
+
const self = this;
|
|
7470
|
+
|
|
7471
|
+
for (let i = 0; i < len; i++) {
|
|
7472
|
+
const p = points[i];
|
|
7473
|
+
let shape = shapeMap[p.index];
|
|
7474
|
+
|
|
7475
|
+
if (!shape) {
|
|
7476
|
+
shape = shapeMap[p.index] = this.graph.createShape('path', { ...p,
|
|
7477
|
+
style: p.style,
|
|
7478
|
+
points: []
|
|
7479
|
+
});
|
|
7480
|
+
this.addShape(shape); // 如果有点击事件
|
|
7481
|
+
|
|
7482
|
+
if (this.option.onClick) {
|
|
7483
|
+
shape.on('click', function (e) {
|
|
7484
|
+
return self.option.onClick.call(this, e);
|
|
7485
|
+
});
|
|
7486
|
+
}
|
|
7487
|
+
|
|
7488
|
+
if (this.option.onOver) {
|
|
7489
|
+
shape.on('mouseover touchover', function (e) {
|
|
7490
|
+
return self.option.onOver.call(this, e);
|
|
7491
|
+
});
|
|
7492
|
+
}
|
|
7493
|
+
|
|
7494
|
+
if (this.option.onLeave) {
|
|
7495
|
+
shape.on('mouseleave touchleave', function (e) {
|
|
7496
|
+
return self.option.onLeave.call(this, e);
|
|
7497
|
+
});
|
|
7498
|
+
}
|
|
7499
|
+
}
|
|
7500
|
+
|
|
7501
|
+
shape.zIndex += p.radius / this.radius; // 用每个轴占比做为排序号,这样占面积最大的排最底层
|
|
7502
|
+
|
|
7503
|
+
let point = null; // 在动画中,则一直刷新
|
|
7504
|
+
|
|
7505
|
+
if (isRunningAni) {
|
|
7506
|
+
let step = p.radius / aniCount * this.___animateCounter;
|
|
7507
|
+
|
|
7508
|
+
if (step >= p.radius) {
|
|
7509
|
+
step = p.radius;
|
|
7510
|
+
} else {
|
|
7511
|
+
aniIsEnd = false;
|
|
7512
|
+
}
|
|
7513
|
+
|
|
7514
|
+
point = { ...p,
|
|
7515
|
+
x: this.center.x + p.axis.radarOption.cos * step,
|
|
7516
|
+
y: this.center.y - p.axis.radarOption.sin * step
|
|
7517
|
+
};
|
|
7518
|
+
} else {
|
|
7519
|
+
point = p;
|
|
7520
|
+
}
|
|
7521
|
+
|
|
7522
|
+
shape.points.push(point);
|
|
7523
|
+
this.createLabel(point); // 生成标签
|
|
7524
|
+
} // 所有动画都完成,则清空计数器
|
|
7525
|
+
|
|
7526
|
+
|
|
7527
|
+
if (aniIsEnd) {
|
|
7528
|
+
this.___animateCounter = 0;
|
|
7529
|
+
} else {
|
|
7530
|
+
this.___animateCounter++; // next tick 再次刷新
|
|
7531
|
+
|
|
7532
|
+
this.graph.utils.requestAnimationFrame(() => {
|
|
7533
|
+
this.needUpdate = true; //需要刷新
|
|
7534
|
+
});
|
|
7535
|
+
}
|
|
7536
|
+
}
|
|
7537
|
+
/**
|
|
7538
|
+
* 生成序列图描点
|
|
7539
|
+
*
|
|
7540
|
+
* @method createPoints
|
|
7541
|
+
*/
|
|
7542
|
+
|
|
7543
|
+
|
|
7544
|
+
createPoints(center, radius) {
|
|
7545
|
+
if (!this.data || !this.axises) return [];
|
|
7546
|
+
center = center || this.center;
|
|
7547
|
+
const points = [];
|
|
7548
|
+
|
|
7549
|
+
for (var i = 0; i < this.data.length; i++) {
|
|
7550
|
+
const s = this.data[i];
|
|
7551
|
+
const style = this.graph.utils.clone(this.style);
|
|
7552
|
+
|
|
7553
|
+
if (style.color && typeof style.color === 'function') {
|
|
7554
|
+
style.stroke = style.color.call(this, {
|
|
7555
|
+
data: s,
|
|
7556
|
+
index: i
|
|
7557
|
+
});
|
|
7558
|
+
} else {
|
|
7559
|
+
style.stroke = this.graph.getColor(i);
|
|
7560
|
+
}
|
|
7561
|
+
|
|
7562
|
+
if (typeof style.fill === 'function') {
|
|
7563
|
+
style.fill = style.fill.call(this, style);
|
|
7564
|
+
} else {
|
|
7565
|
+
const color = this.graph.utils.hexToRGBA(style.stroke);
|
|
7566
|
+
style.fill = `rgba(${color.r},${color.g},${color.b}, 0.2)`;
|
|
7567
|
+
}
|
|
7568
|
+
|
|
7569
|
+
const shapePoints = [];
|
|
7570
|
+
|
|
7571
|
+
for (const axis of this.axises) {
|
|
7572
|
+
const yv = s[axis.field];
|
|
7573
|
+
const p = {
|
|
7574
|
+
x: center.x,
|
|
7575
|
+
y: center.y,
|
|
7576
|
+
index: i,
|
|
7577
|
+
radius: 0,
|
|
7578
|
+
data: s,
|
|
7579
|
+
yValue: yv,
|
|
7580
|
+
yLabel: yv,
|
|
7581
|
+
style,
|
|
7582
|
+
axis
|
|
7583
|
+
};
|
|
7584
|
+
shapePoints.push(p); //如果Y值不存在。则此点无效,不画图
|
|
7585
|
+
|
|
7586
|
+
if (yv == null || typeof yv == 'undefined') {
|
|
7587
|
+
continue;
|
|
7588
|
+
}
|
|
7589
|
+
|
|
7590
|
+
p.radius = Math.abs(yv - axis.min()) * axis.step();
|
|
7591
|
+
p.x = center.x + axis.radarOption.cos * p.radius;
|
|
7592
|
+
p.y = center.y - axis.radarOption.sin * p.radius; // 生成标点的回调
|
|
7593
|
+
|
|
7594
|
+
this.emit('onPointCreated', p);
|
|
7595
|
+
}
|
|
7596
|
+
|
|
7597
|
+
points.push(...shapePoints);
|
|
7598
|
+
}
|
|
7599
|
+
|
|
7600
|
+
return points;
|
|
7601
|
+
} // 生成图的标注
|
|
7602
|
+
|
|
7603
|
+
|
|
7604
|
+
createLabel(point) {
|
|
7605
|
+
if (this.style.label && this.style.label.show === false) return;
|
|
7606
|
+
const text = this.option.itemLabelFormat ? this.option.itemLabelFormat.call(this, point) : point.yValue;
|
|
7607
|
+
if (!text) return; // v如果指定了为控件,则直接加入
|
|
7608
|
+
|
|
7609
|
+
if (text instanceof jmControl) {
|
|
7610
|
+
this.addShape(text);
|
|
7611
|
+
return text;
|
|
7612
|
+
}
|
|
7613
|
+
|
|
7614
|
+
const self = this;
|
|
7615
|
+
const label = this.graph.createShape('label', {
|
|
7616
|
+
style: this.style.label,
|
|
7617
|
+
text: text,
|
|
7618
|
+
point,
|
|
7619
|
+
position: function () {
|
|
7620
|
+
const p = {
|
|
7621
|
+
x: this.option.point.x,
|
|
7622
|
+
y: this.option.point.y
|
|
7623
|
+
};
|
|
7624
|
+
|
|
7625
|
+
if (p.x < self.center.x) {
|
|
7626
|
+
p.x -= this.width;
|
|
7627
|
+
}
|
|
7628
|
+
|
|
7629
|
+
if (p.y < self.center.y) {
|
|
7630
|
+
p.y -= this.height;
|
|
7631
|
+
}
|
|
7632
|
+
|
|
7633
|
+
return p;
|
|
7634
|
+
}
|
|
7635
|
+
});
|
|
7636
|
+
this.addShape(label);
|
|
7637
|
+
}
|
|
7638
|
+
|
|
7639
|
+
}
|
|
7640
|
+
/**
|
|
7641
|
+
* 生成图例
|
|
7642
|
+
*
|
|
7643
|
+
* @method createLegend
|
|
7644
|
+
*/
|
|
7645
|
+
|
|
7646
|
+
jmRadarSeries.prototype.createLegend = function (points) {
|
|
7647
|
+
if (!points || !points.length) return;
|
|
7648
|
+
const legendMap = {};
|
|
7649
|
+
|
|
7650
|
+
for (let k in points) {
|
|
7651
|
+
const p = points[k];
|
|
7652
|
+
if (!p) continue;
|
|
7653
|
+
if (legendMap[p.index]) continue; //生成图例前的图标
|
|
7654
|
+
|
|
7655
|
+
const style = this.graph.utils.clone(p.style);
|
|
7656
|
+
style.fill = style.fill; //delete style.stroke;
|
|
7657
|
+
|
|
7658
|
+
const shape = legendMap[p.index] = this.graph.createShape('rect', {
|
|
7659
|
+
style: style,
|
|
7660
|
+
position: {
|
|
7661
|
+
x: 0,
|
|
7662
|
+
y: 0
|
|
7663
|
+
}
|
|
7664
|
+
}); //shape.targetShape = p.shape;
|
|
7665
|
+
//此处重写图例事件
|
|
7666
|
+
|
|
7667
|
+
this.graph.legend.append(this, shape, {
|
|
7668
|
+
name: this.legendLabel,
|
|
7669
|
+
hover: function () {
|
|
7670
|
+
//var sp = this.children.get(0);
|
|
7671
|
+
//应用图的动态样式
|
|
7672
|
+
Object.assign(this.targetShape.style, this.targetShape.style.hover);
|
|
7673
|
+
Object.assign(this.style, this.style.hover);
|
|
7674
|
+
},
|
|
7675
|
+
leave: function () {
|
|
7676
|
+
//var sp = this.children.get(0);
|
|
7677
|
+
//应用图的普通样式
|
|
7678
|
+
Object.assign(this.targetShape.style, this.targetShape.style.normal);
|
|
7679
|
+
Object.assign(this.style, this.style.normal);
|
|
7680
|
+
},
|
|
7681
|
+
data: p.data
|
|
7682
|
+
});
|
|
7683
|
+
}
|
|
7684
|
+
};
|
|
7685
|
+
|
|
7219
7686
|
/**
|
|
7220
7687
|
* 图形基类
|
|
7221
7688
|
*
|
|
@@ -7936,13 +8403,16 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7936
8403
|
|
|
7937
8404
|
let longtap = 0; // 是否有长按, 0 未开始,1已按下,2识别为长按
|
|
7938
8405
|
|
|
8406
|
+
let lineTouching = 0; // 1=启用标线状态,2=非标线,则可以触发系统行为
|
|
8407
|
+
|
|
7939
8408
|
let longtapHandler = 0;
|
|
7940
8409
|
let touchStartPos = {
|
|
7941
8410
|
x: 0,
|
|
7942
8411
|
y: 0
|
|
7943
8412
|
};
|
|
7944
8413
|
graph.on('mousedown touchstart', args => {
|
|
7945
|
-
// 如果长按才启用
|
|
8414
|
+
lineTouching = 0; // 如果长按才启用
|
|
8415
|
+
|
|
7946
8416
|
if (chart.style.markLine.longtap) {
|
|
7947
8417
|
longtap = 1;
|
|
7948
8418
|
longtapHandler && graph.utils.cancelAnimationFrame(longtapHandler);
|
|
@@ -7989,14 +8459,28 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
7989
8459
|
|
|
7990
8460
|
if (longtap === 1) {
|
|
7991
8461
|
if (args.offsetInfo.offset > 15) longtap = 0; // 如果移动了,则取消长按
|
|
8462
|
+
else lineTouching = 1;
|
|
8463
|
+
}
|
|
8464
|
+
|
|
8465
|
+
args.event.stopPropagation(); // 如果指定了锁定图表标线操作值,则触发后当次滑动不再响应系统默认行为
|
|
8466
|
+
|
|
8467
|
+
if (chart.style.markLine.lock) {
|
|
8468
|
+
// 标线状态一直禁用系统能力
|
|
8469
|
+
// 如果指定了锁定值,只需要一项符合要求就进行锁定
|
|
8470
|
+
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) {
|
|
8471
|
+
lineTouching = 1;
|
|
8472
|
+
args.event.preventDefault(); // 阻止默认行为
|
|
8473
|
+
}
|
|
7992
8474
|
}
|
|
7993
8475
|
|
|
8476
|
+
if (lineTouching === 0) lineTouching = 2;
|
|
7994
8477
|
args.longtap = longtap;
|
|
7995
8478
|
this.move(args);
|
|
7996
8479
|
}); // 取消移动
|
|
7997
8480
|
|
|
7998
8481
|
graph.on('mouseup touchend touchcancel touchleave', args => {
|
|
7999
8482
|
longtap = 0;
|
|
8483
|
+
lineTouching = 0;
|
|
8000
8484
|
this.endMove(args);
|
|
8001
8485
|
});
|
|
8002
8486
|
}
|
|
@@ -8376,7 +8860,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8376
8860
|
type: 'x',
|
|
8377
8861
|
visible: this.style.axis.x === false ? false : true,
|
|
8378
8862
|
format: this.option.xLabelFormat,
|
|
8379
|
-
...this.option.
|
|
8863
|
+
...this.option.xAxisOption
|
|
8380
8864
|
}, options || {});
|
|
8381
8865
|
|
|
8382
8866
|
if (typeof this.option.minXValue !== 'undefined') {
|
|
@@ -8413,7 +8897,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8413
8897
|
visible: this.style.axis.y === false ? false : true,
|
|
8414
8898
|
format: this.option.yLabelFormat,
|
|
8415
8899
|
zeroBase: this.baseY === 0,
|
|
8416
|
-
...this.option.
|
|
8900
|
+
...this.option.yAxisOption
|
|
8417
8901
|
}, options || {});
|
|
8418
8902
|
|
|
8419
8903
|
if (typeof this.option.minYValue !== 'undefined') {
|
|
@@ -8445,6 +8929,7 @@ define(['exports'], function (exports) { 'use strict';
|
|
|
8445
8929
|
'bar': jmBarSeries,
|
|
8446
8930
|
'stackBar': jmStackBarSeries,
|
|
8447
8931
|
'pie': jmPieSeries,
|
|
8932
|
+
'radar': jmRadarSeries,
|
|
8448
8933
|
'stackLine': jmStackLineSeries,
|
|
8449
8934
|
'candlestick': jmCandlestickSeries
|
|
8450
8935
|
};
|