jmchart 1.1.95 → 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.
@@ -5379,7 +5379,6 @@ System.register([], function (exports) {
5379
5379
  zIndex: 17,
5380
5380
  cursor: 'default',
5381
5381
  close: true,
5382
- opacity: 0.8,
5383
5382
  shadow: {
5384
5383
  x: 1,
5385
5384
  y: 1,
@@ -5408,7 +5407,34 @@ System.register([], function (exports) {
5408
5407
  zIndex: 11,
5409
5408
  cursor: 'default',
5410
5409
  close: true,
5411
- opacity: 0.8,
5410
+ shadow: {
5411
+ x: 1,
5412
+ y: 1,
5413
+ blur: 2,
5414
+ color: '#ccc'
5415
+ }
5416
+ },
5417
+ radar: {
5418
+ normal: {
5419
+ zIndex: 11,
5420
+ cursor: 'default',
5421
+ opacity: 0.8
5422
+ },
5423
+ hover: {
5424
+ //zIndex: 100,
5425
+ opacity: 1,
5426
+ cursor: 'pointer'
5427
+ },
5428
+ margin: {
5429
+ left: 10,
5430
+ top: 10,
5431
+ right: 10,
5432
+ bottom: 10
5433
+ },
5434
+ lineWidth: 1,
5435
+ zIndex: 11,
5436
+ cursor: 'default',
5437
+ close: true,
5412
5438
  shadow: {
5413
5439
  x: 1,
5414
5440
  y: 1,
@@ -5462,6 +5488,8 @@ System.register([], function (exports) {
5462
5488
 
5463
5489
  _defineProperty(this, "scalePoints", []);
5464
5490
 
5491
+ _defineProperty(this, "labels", []);
5492
+
5465
5493
  this.arrowVisible = !!options.arrowVisible;
5466
5494
  this.zeroBase = options.zeroBase || false;
5467
5495
  this.labelCount = options.labelCount || 5;
@@ -5475,6 +5503,8 @@ System.register([], function (exports) {
5475
5503
 
5476
5504
  this.field = options.field || '';
5477
5505
  this.index = options.index || 0;
5506
+ this.gridLines = []; // 线条数组
5507
+
5478
5508
  this.init(options);
5479
5509
  } // 初始化一些参数
5480
5510
  // 这个函数可能会重入。
@@ -5484,6 +5514,8 @@ System.register([], function (exports) {
5484
5514
  options = options || {}; // 深度组件默认样式
5485
5515
 
5486
5516
  if (options.style) this.graph.utils.clone(options.style, this.style, true);
5517
+ this.field = options.field || this.field || '';
5518
+ this.radarOption = options.radarOption;
5487
5519
 
5488
5520
  if (this.type == 'x') {
5489
5521
  if (typeof options.maxXValue !== 'undefined') this.maxValue = options.maxXValue; // 最大的值,如果指定了,则如果有数值比它大才会修改上限,否则以它为上限
@@ -5512,6 +5544,24 @@ System.register([], function (exports) {
5512
5544
 
5513
5545
  set data(d) {
5514
5546
  this.graph.data = d;
5547
+ } // 生成绘制点,
5548
+ // 重写原函数
5549
+
5550
+
5551
+ initPoints() {
5552
+ // 如果是雷达图
5553
+ if (this.radarOption && this.type === 'x') {
5554
+ this.points = [];
5555
+
5556
+ for (const axis of this.radarOption.yAxises) {
5557
+ this.points.push(axis.end);
5558
+ }
5559
+
5560
+ this.points.push(this.points[0]);
5561
+ return this.points;
5562
+ } else {
5563
+ return super.initPoints();
5564
+ }
5515
5565
  }
5516
5566
  /**
5517
5567
  * 计算当前轴的位置
@@ -5527,7 +5577,39 @@ System.register([], function (exports) {
5527
5577
  case 'x':
5528
5578
  {
5529
5579
  //初始化显示标签个数
5530
- this.labelCount = this.style.xLabel.count || 5;
5580
+ this.labelCount = this.style.xLabel.count || 5; // 如果是雷达图,则画栅格线
5581
+
5582
+ if (this.radarOption) {
5583
+ if (this.style.grid && this.style.grid.x) {
5584
+ for (let i = 1; i < this.labelCount + 1; i++) {
5585
+ const points = [];
5586
+ const curRadius = this.radarOption.radius / this.labelCount * i;
5587
+
5588
+ for (const axis of this.radarOption.yAxises) {
5589
+ const point = {};
5590
+ point.x = axis.radarOption.center.x + axis.radarOption.cos * curRadius + bounds.left;
5591
+ point.y = axis.radarOption.center.y - axis.radarOption.sin * curRadius + bounds.top;
5592
+ points.push(point);
5593
+ } // 画栅格线
5594
+
5595
+
5596
+ for (let j = 0; j < points.length; j++) {
5597
+ const start = points[j];
5598
+ const end = points[j + 1] || points[0];
5599
+ const gridLine = this.graph.createShape('line', {
5600
+ start,
5601
+ end,
5602
+ style: this.style.grid
5603
+ });
5604
+ this.parent.children.add(gridLine);
5605
+ this.gridLines.push(gridLine);
5606
+ }
5607
+ }
5608
+ }
5609
+
5610
+ break;
5611
+ }
5612
+
5531
5613
  this.start.x = bounds.left;
5532
5614
  this.start.y = bounds.bottom;
5533
5615
  this.end.x = bounds.right;
@@ -5546,21 +5628,30 @@ System.register([], function (exports) {
5546
5628
 
5547
5629
  case 'y':
5548
5630
  {
5549
- const index = this.index || 1;
5550
- let xoffset = bounds.left; //初始化显示标签个数
5631
+ //初始化显示标签个数
5632
+ this.labelCount = this.style.yLabel.count || 5;
5633
+ const index = this.index || 1; // 如果是雷达图,则画发散的线
5634
+
5635
+ if (this.radarOption) {
5636
+ this.end.x = this.radarOption.center.x + this.radarOption.cos * this.radarOption.radius + bounds.left;
5637
+ this.end.y = this.radarOption.center.y - this.radarOption.sin * this.radarOption.radius + bounds.top;
5638
+ this.start.x = this.radarOption.center.x + bounds.left;
5639
+ this.start.y = this.radarOption.center.y + bounds.top;
5640
+ } else {
5641
+ let xoffset = bounds.left; //多Y轴时,第二个为右边第一轴,其它的依此递推
5551
5642
 
5552
- this.labelCount = this.style.yLabel.count || 5; //多Y轴时,第二个为右边第一轴,其它的依此递推
5643
+ if (index == 2) {
5644
+ xoffset = bounds.right;
5645
+ } else if (index > 2) {
5646
+ xoffset = this.graph.yAxises[index - 1].start.x + this.graph.yAxises[index - 1].width + 10;
5647
+ }
5553
5648
 
5554
- if (index == 2) {
5555
- xoffset = bounds.right;
5556
- } else if (index > 2) {
5557
- xoffset = this.graph.yAxises[index - 1].start.x + this.graph.yAxises[index - 1].width + 10;
5649
+ this.start.x = xoffset;
5650
+ this.start.y = bounds.bottom;
5651
+ this.end.x = this.start.x;
5652
+ this.end.y = bounds.top;
5558
5653
  }
5559
5654
 
5560
- this.start.x = xoffset;
5561
- this.start.y = bounds.bottom;
5562
- this.end.x = this.start.x;
5563
- this.end.y = bounds.top;
5564
5655
  break;
5565
5656
  }
5566
5657
  }
@@ -5582,11 +5673,12 @@ System.register([], function (exports) {
5582
5673
 
5583
5674
 
5584
5675
  createLabel() {
5585
- //移除原有的标签
5586
- this.children.each(function (i, c) {
5587
- c.remove();
5588
- }, true);
5589
- this.labels = []; //如果是?X轴则执行X轴标签生成
5676
+ if (this.visible === false) return; // 雷达图的标签单独处理
5677
+
5678
+ if (this.radarOption) {
5679
+ return this.createRadarLabel();
5680
+ } //如果是?X轴则执行X轴标签生成
5681
+
5590
5682
 
5591
5683
  if (this.type == 'x') {
5592
5684
  this.createXLabel();
@@ -5706,13 +5798,7 @@ System.register([], function (exports) {
5706
5798
 
5707
5799
  let count = this.labelCount;
5708
5800
  const mm = max - min;
5709
- /*if(mm <= 10) {
5710
- count = mm;
5711
- }*/
5712
- // mm 放大10000倍,这里结果也需要除于10000
5713
-
5714
- let pervalue = mm / count || 1; //if(pervalue > 1 || pervalue < -1) pervalue = Math.floor(pervalue);
5715
-
5801
+ let pervalue = mm / count || 1;
5716
5802
  const format = this.option.format || this.format;
5717
5803
  const marginLeft = this.style.yLabel.margin.left * this.graph.devicePixelRatio || 0;
5718
5804
  const marginRight = this.style.yLabel.margin.right * this.graph.devicePixelRatio || 0;
@@ -5723,7 +5809,7 @@ System.register([], function (exports) {
5723
5809
  if (p > max || i === count) p = max;
5724
5810
  const h = (p - min) * step; // 当前点的偏移高度
5725
5811
 
5726
- const label = this.graph.graph.createShape('label', {
5812
+ const label = this.graph.createShape('label', {
5727
5813
  style: this.style.yLabel
5728
5814
  });
5729
5815
  label.text = format.call(this, p, label); // 格式化label
@@ -5756,7 +5842,7 @@ System.register([], function (exports) {
5756
5842
  y: offy + this.end.y
5757
5843
  }); // 指定要显示网格
5758
5844
 
5759
- if (this.style.grid && this.style.grid.x) {
5845
+ if (!this.radarOption && this.style.grid && this.style.grid.x) {
5760
5846
  // 它的坐标是相对于轴的,所以Y轴会用负的区域高度
5761
5847
  const line = this.graph.createShape('line', {
5762
5848
  start: {
@@ -5819,6 +5905,42 @@ System.register([], function (exports) {
5819
5905
  }
5820
5906
  }
5821
5907
  }
5908
+ /**
5909
+ * 生成雷达图的Y轴标签
5910
+ */
5911
+
5912
+
5913
+ createRadarLabel() {
5914
+ const format = this.option.format;
5915
+ const bounds = this.graph.chartArea.getBounds(); // 获取画图区域
5916
+
5917
+ const self = this;
5918
+ const label = this.graph.createShape('label', {
5919
+ style: this.style.yLabel,
5920
+ position: function () {
5921
+ // 因为axis是相对于chart的,而center是相对于chartArea的,所以要计算axis位置相对于chartArea来比较
5922
+ const pos = {
5923
+ x: self.end.x - bounds.left,
5924
+ y: self.end.y - bounds.top
5925
+ };
5926
+ const size = this.testSize();
5927
+
5928
+ if (pos.x < self.radarOption.center.x) {
5929
+ pos.x -= size.width;
5930
+ }
5931
+
5932
+ if (pos.y < self.radarOption.center.y) {
5933
+ pos.y -= size.height;
5934
+ }
5935
+
5936
+ return pos;
5937
+ }
5938
+ });
5939
+ label.text = typeof format === 'function' ? format.call(this, label) : this.field; // 格式化label
5940
+
5941
+ this.labels.push(label);
5942
+ this.graph.chartArea.children.add(label);
5943
+ }
5822
5944
  /**
5823
5945
  * 获取当前轴所占宽
5824
5946
  *
@@ -5966,6 +6088,18 @@ System.register([], function (exports) {
5966
6088
  clear() {
5967
6089
  this._min = null;
5968
6090
  this._max = null;
6091
+ this.children.each((i, c) => {
6092
+ c.remove();
6093
+ }, true); // 清空栅格线
6094
+
6095
+ this.gridLines && this.gridLines.forEach(line => {
6096
+ line.remove();
6097
+ });
6098
+ this.labels && this.labels.forEach(label => {
6099
+ label.remove();
6100
+ });
6101
+ this.labels = [];
6102
+ this.gridLines = [];
5969
6103
  }
5970
6104
  /**
5971
6105
  * 计算当前轴的单位偏移量
@@ -5977,7 +6111,7 @@ System.register([], function (exports) {
5977
6111
 
5978
6112
  step() {
5979
6113
  if (this.type == 'x') {
5980
- const w = this.width; //如果排版为内联,则单位占宽减少一个单位,
6114
+ const w = this.radarOption ? this.radarOption.radius : this.width; //如果排版为内联,则单位占宽减少一个单位,
5981
6115
  //也就是起始位从一个单位开始
5982
6116
 
5983
6117
  if (this.graph.style.layout == 'inside') {
@@ -5993,7 +6127,7 @@ System.register([], function (exports) {
5993
6127
 
5994
6128
  return w / tmp;
5995
6129
  } else if (this.type == 'y') {
5996
- const h = this.height;
6130
+ const h = this.radarOption ? this.radarOption.radius : this.height;
5997
6131
 
5998
6132
  switch (this.dataType) {
5999
6133
  case 'string':
@@ -6257,7 +6391,7 @@ System.register([], function (exports) {
6257
6391
  }); // 初始化一些参数, 因为这里有多个Y轴的可能,所以每次都需要重调一次init
6258
6392
 
6259
6393
  this.yAxis.init({
6260
- field: this.field,
6394
+ field: Array.isArray(this.field) ? this.field[0] : this.field,
6261
6395
  minYValue: options.minYValue,
6262
6396
  maxYValue: options.maxYValue
6263
6397
  });
@@ -6312,6 +6446,11 @@ System.register([], function (exports) {
6312
6446
  if (dataChanged) this.___animateCounter = 0; // 数据改变。动画重新开始
6313
6447
  } else {
6314
6448
  this.dataPoints = this.createPoints(...args);
6449
+ } // 执行初始化函数回调
6450
+
6451
+
6452
+ if (this.option && this.option.onInit) {
6453
+ this.option.onInit.apply(this, args);
6315
6454
  }
6316
6455
 
6317
6456
  return {
@@ -6380,12 +6519,12 @@ System.register([], function (exports) {
6380
6519
 
6381
6520
  while (shape = this.shapes.shift()) {
6382
6521
  shape && shape.remove();
6383
- } //生成图例 这里要放到shape清理后面
6384
-
6522
+ }
6385
6523
 
6386
- this.createLegend();
6387
6524
  this.initAxisValue(); // 处理最大值最小值
6525
+ //生成图例 这里要放到shape清理后面
6388
6526
 
6527
+ this.createLegend();
6389
6528
  return this.chartInfo = {
6390
6529
  xAxis: this.xAxis,
6391
6530
  yAxis: this.yAxis
@@ -6511,6 +6650,7 @@ System.register([], function (exports) {
6511
6650
  style
6512
6651
  });
6513
6652
  this.graph.legend.append(this, shape);
6653
+ return shape;
6514
6654
  } // 生成柱图的标注
6515
6655
 
6516
6656
 
@@ -6776,15 +6916,18 @@ System.register([], function (exports) {
6776
6916
 
6777
6917
  for (let index = 0; index < point.points.length; index++) {
6778
6918
  const style = this.graph.utils.clone(this.style);
6919
+ const p = point.points[index];
6779
6920
 
6780
6921
  if (style.color && typeof style.color === 'function') {
6781
- style.fill = style.color.call(this, this, index);
6922
+ style.fill = style.color.call(this, {
6923
+ index,
6924
+ point: p
6925
+ });
6782
6926
  } else {
6783
6927
  style.fill = this.graph.getColor(index);
6784
6928
  }
6785
6929
 
6786
6930
  const sp = this.addShape(this.graph.createPath(null, style));
6787
- const p = point.points[index];
6788
6931
  let startY = topStartY;
6789
6932
  if (p.yValue < this.baseYValue) startY = bottomStartY; //首先确定p1和p4,因为他们是底脚。会固定
6790
6933
 
@@ -6918,7 +7061,7 @@ System.register([], function (exports) {
6918
7061
  x: this.graph.chartArea.width / 2,
6919
7062
  y: this.graph.chartArea.height / 2
6920
7063
  };
6921
- const radius = Math.min(center.x - this.style.margin.left - this.style.margin.right * this.graph.devicePixelRatio, center.y - this.style.margin.top * this.graph.devicePixelRatio - this.style.margin.bottom * this.graph.devicePixelRatio); //生成描点位
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); //生成描点位
6922
7065
  // super.init会把参数透传给 createPoints
6923
7066
 
6924
7067
  const {
@@ -7010,7 +7153,8 @@ System.register([], function (exports) {
7010
7153
  // 每个数值点比
7011
7154
  style: this.graph.utils.clone(this.style),
7012
7155
  anticlockwise
7013
- }; //p.style.color = this.graph.getColor(index);
7156
+ };
7157
+ points.push(p); //p.style.color = this.graph.getColor(index);
7014
7158
 
7015
7159
  if (p.style.color && typeof p.style.color === 'function') {
7016
7160
  p.style.fill = p.style.color.call(this, p);
@@ -7091,34 +7235,34 @@ System.register([], function (exports) {
7091
7235
 
7092
7236
  if (this.option.onClick) {
7093
7237
  p.shape.on('click', e => {
7094
- this.option.onClick.call(this, p, e);
7238
+ return this.option.onClick.call(this, p, e);
7095
7239
  });
7096
7240
  }
7097
7241
 
7098
7242
  if (this.option.onOver) {
7099
7243
  p.shape.on('mouseover touchover', e => {
7100
- this.option.onOver.call(this, p, e);
7244
+ return this.option.onOver.call(this, p, e);
7101
7245
  });
7102
7246
  }
7103
7247
 
7104
7248
  if (this.option.onLeave) {
7105
7249
  p.shape.on('mouseleave touchleave', e => {
7106
- this.option.onLeave.call(this, p, e);
7250
+ return this.option.onLeave.call(this, p, e);
7107
7251
  });
7108
7252
  }
7109
7253
 
7110
7254
  this.createLabel(p); // 生成标签
7111
- }
7255
+ // 生成标点的回调
7112
7256
 
7113
- points.push(p);
7114
- index++; // 生成标点的回调
7257
+ this.emit('onPointCreated', p);
7258
+ }
7115
7259
 
7116
- this.emit('onPointCreated', p);
7260
+ index++;
7117
7261
  }
7118
7262
  }
7119
7263
 
7120
7264
  return points;
7121
- } // 生成柱图的标注
7265
+ } // 生成图的标注
7122
7266
 
7123
7267
 
7124
7268
  createLabel(point) {
@@ -7142,7 +7286,7 @@ System.register([], function (exports) {
7142
7286
  }; // 动态计算位置
7143
7287
 
7144
7288
  const parentRect = this.parent.getBounds(); //const rect = this.getBounds.call(this.parent);
7145
- // 圆弧的中间位,离圆心最近和最完的二个点
7289
+ // 圆弧的中间位,离圆心最近和最远的二个点
7146
7290
 
7147
7291
  let centerMaxPoint = this.parent.points[Math.floor(this.parent.points.length / 2)];
7148
7292
  let centerMinPoint = this.parent.center; // 如果是空心圆,则要计算 1/4 和 3/4位的点。顺时针和逆时针二个点大小不一样,这里只取,大小计算时处理
@@ -7219,6 +7363,329 @@ System.register([], function (exports) {
7219
7363
  }
7220
7364
  };
7221
7365
 
7366
+ /**
7367
+ * 雷达图
7368
+ *
7369
+ * @class jmRadarSeries
7370
+ * @module jmChart
7371
+ * @param {jmChart} chart 当前图表
7372
+ * @param {array} mappings 图形字段映射
7373
+ * @param {style} style 样式
7374
+ */
7375
+ //构造函数
7376
+
7377
+ class jmRadarSeries extends jmSeries {
7378
+ constructor(options) {
7379
+ super(options);
7380
+ } // 重新生成轴,雷达图只需要Y轴即可
7381
+
7382
+
7383
+ createAxises(center, radius) {
7384
+ this.axises = [this.yAxis];
7385
+ const yCount = this.field.length;
7386
+ if (!yCount) return; //每个维度点的角度
7387
+
7388
+ const rotateStep = Math.PI * 2 / yCount; // 清空除了一个默认外的所有Y轴
7389
+
7390
+ for (let index in this.graph.yAxises) {
7391
+ const axis = this.graph.yAxises[index];
7392
+ if (!axis || axis === this.yAxis) continue;
7393
+ axis.remove();
7394
+ delete this.graph.yAxises[index];
7395
+ }
7396
+
7397
+ for (let index = 0; index < yCount; index++) {
7398
+ if (!this.field[index]) continue;
7399
+ let axis = this.yAxis; // 除了默认的y轴外,其它都重新生成
7400
+
7401
+ if (index > 0) {
7402
+ axis = this.graph.createYAxis({
7403
+ index: index + 1,
7404
+ format: this.option.yLabelFormat || this.graph.option.yLabelFormat
7405
+ });
7406
+ this.axises.push(axis);
7407
+ }
7408
+
7409
+ const rotate = Math.PI / 2 + rotateStep * index; //从向上90度开始
7410
+
7411
+ axis.init({
7412
+ field: this.field[index],
7413
+ radarOption: {
7414
+ center,
7415
+ radius,
7416
+ yCount,
7417
+ rotate: rotate,
7418
+ cos: Math.cos(rotate),
7419
+ sin: Math.sin(rotate)
7420
+ }
7421
+ });
7422
+ } // x轴初始化
7423
+
7424
+
7425
+ this.xAxis.init({
7426
+ radarOption: {
7427
+ center,
7428
+ radius,
7429
+ yCount,
7430
+ yAxises: this.axises
7431
+ }
7432
+ });
7433
+ return this.axises;
7434
+ } // 计算最大值和最小值,一般图形直接采用最大最小值即可,有些需要多值叠加
7435
+
7436
+
7437
+ initAxisValue() {
7438
+ this.center = {
7439
+ x: this.graph.chartArea.width / 2,
7440
+ y: this.graph.chartArea.height / 2
7441
+ };
7442
+ 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);
7443
+ const axises = this.createAxises(this.center, this.radius); // 重置所有轴
7444
+ // 计算最大最小值
7445
+ // 当前需要先更新axis的边界值,轴好画图
7446
+
7447
+ for (let i = 0; i < this.data.length; i++) {
7448
+ axises.forEach(axis => {
7449
+ const v = this.data[i][axis.field];
7450
+ axis.max(v);
7451
+ axis.min(v);
7452
+ });
7453
+ }
7454
+ } // 重新初始化图形
7455
+
7456
+
7457
+ init() {
7458
+ //生成描点位
7459
+ // super.init会把参数透传给 createPoints
7460
+ const {
7461
+ points,
7462
+ dataChanged
7463
+ } = this.initDataPoint(this.center, this.radius);
7464
+ this.createLegend(points); // 是否正在动画中
7465
+
7466
+ const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0);
7467
+ const aniCount = this.style.aniCount || 20;
7468
+ let aniIsEnd = true; // 当次是否结束动画
7469
+
7470
+ const len = points.length;
7471
+ const shapeMap = {};
7472
+ const self = this;
7473
+
7474
+ for (let i = 0; i < len; i++) {
7475
+ const p = points[i];
7476
+ let shape = shapeMap[p.index];
7477
+
7478
+ if (!shape) {
7479
+ shape = shapeMap[p.index] = this.graph.createShape('path', { ...p,
7480
+ style: p.style,
7481
+ points: []
7482
+ });
7483
+ this.addShape(shape); // 如果有点击事件
7484
+
7485
+ if (this.option.onClick) {
7486
+ shape.on('click', function (e) {
7487
+ return self.option.onClick.call(this, e);
7488
+ });
7489
+ }
7490
+
7491
+ if (this.option.onOver) {
7492
+ shape.on('mouseover touchover', function (e) {
7493
+ return self.option.onOver.call(this, e);
7494
+ });
7495
+ }
7496
+
7497
+ if (this.option.onLeave) {
7498
+ shape.on('mouseleave touchleave', function (e) {
7499
+ return self.option.onLeave.call(this, e);
7500
+ });
7501
+ }
7502
+ }
7503
+
7504
+ shape.zIndex += p.radius / this.radius; // 用每个轴占比做为排序号,这样占面积最大的排最底层
7505
+
7506
+ let point = null; // 在动画中,则一直刷新
7507
+
7508
+ if (isRunningAni) {
7509
+ let step = p.radius / aniCount * this.___animateCounter;
7510
+
7511
+ if (step >= p.radius) {
7512
+ step = p.radius;
7513
+ } else {
7514
+ aniIsEnd = false;
7515
+ }
7516
+
7517
+ point = { ...p,
7518
+ x: this.center.x + p.axis.radarOption.cos * step,
7519
+ y: this.center.y - p.axis.radarOption.sin * step
7520
+ };
7521
+ } else {
7522
+ point = p;
7523
+ }
7524
+
7525
+ shape.points.push(point);
7526
+ this.createLabel(point); // 生成标签
7527
+ } // 所有动画都完成,则清空计数器
7528
+
7529
+
7530
+ if (aniIsEnd) {
7531
+ this.___animateCounter = 0;
7532
+ } else {
7533
+ this.___animateCounter++; // next tick 再次刷新
7534
+
7535
+ this.graph.utils.requestAnimationFrame(() => {
7536
+ this.needUpdate = true; //需要刷新
7537
+ });
7538
+ }
7539
+ }
7540
+ /**
7541
+ * 生成序列图描点
7542
+ *
7543
+ * @method createPoints
7544
+ */
7545
+
7546
+
7547
+ createPoints(center, radius) {
7548
+ if (!this.data || !this.axises) return [];
7549
+ center = center || this.center;
7550
+ const points = [];
7551
+
7552
+ for (var i = 0; i < this.data.length; i++) {
7553
+ const s = this.data[i];
7554
+ const style = this.graph.utils.clone(this.style);
7555
+
7556
+ if (style.color && typeof style.color === 'function') {
7557
+ style.stroke = style.color.call(this, {
7558
+ data: s,
7559
+ index: i
7560
+ });
7561
+ } else {
7562
+ style.stroke = this.graph.getColor(i);
7563
+ }
7564
+
7565
+ if (typeof style.fill === 'function') {
7566
+ style.fill = style.fill.call(this, style);
7567
+ } else {
7568
+ const color = this.graph.utils.hexToRGBA(style.stroke);
7569
+ style.fill = `rgba(${color.r},${color.g},${color.b}, 0.2)`;
7570
+ }
7571
+
7572
+ const shapePoints = [];
7573
+
7574
+ for (const axis of this.axises) {
7575
+ const yv = s[axis.field];
7576
+ const p = {
7577
+ x: center.x,
7578
+ y: center.y,
7579
+ index: i,
7580
+ radius: 0,
7581
+ data: s,
7582
+ yValue: yv,
7583
+ yLabel: yv,
7584
+ style,
7585
+ axis
7586
+ };
7587
+ shapePoints.push(p); //如果Y值不存在。则此点无效,不画图
7588
+
7589
+ if (yv == null || typeof yv == 'undefined') {
7590
+ continue;
7591
+ }
7592
+
7593
+ p.radius = Math.abs(yv - axis.min()) * axis.step();
7594
+ p.x = center.x + axis.radarOption.cos * p.radius;
7595
+ p.y = center.y - axis.radarOption.sin * p.radius; // 生成标点的回调
7596
+
7597
+ this.emit('onPointCreated', p);
7598
+ }
7599
+
7600
+ points.push(...shapePoints);
7601
+ }
7602
+
7603
+ return points;
7604
+ } // 生成图的标注
7605
+
7606
+
7607
+ createLabel(point) {
7608
+ if (this.style.label && this.style.label.show === false) return;
7609
+ const text = this.option.itemLabelFormat ? this.option.itemLabelFormat.call(this, point) : point.yValue;
7610
+ if (!text) return; // v如果指定了为控件,则直接加入
7611
+
7612
+ if (text instanceof jmControl) {
7613
+ this.addShape(text);
7614
+ return text;
7615
+ }
7616
+
7617
+ const self = this;
7618
+ const label = this.graph.createShape('label', {
7619
+ style: this.style.label,
7620
+ text: text,
7621
+ point,
7622
+ position: function () {
7623
+ const p = {
7624
+ x: this.option.point.x,
7625
+ y: this.option.point.y
7626
+ };
7627
+
7628
+ if (p.x < self.center.x) {
7629
+ p.x -= this.width;
7630
+ }
7631
+
7632
+ if (p.y < self.center.y) {
7633
+ p.y -= this.height;
7634
+ }
7635
+
7636
+ return p;
7637
+ }
7638
+ });
7639
+ this.addShape(label);
7640
+ }
7641
+
7642
+ }
7643
+ /**
7644
+ * 生成图例
7645
+ *
7646
+ * @method createLegend
7647
+ */
7648
+
7649
+ jmRadarSeries.prototype.createLegend = function (points) {
7650
+ if (!points || !points.length) return;
7651
+ const legendMap = {};
7652
+
7653
+ for (let k in points) {
7654
+ const p = points[k];
7655
+ if (!p) continue;
7656
+ if (legendMap[p.index]) continue; //生成图例前的图标
7657
+
7658
+ const style = this.graph.utils.clone(p.style);
7659
+ style.fill = style.fill; //delete style.stroke;
7660
+
7661
+ const shape = legendMap[p.index] = this.graph.createShape('rect', {
7662
+ style: style,
7663
+ position: {
7664
+ x: 0,
7665
+ y: 0
7666
+ }
7667
+ }); //shape.targetShape = p.shape;
7668
+ //此处重写图例事件
7669
+
7670
+ this.graph.legend.append(this, shape, {
7671
+ name: this.legendLabel,
7672
+ hover: function () {
7673
+ //var sp = this.children.get(0);
7674
+ //应用图的动态样式
7675
+ Object.assign(this.targetShape.style, this.targetShape.style.hover);
7676
+ Object.assign(this.style, this.style.hover);
7677
+ },
7678
+ leave: function () {
7679
+ //var sp = this.children.get(0);
7680
+ //应用图的普通样式
7681
+ Object.assign(this.targetShape.style, this.targetShape.style.normal);
7682
+ Object.assign(this.style, this.style.normal);
7683
+ },
7684
+ data: p.data
7685
+ });
7686
+ }
7687
+ };
7688
+
7222
7689
  /**
7223
7690
  * 图形基类
7224
7691
  *
@@ -8002,6 +8469,7 @@ System.register([], function (exports) {
8002
8469
 
8003
8470
  if (chart.style.markLine.lock) {
8004
8471
  // 标线状态一直禁用系统能力
8472
+ // 如果指定了锁定值,只需要一项符合要求就进行锁定
8005
8473
  if (lineTouching === 0 && (chart.style.markLine.lock.y && Math.abs(args.offsetInfo.y) < chart.style.markLine.lock.y || chart.style.markLine.lock.x && Math.abs(args.offsetInfo.x) < chart.style.markLine.lock.x) || lineTouching === 1) {
8006
8474
  lineTouching = 1;
8007
8475
  args.event.preventDefault(); // 阻止默认行为
@@ -8395,7 +8863,7 @@ System.register([], function (exports) {
8395
8863
  type: 'x',
8396
8864
  visible: this.style.axis.x === false ? false : true,
8397
8865
  format: this.option.xLabelFormat,
8398
- ...this.option.yAxisOption
8866
+ ...this.option.xAxisOption
8399
8867
  }, options || {});
8400
8868
 
8401
8869
  if (typeof this.option.minXValue !== 'undefined') {
@@ -8432,7 +8900,7 @@ System.register([], function (exports) {
8432
8900
  visible: this.style.axis.y === false ? false : true,
8433
8901
  format: this.option.yLabelFormat,
8434
8902
  zeroBase: this.baseY === 0,
8435
- ...this.option.xAxisOption
8903
+ ...this.option.yAxisOption
8436
8904
  }, options || {});
8437
8905
 
8438
8906
  if (typeof this.option.minYValue !== 'undefined') {
@@ -8464,6 +8932,7 @@ System.register([], function (exports) {
8464
8932
  'bar': jmBarSeries,
8465
8933
  'stackBar': jmStackBarSeries,
8466
8934
  'pie': jmPieSeries,
8935
+ 'radar': jmRadarSeries,
8467
8936
  'stackLine': jmStackLineSeries,
8468
8937
  'candlestick': jmCandlestickSeries
8469
8938
  };