jmchart 1.2.18 → 1.2.20

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.
@@ -116,7 +116,6 @@ export default class jmRadarSeries extends jmSeries {
116
116
  let aniIsEnd = true;// 当次是否结束动画
117
117
  const len = points.length;
118
118
  const shapeMap = {};
119
- const self = this;
120
119
 
121
120
  for(let i=0; i<len; i++) {
122
121
  const p = points[i];
@@ -130,19 +129,22 @@ export default class jmRadarSeries extends jmSeries {
130
129
  this.addShape(shape);
131
130
 
132
131
  // 如果有点击事件
132
+ if(this.option.onClick || this.option.onOver || this.option.onLeave) {
133
+ shape.interactive = true;
134
+ }
133
135
  if(this.option.onClick) {
134
- shape.on('click', function(e) {
135
- return self.option.onClick.call(this, e);
136
+ shape.on('click', (e) => {
137
+ return this.option.onClick.call(this, e);
136
138
  });
137
139
  }
138
140
  if(this.option.onOver) {
139
- shape.on('mouseover touchover', function(e) {
140
- return self.option.onOver.call(this, e);
141
+ shape.on('mouseover touchover', (e) => {
142
+ return this.option.onOver.call(this, e);
141
143
  });
142
144
  }
143
145
  if(this.option.onLeave) {
144
- shape.on('mouseleave touchleave', function(e) {
145
- return self.option.onLeave.call(this, e);
146
+ shape.on('mouseleave touchleave', (e) => {
147
+ return this.option.onLeave.call(this, e);
146
148
  });
147
149
  }
148
150
  this.createLegend(p);
@@ -194,7 +196,7 @@ export default class jmRadarSeries extends jmSeries {
194
196
  center = center || this.center;
195
197
  const points = [];
196
198
 
197
- for(var i=0;i< this.data.length;i++) {
199
+ for(let i=0;i< this.data.length;i++) {
198
200
  const s = this.data[i];
199
201
  let strokeColor;
200
202
  if(this.style.color && typeof this.style.color === 'function') {
@@ -268,53 +270,30 @@ export default class jmRadarSeries extends jmSeries {
268
270
  this.addShape(text);
269
271
  return text;
270
272
  }
271
- const self = this;
273
+
272
274
  const label = this.graph.createShape('label', {
273
- style: this.style.label,
274
- text: text,
275
- point,
276
- position: function() {
277
- const p = {
278
- x: this.option.point.x,
279
- y: this.option.point.y
280
- }
281
- if(p.x < self.center.x) {
282
- p.x -= this.width;
283
- }
284
-
285
- if(p.y < self.center.y) {
286
- p.y -= this.height;
287
- }
288
- return p;
289
- }
275
+ style: this.style.label || {},
276
+ text: text
290
277
  });
291
-
278
+ label.position = { x: point.x, y: point.y };
292
279
  this.addShape(label);
280
+ return label;
293
281
  }
294
- }
295
-
296
-
297
282
 
298
- /**
299
- * 生成图例
300
- *
301
- * @method createLegend
302
- */
303
- jmRadarSeries.prototype.createLegend = function(point) {
304
- if(!point) return;
283
+ /**
284
+ * 生成图例
285
+ */
286
+ createLegend(point) {
287
+ if(!point) return;
305
288
 
306
- //生成图例前的图标
307
- const style = this.graph.utils.clone(point.style);
308
-
309
- //delete style.stroke;
310
- const shape = this.graph.createShape('rect',{
311
- style: style,
312
- position : {x: 0, y: 0}
313
- });
314
- //此处重写图例事件
315
- this.graph.legend.append(this, shape, {
316
- name: this.legendLabel,
317
- data: point.data
318
- });
289
+ const style = this.graph.utils.clone(point.style);
290
+ const shape = this.graph.createShape('rect',{
291
+ style: style,
292
+ position : {x: 0, y: 0}
293
+ });
294
+ this.graph.legend.append(this, shape, {
295
+ name: this.legendLabel,
296
+ data: point.data
297
+ });
298
+ }
319
299
  }
320
-
@@ -105,7 +105,8 @@ export default class jmRangeSeries extends jmLineSeries {
105
105
  if(endShapePoints.length) endShapePoints[0].m = true;
106
106
  this.points = startShapePoints.concat(endShapePoints);
107
107
 
108
- const areaPoints = startShapePoints.concat(endShapePoints.reverse());
108
+ const reversedEndPoints = endShapePoints.slice().reverse();
109
+ const areaPoints = startShapePoints.concat(reversedEndPoints);
109
110
  const areaEnd = areaPoints[areaPoints.length - 1] = this.graph.utils.clone(areaPoints[areaPoints.length - 1]);
110
111
  areaEnd.m = false;
111
112
  this.createArea(areaPoints, false);
@@ -116,15 +117,15 @@ export default class jmRangeSeries extends jmLineSeries {
116
117
  */
117
118
  createLegend() {
118
119
 
119
- var style = this.graph.utils.clone(this.style);
120
+ const style = this.graph.utils.clone(this.style);
120
121
  style.stroke = style.color;
121
- var shape = this.graph.createShape('path',{style:style});
122
-
122
+ const shape = this.graph.createShape('path',{style:style});
123
+
123
124
  if(this.curve || this.style.curve) {
124
- var p1 = {x:0,y: this.graph.style.legend.item.shape.height};
125
- var p2 = {x:this.graph.style.legend.item.shape.width / 3,y:this.graph.style.legend.item.shape.height/3};
126
- var p3 = {x:this.graph.style.legend.item.shape.width / 3 * 2,y:this.graph.style.legend.item.shape.height/3*2};
127
- var p4 = {x:this.graph.style.legend.item.shape.width,y:0};
125
+ const p1 = {x:0,y: this.graph.style.legend.item.shape.height};
126
+ const p2 = {x:this.graph.style.legend.item.shape.width / 3,y:this.graph.style.legend.item.shape.height/3};
127
+ const p3 = {x:this.graph.style.legend.item.shape.width / 3 * 2,y:this.graph.style.legend.item.shape.height/3*2};
128
+ const p4 = {x:this.graph.style.legend.item.shape.width,y:0};
128
129
 
129
130
  this.__bezier = this.__bezier || this.graph.createShape('bezier');
130
131
  this.__bezier.cpoints = [
@@ -143,7 +144,3 @@ export default class jmRangeSeries extends jmLineSeries {
143
144
  this.graph.legend.append(this, shape);
144
145
  }
145
146
  }
146
-
147
- export {
148
- jmRangeSeries
149
- }
@@ -189,5 +189,3 @@ export default class jmRingProgressSeries extends jmSeries {
189
189
  this.graph.legend.append(this, shape);
190
190
  }
191
191
  }
192
-
193
- export { jmRingProgressSeries };
@@ -102,12 +102,11 @@ export default class jmScatterSeries extends jmSeries {
102
102
  * @for jmScatterSeries
103
103
  */
104
104
  createLegend() {
105
- // 生成图例前的图标
106
- var style = this.graph.utils.clone(this.style);
105
+ const style = this.graph.utils.clone(this.style);
107
106
  style.stroke = style.color;
108
107
  style.fill = style.color;
109
-
110
- var shape = this.graph.createShape('circle', {
108
+
109
+ const shape = this.graph.createShape('circle', {
111
110
  style: style,
112
111
  center: {
113
112
  x: this.graph.style.legend.item.shape.width / 2,
@@ -118,8 +117,4 @@ export default class jmScatterSeries extends jmSeries {
118
117
 
119
118
  this.graph.legend.append(this, shape);
120
119
  }
121
- }
122
-
123
- export {
124
- jmScatterSeries
125
120
  }
@@ -1,3 +1,4 @@
1
+ import jmSeries, { ANIMATION_DATA_THRESHOLD, DEFAULT_ANIMATION_COUNT } from './series.js';
1
2
  import jmBarSeries from './barSeries.js';
2
3
 
3
4
  /**
@@ -50,9 +51,9 @@ export default class jmStackBarSeries extends jmBarSeries {
50
51
 
51
52
  this.initWidth(len);
52
53
 
53
- const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0 ) && len < 100;
54
+ const isRunningAni = this.enableAnimate && (dataChanged || this.___animateCounter > 0 ) && len < ANIMATION_DATA_THRESHOLD;
54
55
  let aniIsEnd = true;
55
- const aniCount = (this.style.aniCount || 10);
56
+ const aniCount = (this.style.aniCount || DEFAULT_ANIMATION_COUNT);
56
57
 
57
58
  for(let i=0; i<len; i++) {
58
59
  const point = points[i];
@@ -15,7 +15,3 @@ export default class jmStackLineSeries extends jmRangeSeries {
15
15
  super(options);
16
16
  }
17
17
  }
18
-
19
- export {
20
- jmStackLineSeries
21
- }
@@ -173,7 +173,3 @@ export default class jmWaterfallSeries extends jmSeries {
173
173
  this.graph.legend.append(this, shape);
174
174
  }
175
175
  }
176
-
177
- export {
178
- jmWaterfallSeries
179
- }
@@ -55,8 +55,8 @@ export default class jmWordCloudSeries extends jmSeries {
55
55
  const xField = this.option.xField || 'word';
56
56
 
57
57
  const weights = data.map(item => Math.abs(item[field] || 0));
58
- const maxWeight = Math.max(...weights);
59
- const minWeight = Math.min(...weights);
58
+ const maxWeight = weights.reduce((a, b) => Math.max(a, b));
59
+ const minWeight = weights.reduce((a, b) => Math.min(a, b));
60
60
 
61
61
  if(maxWeight === 0) return;
62
62
 
@@ -230,5 +230,3 @@ export default class jmWordCloudSeries extends jmSeries {
230
230
  this.graph.legend.append(this, shape);
231
231
  }
232
232
  }
233
-
234
- export { jmWordCloudSeries };