jmchart 1.1.96 → 1.1.99

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.
@@ -108,8 +108,6 @@ export default class jmRadarSeries extends jmSeries {
108
108
  // super.init会把参数透传给 createPoints
109
109
  const { points, dataChanged } = this.initDataPoint(this.center, this.radius);
110
110
 
111
- this.createLegend(points);
112
-
113
111
  // 是否正在动画中
114
112
  const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0 );
115
113
 
@@ -146,6 +144,7 @@ export default class jmRadarSeries extends jmSeries {
146
144
  return self.option.onLeave.call(this, e);
147
145
  });
148
146
  }
147
+ this.createLegend(p);
149
148
  }
150
149
 
151
150
  shape.zIndex += p.radius / this.radius;// 用每个轴占比做为排序号,这样占面积最大的排最底层
@@ -216,6 +215,7 @@ export default class jmRadarSeries extends jmSeries {
216
215
 
217
216
  const shapePoints = [];
218
217
  for(const axis of this.axises) {
218
+ if(!axis || !axis.field) continue;
219
219
  const yv = s[axis.field];
220
220
 
221
221
  const p = {
@@ -293,40 +293,21 @@ export default class jmRadarSeries extends jmSeries {
293
293
  *
294
294
  * @method createLegend
295
295
  */
296
- jmRadarSeries.prototype.createLegend = function(points) {
297
- if(!points || !points.length) return;
296
+ jmRadarSeries.prototype.createLegend = function(point) {
297
+ if(!point) return;
298
298
 
299
- const legendMap = {};
300
- for(let k in points) {
301
- const p = points[k];
302
- if(!p) continue;
303
- if(legendMap[p.index]) continue;
304
- //生成图例前的图标
305
- const style = this.graph.utils.clone(p.style);
306
- style.fill = style.fill;
307
- //delete style.stroke;
308
- const shape = legendMap[p.index] = this.graph.createShape('rect',{
309
- style: style,
310
- position : {x: 0, y: 0}
311
- });
312
- //shape.targetShape = p.shape;
313
- //此处重写图例事件
314
- this.graph.legend.append(this, shape, {
315
- name: this.legendLabel,
316
- hover: function() {
317
- //var sp = this.children.get(0);
318
- //应用图的动态样式
319
- Object.assign(this.targetShape.style, this.targetShape.style.hover);
320
- Object.assign(this.style, this.style.hover);
321
- },
322
- leave: function() {
323
- //var sp = this.children.get(0);
324
- //应用图的普通样式
325
- Object.assign(this.targetShape.style, this.targetShape.style.normal);
326
- Object.assign(this.style, this.style.normal);
327
- },
328
- data: p.data
329
- });
330
- }
299
+ //生成图例前的图标
300
+ const style = this.graph.utils.clone(point.style);
301
+
302
+ //delete style.stroke;
303
+ const shape = this.graph.createShape('rect',{
304
+ style: style,
305
+ position : {x: 0, y: 0}
306
+ });
307
+ //此处重写图例事件
308
+ this.graph.legend.append(this, shape, {
309
+ name: this.legendLabel,
310
+ data: point.data
311
+ });
331
312
  }
332
313
 
@@ -260,7 +260,9 @@ export default class jmSeries extends jmPath {
260
260
  // 这里的点应相对于chartArea
261
261
  p.x = xstep * i + this.xAxis.labelStart;
262
262
 
263
- for(const f of fields) {
263
+ for(let j=0; j<fields.length; j++) {
264
+ const f = fields[j];
265
+
264
266
  const yv = s[f];
265
267
  p.yLabel = p.yValue = yv;
266
268
  // 高度
@@ -120,7 +120,8 @@ export default class jmStackBarSeries extends jmBarSeries {
120
120
 
121
121
  for(const row of this.data) {
122
122
  let max, min;
123
- for(const f of fields) {
123
+ for(let i=0; i<fields.length; i++) {
124
+ const f = fields[i];
124
125
  const v = Number(row[f]);
125
126
  if(typeof max === 'undefined') max = v;
126
127
  else {