echarts 4.2.0-rc.2 → 4.2.1

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.
Files changed (82) hide show
  1. package/KEYS +60 -0
  2. package/LICENSE +7 -8
  3. package/dist/echarts-en.common.js +1250 -717
  4. package/dist/echarts-en.common.min.js +1 -1
  5. package/dist/echarts-en.js +2284 -1763
  6. package/dist/echarts-en.js.map +1 -1
  7. package/dist/echarts-en.min.js +1 -1
  8. package/dist/echarts-en.simple.js +1001 -560
  9. package/dist/echarts-en.simple.min.js +1 -1
  10. package/dist/echarts.common.js +1250 -717
  11. package/dist/echarts.common.min.js +1 -1
  12. package/dist/echarts.js +2284 -1763
  13. package/dist/echarts.js.map +1 -1
  14. package/dist/echarts.min.js +1 -1
  15. package/dist/echarts.simple.js +1001 -560
  16. package/dist/echarts.simple.min.js +1 -1
  17. package/dist/extension/dataTool.js +32 -33
  18. package/dist/extension/dataTool.js.map +1 -1
  19. package/lib/chart/graph/GraphView.js +17 -9
  20. package/lib/chart/graph/forceHelper.js +15 -20
  21. package/lib/chart/helper/Line.js +5 -1
  22. package/lib/chart/map/MapSeries.js +32 -26
  23. package/lib/chart/map/MapView.js +93 -40
  24. package/lib/chart/pie/labelLayout.js +23 -16
  25. package/lib/chart/sankey/sankeyLayout.js +18 -17
  26. package/lib/chart/sunburst/SunburstPiece.js +10 -5
  27. package/lib/chart/themeRiver/ThemeRiverSeries.js +26 -29
  28. package/lib/chart/tree/layoutHelper.js +57 -10
  29. package/lib/chart/treemap/treemapLayout.js +13 -7
  30. package/lib/component/axis/AxisBuilder.js +11 -2
  31. package/lib/component/helper/MapDraw.js +4 -0
  32. package/lib/component/helper/RoamController.js +3 -3
  33. package/lib/component/legend/LegendView.js +19 -1
  34. package/lib/component/legend/ScrollableLegendView.js +105 -70
  35. package/lib/coord/axisHelper.js +24 -1
  36. package/lib/coord/axisTickLabelBuilder.js +7 -12
  37. package/lib/coord/geo/Geo.js +1 -1
  38. package/lib/data/List.js +111 -36
  39. package/lib/echarts.js +13 -4
  40. package/lib/model/Model.js +1 -1
  41. package/lib/model/mixin/textStyle.js +1 -1
  42. package/lib/scale/Time.js +14 -4
  43. package/lib/util/format.js +30 -1
  44. package/lib/util/graphic.js +114 -27
  45. package/lib/util/model.js +27 -1
  46. package/lib/util/number.js +12 -33
  47. package/lib/visual/visualSolution.js +1 -1
  48. package/package.json +3 -4
  49. package/src/chart/graph/GraphView.js +15 -10
  50. package/src/chart/graph/forceHelper.js +17 -24
  51. package/src/chart/helper/Line.js +5 -1
  52. package/src/chart/map/MapSeries.js +28 -31
  53. package/src/chart/map/MapView.js +96 -38
  54. package/src/chart/pie/labelLayout.js +19 -14
  55. package/src/chart/sankey/sankeyLayout.js +17 -19
  56. package/src/chart/sunburst/SunburstPiece.js +11 -3
  57. package/src/chart/themeRiver/ThemeRiverSeries.js +18 -33
  58. package/src/chart/tree/layoutHelper.js +56 -10
  59. package/src/chart/treemap/treemapLayout.js +13 -7
  60. package/src/component/axis/AxisBuilder.js +7 -1
  61. package/src/component/helper/MapDraw.js +5 -1
  62. package/src/component/helper/RoamController.js +3 -4
  63. package/src/component/legend/LegendView.js +20 -1
  64. package/src/component/legend/ScrollableLegendView.js +119 -85
  65. package/src/coord/axisHelper.js +19 -0
  66. package/src/coord/axisTickLabelBuilder.js +10 -13
  67. package/src/coord/geo/Geo.js +1 -1
  68. package/src/data/List.js +107 -28
  69. package/src/echarts.js +11 -5
  70. package/src/model/Model.js +1 -1
  71. package/src/model/mixin/textStyle.js +1 -0
  72. package/src/scale/Time.js +14 -4
  73. package/src/util/format.js +39 -1
  74. package/src/util/graphic.js +110 -28
  75. package/src/util/model.js +25 -0
  76. package/src/util/number.js +12 -33
  77. package/src/visual/visualSolution.js +1 -1
  78. package/extension/dataTool/quantile.js +0 -82
  79. package/lib/component/tooltip/TooltipContentManager.js +0 -126
  80. package/lib/util/nest.js +0 -148
  81. package/src/component/tooltip/TooltipContentManager.js +0 -120
  82. package/src/util/nest.js +0 -127
@@ -46,6 +46,10 @@ var _vector = require("zrender/lib/core/vector");
46
46
 
47
47
  var v2ApplyTransform = _vector.applyTransform;
48
48
 
49
+ var _axisHelper = require("../../coord/axisHelper");
50
+
51
+ var shouldShowAllLabels = _axisHelper.shouldShowAllLabels;
52
+
49
53
  /*
50
54
  * Licensed to the Apache Software Foundation (ASF) under one
51
55
  * or more contributor license agreements. See the NOTICE file
@@ -238,7 +242,8 @@ var builders = {
238
242
  symbol.attr({
239
243
  rotation: point.rotate,
240
244
  position: pos,
241
- silent: true
245
+ silent: true,
246
+ z2: 11
242
247
  });
243
248
  this.group.add(symbol);
244
249
  }
@@ -438,9 +443,13 @@ function isSilent(axisModel) {
438
443
  }
439
444
 
440
445
  function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
441
- // If min or max are user set, we need to check
446
+ if (shouldShowAllLabels(axisModel.axis)) {
447
+ return;
448
+ } // If min or max are user set, we need to check
442
449
  // If the tick on min(max) are overlap on their neighbour tick
443
450
  // If they are overlapped, we need to hide the min(max) tick label
451
+
452
+
444
453
  var showMinLabel = axisModel.get('axisLabel.showMinLabel');
445
454
  var showMaxLabel = axisModel.get('axisLabel.showMaxLabel'); // FIXME
446
455
  // Have not consider onBand yet, where tick els is more than label els.
@@ -300,6 +300,10 @@ MapDraw.prototype = {
300
300
 
301
301
  var textEl = new graphic.Text({
302
302
  position: region.center.slice(),
303
+ // FIXME
304
+ // label rotation is not support yet in geo or regions of series-map
305
+ // that has no data. The rotation will be effected by this `scale`.
306
+ // So needed to change to RectText?
303
307
  scale: [1 / scale[0], 1 / scale[1]],
304
308
  z2: 10,
305
309
  silent: true
@@ -149,7 +149,7 @@ function RoamController(zr) {
149
149
  zrUtil.mixin(RoamController, Eventful);
150
150
 
151
151
  function mousedown(e) {
152
- if (eventTool.notLeftMouse(e) || e.target && e.target.draggable) {
152
+ if (eventTool.isMiddleOrRightButtonOnMouseUpDown(e) || e.target && e.target.draggable) {
153
153
  return;
154
154
  }
155
155
 
@@ -165,7 +165,7 @@ function mousedown(e) {
165
165
  }
166
166
 
167
167
  function mousemove(e) {
168
- if (eventTool.notLeftMouse(e) || !isAvailableBehavior('moveOnMouseMove', e, this._opt) || !this._dragging || e.gestureEvent === 'pinch' || interactionMutex.isTaken(this._zr, 'globalPan')) {
168
+ if (!this._dragging || !isAvailableBehavior('moveOnMouseMove', e, this._opt) || e.gestureEvent === 'pinch' || interactionMutex.isTaken(this._zr, 'globalPan')) {
169
169
  return;
170
170
  }
171
171
 
@@ -189,7 +189,7 @@ function mousemove(e) {
189
189
  }
190
190
 
191
191
  function mouseup(e) {
192
- if (!eventTool.notLeftMouse(e)) {
192
+ if (!eventTool.isMiddleOrRightButtonOnMouseUpDown(e)) {
193
193
  this._dragging = false;
194
194
  }
195
195
  }
@@ -79,6 +79,14 @@ var _default = echarts.extendComponentView({
79
79
  */
80
80
 
81
81
  this._backgroundEl;
82
+ /**
83
+ * If first rendering, `contentGroup.position` is [0, 0], which
84
+ * does not make sense and may cause unexepcted animation if adopted.
85
+ * @private
86
+ * @type {boolean}
87
+ */
88
+
89
+ this._isFirstRender = true;
82
90
  },
83
91
 
84
92
  /**
@@ -92,6 +100,8 @@ var _default = echarts.extendComponentView({
92
100
  * @override
93
101
  */
94
102
  render: function (legendModel, ecModel, api) {
103
+ var isFirstRender = this._isFirstRender;
104
+ this._isFirstRender = false;
95
105
  this.resetInner();
96
106
 
97
107
  if (!legendModel.get('show', true)) {
@@ -113,7 +123,7 @@ var _default = echarts.extendComponentView({
113
123
  };
114
124
  var padding = legendModel.get('padding');
115
125
  var maxSize = layoutUtil.getLayoutRect(positionInfo, viewportSize, padding);
116
- var mainRect = this.layoutInner(legendModel, itemAlign, maxSize); // Place mainGroup, based on the calculated `mainRect`.
126
+ var mainRect = this.layoutInner(legendModel, itemAlign, maxSize, isFirstRender); // Place mainGroup, based on the calculated `mainRect`.
117
127
 
118
128
  var layoutRect = layoutUtil.getLayoutRect(zrUtil.defaults({
119
129
  width: mainRect.width,
@@ -300,6 +310,14 @@ var _default = echarts.extendComponentView({
300
310
  var contentRect = contentGroup.getBoundingRect();
301
311
  contentGroup.attr('position', [-contentRect.x, -contentRect.y]);
302
312
  return this.group.getBoundingRect();
313
+ },
314
+
315
+ /**
316
+ * @protected
317
+ */
318
+ remove: function () {
319
+ this.getContentGroup().removeAll();
320
+ this._isFirstRender = true;
303
321
  }
304
322
  });
305
323
 
@@ -105,7 +105,9 @@ var ScrollableLegendView = LegendView.extend({
105
105
  var me = this; // Render content items.
106
106
 
107
107
  ScrollableLegendView.superCall(this, 'renderInner', itemAlign, legendModel, ecModel, api);
108
- var controllerGroup = this._controllerGroup;
108
+ var controllerGroup = this._controllerGroup; // FIXME: support be 'auto' adapt to size number text length,
109
+ // e.g., '3/12345' should not overlap with the control arrow button.
110
+
109
111
  var pageIconSize = legendModel.get('pageIconSize', true);
110
112
 
111
113
  if (!zrUtil.isArray(pageIconSize)) {
@@ -146,7 +148,7 @@ var ScrollableLegendView = LegendView.extend({
146
148
  /**
147
149
  * @override
148
150
  */
149
- layoutInner: function (legendModel, itemAlign, maxSize) {
151
+ layoutInner: function (legendModel, itemAlign, maxSize, isFirstRender) {
150
152
  var contentGroup = this.getContentGroup();
151
153
  var containerGroup = this._containerGroup;
152
154
  var controllerGroup = this._controllerGroup;
@@ -162,8 +164,13 @@ var ScrollableLegendView = LegendView.extend({
162
164
  var controllerRect = controllerGroup.getBoundingRect();
163
165
  var showController = this._showController = contentRect[wh] > maxSize[wh];
164
166
  var contentPos = [-contentRect.x, -contentRect.y]; // Remain contentPos when scroll animation perfroming.
167
+ // If first rendering, `contentGroup.position` is [0, 0], which
168
+ // does not make sense and may cause unexepcted animation if adopted.
169
+
170
+ if (!isFirstRender) {
171
+ contentPos[orientIdx] = contentGroup.position[orientIdx];
172
+ } // Layout container group based on 0.
165
173
 
166
- contentPos[orientIdx] = contentGroup.position[orientIdx]; // Layout container group based on 0.
167
174
 
168
175
  var containerPos = [0, 0];
169
176
  var controllerPos = [-controllerRect.x, -controllerRect.y];
@@ -278,95 +285,123 @@ var ScrollableLegendView = LegendView.extend({
278
285
  * }
279
286
  */
280
287
  _getPageInfo: function (legendModel) {
281
- // Align left or top by the current dataIndex.
282
- var currDataIndex = legendModel.get('scrollDataIndex', true);
288
+ var scrollDataIndex = legendModel.get('scrollDataIndex', true);
283
289
  var contentGroup = this.getContentGroup();
284
- var contentRect = contentGroup.getBoundingRect();
285
290
  var containerRectSize = this._containerGroup.__rectSize;
286
291
  var orientIdx = legendModel.getOrient().index;
287
292
  var wh = WH[orientIdx];
288
- var hw = WH[1 - orientIdx];
289
293
  var xy = XY[orientIdx];
290
- var contentPos = contentGroup.position.slice();
291
- var pageIndex;
292
- var pagePrevDataIndex;
293
- var pageNextDataIndex;
294
- var targetItemGroup;
295
294
 
296
- if (this._showController) {
297
- contentGroup.eachChild(function (child) {
298
- if (child.__legendDataIndex === currDataIndex) {
299
- targetItemGroup = child;
300
- }
301
- });
302
- } else {
303
- targetItemGroup = contentGroup.childAt(0);
295
+ var targetItemIndex = this._findTargetItemIndex(scrollDataIndex);
296
+
297
+ var children = contentGroup.children();
298
+ var targetItem = children[targetItemIndex];
299
+ var itemCount = children.length;
300
+ var pCount = !itemCount ? 0 : 1;
301
+ var result = {
302
+ contentPosition: contentGroup.position.slice(),
303
+ pageCount: pCount,
304
+ pageIndex: pCount - 1,
305
+ pagePrevDataIndex: null,
306
+ pageNextDataIndex: null
307
+ };
308
+
309
+ if (!targetItem) {
310
+ return result;
304
311
  }
305
312
 
306
- var pageCount = containerRectSize ? Math.ceil(contentRect[wh] / containerRectSize) : 0;
313
+ var targetItemInfo = getItemInfo(targetItem);
314
+ result.contentPosition[orientIdx] = -targetItemInfo.s; // Strategy:
315
+ // (1) Always align based on the left/top most item.
316
+ // (2) It is user-friendly that the last item shown in the
317
+ // current window is shown at the begining of next window.
318
+ // Otherwise if half of the last item is cut by the window,
319
+ // it will have no chance to display entirely.
320
+ // (3) Consider that item size probably be different, we
321
+ // have calculate pageIndex by size rather than item index,
322
+ // and we can not get page index directly by division.
323
+ // (4) The window is to narrow to contain more than
324
+ // one item, we should make sure that the page can be fliped.
325
+
326
+ for (var i = targetItemIndex + 1, winStartItemInfo = targetItemInfo, winEndItemInfo = targetItemInfo, currItemInfo = null; i <= itemCount; ++i) {
327
+ currItemInfo = getItemInfo(children[i]);
328
+
329
+ if ( // Half of the last item is out of the window.
330
+ !currItemInfo && winEndItemInfo.e > winStartItemInfo.s + containerRectSize || // If the current item does not intersect with the window, the new page
331
+ // can be started at the current item or the last item.
332
+ currItemInfo && !intersect(currItemInfo, winStartItemInfo.s)) {
333
+ if (winEndItemInfo.i > winStartItemInfo.i) {
334
+ winStartItemInfo = winEndItemInfo;
335
+ } else {
336
+ // e.g., when page size is smaller than item size.
337
+ winStartItemInfo = currItemInfo;
338
+ }
307
339
 
308
- if (targetItemGroup) {
309
- var itemRect = targetItemGroup.getBoundingRect();
310
- var itemLoc = targetItemGroup.position[orientIdx] + itemRect[xy];
311
- contentPos[orientIdx] = -itemLoc - contentRect[xy];
312
- pageIndex = Math.floor(pageCount * (itemLoc + itemRect[xy] + containerRectSize / 2) / contentRect[wh]);
313
- pageIndex = contentRect[wh] && pageCount ? Math.max(0, Math.min(pageCount - 1, pageIndex)) : -1;
314
- var winRect = {
315
- x: 0,
316
- y: 0
317
- };
318
- winRect[wh] = containerRectSize;
319
- winRect[hw] = contentRect[hw];
320
- winRect[xy] = -contentPos[orientIdx] - contentRect[xy];
321
- var startIdx;
322
- var children = contentGroup.children();
323
- contentGroup.eachChild(function (child, index) {
324
- var itemRect = getItemRect(child);
340
+ if (winStartItemInfo) {
341
+ if (result.pageNextDataIndex == null) {
342
+ result.pageNextDataIndex = winStartItemInfo.i;
343
+ }
325
344
 
326
- if (itemRect.intersect(winRect)) {
327
- startIdx == null && (startIdx = index); // It is user-friendly that the last item shown in the
328
- // current window is shown at the begining of next window.
345
+ ++result.pageCount;
346
+ }
347
+ }
348
+
349
+ winEndItemInfo = currItemInfo;
350
+ }
329
351
 
330
- pageNextDataIndex = child.__legendDataIndex;
331
- } // If the last item is shown entirely, no next page.
352
+ for (var i = targetItemIndex - 1, winStartItemInfo = targetItemInfo, winEndItemInfo = targetItemInfo, currItemInfo = null; i >= -1; --i) {
353
+ currItemInfo = getItemInfo(children[i]);
332
354
 
355
+ if ( // If the the end item does not intersect with the window started
356
+ // from the current item, a page can be settled.
357
+ (!currItemInfo || !intersect(winEndItemInfo, currItemInfo.s)) && // e.g., when page size is smaller than item size.
358
+ winStartItemInfo.i < winEndItemInfo.i) {
359
+ winEndItemInfo = winStartItemInfo;
333
360
 
334
- if (index === children.length - 1 && itemRect[xy] + itemRect[wh] <= winRect[xy] + winRect[wh]) {
335
- pageNextDataIndex = null;
361
+ if (result.pagePrevDataIndex == null) {
362
+ result.pagePrevDataIndex = winStartItemInfo.i;
336
363
  }
337
- }); // Always align based on the left/top most item, so the left/top most
338
- // item in the previous window is needed to be found here.
339
364
 
340
- if (startIdx != null) {
341
- var startItem = children[startIdx];
342
- var startRect = getItemRect(startItem);
343
- winRect[xy] = startRect[xy] + startRect[wh] - winRect[wh]; // If the first item is shown entirely, no previous page.
365
+ ++result.pageCount;
366
+ ++result.pageIndex;
367
+ }
344
368
 
345
- if (startIdx <= 0 && startRect[xy] >= winRect[xy]) {
346
- pagePrevDataIndex = null;
347
- } else {
348
- while (startIdx > 0 && getItemRect(children[startIdx - 1]).intersect(winRect)) {
349
- startIdx--;
350
- }
369
+ winStartItemInfo = currItemInfo;
370
+ }
351
371
 
352
- pagePrevDataIndex = children[startIdx].__legendDataIndex;
353
- }
372
+ return result;
373
+
374
+ function getItemInfo(el) {
375
+ if (el) {
376
+ var itemRect = el.getBoundingRect();
377
+ var start = itemRect[xy] + el.position[orientIdx];
378
+ return {
379
+ s: start,
380
+ e: start + itemRect[wh],
381
+ i: el.__legendDataIndex
382
+ };
354
383
  }
355
384
  }
356
385
 
357
- return {
358
- contentPosition: contentPos,
359
- pageIndex: pageIndex,
360
- pageCount: pageCount,
361
- pagePrevDataIndex: pagePrevDataIndex,
362
- pageNextDataIndex: pageNextDataIndex
363
- };
386
+ function intersect(itemInfo, winStart) {
387
+ return itemInfo.e >= winStart && itemInfo.s <= winStart + containerRectSize;
388
+ }
389
+ },
390
+ _findTargetItemIndex: function (targetDataIndex) {
391
+ var index;
392
+ var contentGroup = this.getContentGroup();
364
393
 
365
- function getItemRect(el) {
366
- var itemRect = el.getBoundingRect().clone();
367
- itemRect[xy] += el.position[orientIdx];
368
- return itemRect;
394
+ if (this._showController) {
395
+ contentGroup.eachChild(function (child, idx) {
396
+ if (child.__legendDataIndex === targetDataIndex) {
397
+ index = idx;
398
+ }
399
+ });
400
+ } else {
401
+ index = 0;
369
402
  }
403
+
404
+ return index;
370
405
  }
371
406
  });
372
407
  var _default = ScrollableLegendView;
@@ -396,6 +396,27 @@ function rotateTextRect(textRect, rotate) {
396
396
  var rotatedRect = new BoundingRect(boundingBox.x, boundingBox.y, afterWidth, afterHeight);
397
397
  return rotatedRect;
398
398
  }
399
+ /**
400
+ * @param {module:echarts/src/model/Model} model axisLabelModel or axisTickModel
401
+ * @return {number|String} Can be null|'auto'|number|function
402
+ */
403
+
404
+
405
+ function getOptionCategoryInterval(model) {
406
+ var interval = model.get('interval');
407
+ return interval == null ? 'auto' : interval;
408
+ }
409
+ /**
410
+ * Set `categoryInterval` as 0 implicitly indicates that
411
+ * show all labels reguardless of overlap.
412
+ * @param {Object} axis axisModel.axis
413
+ * @return {boolean}
414
+ */
415
+
416
+
417
+ function shouldShowAllLabels(axis) {
418
+ return axis.type === 'category' && getOptionCategoryInterval(axis.getLabelModel()) === 0;
419
+ }
399
420
 
400
421
  exports.getScaleExtent = getScaleExtent;
401
422
  exports.niceScaleExtent = niceScaleExtent;
@@ -403,4 +424,6 @@ exports.createScaleByModel = createScaleByModel;
403
424
  exports.ifAxisCrossZero = ifAxisCrossZero;
404
425
  exports.makeLabelFormatter = makeLabelFormatter;
405
426
  exports.getAxisRawValue = getAxisRawValue;
406
- exports.estimateLabelUnionRect = estimateLabelUnionRect;
427
+ exports.estimateLabelUnionRect = estimateLabelUnionRect;
428
+ exports.getOptionCategoryInterval = getOptionCategoryInterval;
429
+ exports.shouldShowAllLabels = shouldShowAllLabels;
@@ -29,6 +29,8 @@ var makeInner = _model.makeInner;
29
29
  var _axisHelper = require("./axisHelper");
30
30
 
31
31
  var makeLabelFormatter = _axisHelper.makeLabelFormatter;
32
+ var getOptionCategoryInterval = _axisHelper.getOptionCategoryInterval;
33
+ var shouldShowAllLabels = _axisHelper.shouldShowAllLabels;
32
34
 
33
35
  /*
34
36
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -307,12 +309,11 @@ function makeLabelsByNumericCategoryInterval(axis, categoryInterval, onlyTick) {
307
309
  // do not need to perform this process.
308
310
 
309
311
 
310
- var showMinMax = {
311
- min: labelModel.get('showMinLabel'),
312
- max: labelModel.get('showMaxLabel')
313
- };
312
+ var showAllLabel = shouldShowAllLabels(axis);
313
+ var includeMinLabel = labelModel.get('showMinLabel') || showAllLabel;
314
+ var includeMaxLabel = labelModel.get('showMaxLabel') || showAllLabel;
314
315
 
315
- if (showMinMax.min && startTick !== ordinalExtent[0]) {
316
+ if (includeMinLabel && startTick !== ordinalExtent[0]) {
316
317
  addItem(ordinalExtent[0]);
317
318
  } // Optimize: avoid generating large array by `ordinalScale.getTicks()`.
318
319
 
@@ -323,7 +324,7 @@ function makeLabelsByNumericCategoryInterval(axis, categoryInterval, onlyTick) {
323
324
  addItem(tickValue);
324
325
  }
325
326
 
326
- if (showMinMax.max && tickValue !== ordinalExtent[1]) {
327
+ if (includeMaxLabel && tickValue !== ordinalExtent[1]) {
327
328
  addItem(ordinalExtent[1]);
328
329
  }
329
330
 
@@ -356,12 +357,6 @@ function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick
356
357
  }
357
358
  });
358
359
  return result;
359
- } // Can be null|'auto'|number|function
360
-
361
-
362
- function getOptionCategoryInterval(model) {
363
- var interval = model.get('interval');
364
- return interval == null ? 'auto' : interval;
365
360
  }
366
361
 
367
362
  exports.createAxisLabels = createAxisLabels;
@@ -67,7 +67,7 @@ function Geo(name, map, nameMap, invertLongitute) {
67
67
  this.map = map;
68
68
  var source = geoSourceManager.load(map, nameMap);
69
69
  this._nameCoordMap = source.nameCoordMap;
70
- this._regionsMap = source.nameCoordMap;
70
+ this._regionsMap = source.regionsMap;
71
71
  this._invertLongitute = invertLongitute == null ? true : invertLongitute;
72
72
  /**
73
73
  * @readOnly
package/lib/data/List.js CHANGED
@@ -65,7 +65,8 @@ var summarizeDimensions = _dimensionHelper.summarizeDimensions;
65
65
  * @module echarts/data/List
66
66
  */
67
67
  var isObject = zrUtil.isObject;
68
- var UNDEFINED = 'undefined'; // Use prefix to avoid index to be the same as otherIdList[idx],
68
+ var UNDEFINED = 'undefined';
69
+ var INDEX_NOT_FOUND = -1; // Use prefix to avoid index to be the same as otherIdList[idx],
69
70
  // which will cause weird udpate animation.
70
71
 
71
72
  var ID_PREFIX = 'e\0\0';
@@ -80,6 +81,7 @@ var dataCtors = {
80
81
  // different from the Ctor of typed array.
81
82
 
82
83
  var CtorUint32Array = typeof Uint32Array === UNDEFINED ? Array : Uint32Array;
84
+ var CtorInt32Array = typeof Int32Array === UNDEFINED ? Array : Int32Array;
83
85
  var CtorUint16Array = typeof Uint16Array === UNDEFINED ? Array : Uint16Array;
84
86
 
85
87
  function getIndicesCtor(list) {
@@ -421,7 +423,8 @@ listProto.initData = function (data, nameList, dimValueGetter) {
421
423
 
422
424
  this.defaultDimValueGetter = defaultDimValueGetters[this._rawData.getSource().sourceFormat]; // Default dim value getter
423
425
 
424
- this._dimValueGetter = dimValueGetter = dimValueGetter || this.defaultDimValueGetter; // Reset raw extent.
426
+ this._dimValueGetter = dimValueGetter = dimValueGetter || this.defaultDimValueGetter;
427
+ this._dimValueGetterArrayRows = defaultDimValueGetters.arrayRows; // Reset raw extent.
425
428
 
426
429
  this._rawExtent = {};
427
430
 
@@ -436,6 +439,10 @@ listProto.initData = function (data, nameList, dimValueGetter) {
436
439
  listProto.getProvider = function () {
437
440
  return this._rawData;
438
441
  };
442
+ /**
443
+ * Caution: Can be only called on raw data (before `this._indices` created).
444
+ */
445
+
439
446
 
440
447
  listProto.appendData = function (data) {
441
448
  var rawData = this._rawData;
@@ -449,6 +456,77 @@ listProto.appendData = function (data) {
449
456
 
450
457
  this._initDataFromProvider(start, end);
451
458
  };
459
+ /**
460
+ * Caution: Can be only called on raw data (before `this._indices` created).
461
+ * This method does not modify `rawData` (`dataProvider`), but only
462
+ * add values to storage.
463
+ *
464
+ * The final count will be increased by `Math.max(values.length, names.length)`.
465
+ *
466
+ * @param {Array.<Array.<*>>} values That is the SourceType: 'arrayRows', like
467
+ * [
468
+ * [12, 33, 44],
469
+ * [NaN, 43, 1],
470
+ * ['-', 'asdf', 0]
471
+ * ]
472
+ * Each item is exaclty cooresponding to a dimension.
473
+ * @param {Array.<string>} [names]
474
+ */
475
+
476
+
477
+ listProto.appendValues = function (values, names) {
478
+ var chunkSize = this._chunkSize;
479
+ var storage = this._storage;
480
+ var dimensions = this.dimensions;
481
+ var dimLen = dimensions.length;
482
+ var rawExtent = this._rawExtent;
483
+ var start = this.count();
484
+ var end = start + Math.max(values.length, names ? names.length : 0);
485
+ var originalChunkCount = this._chunkCount;
486
+
487
+ for (var i = 0; i < dimLen; i++) {
488
+ var dim = dimensions[i];
489
+
490
+ if (!rawExtent[dim]) {
491
+ rawExtent[dim] = getInitialExtent();
492
+ }
493
+
494
+ if (!storage[dim]) {
495
+ storage[dim] = [];
496
+ }
497
+
498
+ prepareChunks(storage, this._dimensionInfos[dim], chunkSize, originalChunkCount, end);
499
+ this._chunkCount = storage[dim].length;
500
+ }
501
+
502
+ var emptyDataItem = new Array(dimLen);
503
+
504
+ for (var idx = start; idx < end; idx++) {
505
+ var sourceIdx = idx - start;
506
+ var chunkIndex = Math.floor(idx / chunkSize);
507
+ var chunkOffset = idx % chunkSize; // Store the data by dimensions
508
+
509
+ for (var k = 0; k < dimLen; k++) {
510
+ var dim = dimensions[k];
511
+
512
+ var val = this._dimValueGetterArrayRows(values[sourceIdx] || emptyDataItem, dim, sourceIdx, k);
513
+
514
+ storage[dim][chunkIndex][chunkOffset] = val;
515
+ var dimRawExtent = rawExtent[dim];
516
+ val < dimRawExtent[0] && (dimRawExtent[0] = val);
517
+ val > dimRawExtent[1] && (dimRawExtent[1] = val);
518
+ }
519
+
520
+ if (names) {
521
+ this._nameList[idx] = names[sourceIdx];
522
+ }
523
+ }
524
+
525
+ this._rawCount = this._count = end; // Reset data extent
526
+
527
+ this._extent = {};
528
+ prepareInvertedIndex(this);
529
+ };
452
530
 
453
531
  listProto._initDataFromProvider = function (start, end) {
454
532
  // Optimize.
@@ -467,8 +545,7 @@ listProto._initDataFromProvider = function (start, end) {
467
545
  var rawExtent = this._rawExtent;
468
546
  var nameRepeatCount = this._nameRepeatCount = {};
469
547
  var nameDimIdx;
470
- var chunkCount = this._chunkCount;
471
- var lastChunkIndex = chunkCount - 1;
548
+ var originalChunkCount = this._chunkCount;
472
549
 
473
550
  for (var i = 0; i < dimLen; i++) {
474
551
  var dim = dimensions[i];
@@ -487,30 +564,11 @@ listProto._initDataFromProvider = function (start, end) {
487
564
  this._idDimIdx = i;
488
565
  }
489
566
 
490
- var DataCtor = dataCtors[dimInfo.type];
491
-
492
567
  if (!storage[dim]) {
493
568
  storage[dim] = [];
494
569
  }
495
570
 
496
- var resizeChunkArray = storage[dim][lastChunkIndex];
497
-
498
- if (resizeChunkArray && resizeChunkArray.length < chunkSize) {
499
- var newStore = new DataCtor(Math.min(end - lastChunkIndex * chunkSize, chunkSize)); // The cost of the copy is probably inconsiderable
500
- // within the initial chunkSize.
501
-
502
- for (var j = 0; j < resizeChunkArray.length; j++) {
503
- newStore[j] = resizeChunkArray[j];
504
- }
505
-
506
- storage[dim][lastChunkIndex] = newStore;
507
- } // Create new chunks.
508
-
509
-
510
- for (var k = chunkCount * chunkSize; k < end; k += chunkSize) {
511
- storage[dim].push(new DataCtor(Math.min(end - k, chunkSize)));
512
- }
513
-
571
+ prepareChunks(storage, dimInfo, chunkSize, originalChunkCount, end);
514
572
  this._chunkCount = storage[dim].length;
515
573
  }
516
574
 
@@ -536,14 +594,8 @@ listProto._initDataFromProvider = function (start, end) {
536
594
 
537
595
  dimStorage[chunkOffset] = val;
538
596
  var dimRawExtent = rawExtent[dim];
539
-
540
- if (val < dimRawExtent[0]) {
541
- dimRawExtent[0] = val;
542
- }
543
-
544
- if (val > dimRawExtent[1]) {
545
- dimRawExtent[1] = val;
546
- }
597
+ val < dimRawExtent[0] && (dimRawExtent[0] = val);
598
+ val > dimRawExtent[1] && (dimRawExtent[1] = val);
547
599
  } // ??? FIXME not check by pure but sourceFormat?
548
600
  // TODO refactor these logic.
549
601
 
@@ -604,6 +656,29 @@ listProto._initDataFromProvider = function (start, end) {
604
656
  prepareInvertedIndex(this);
605
657
  };
606
658
 
659
+ function prepareChunks(storage, dimInfo, chunkSize, chunkCount, end) {
660
+ var DataCtor = dataCtors[dimInfo.type];
661
+ var lastChunkIndex = chunkCount - 1;
662
+ var dim = dimInfo.name;
663
+ var resizeChunkArray = storage[dim][lastChunkIndex];
664
+
665
+ if (resizeChunkArray && resizeChunkArray.length < chunkSize) {
666
+ var newStore = new DataCtor(Math.min(end - lastChunkIndex * chunkSize, chunkSize)); // The cost of the copy is probably inconsiderable
667
+ // within the initial chunkSize.
668
+
669
+ for (var j = 0; j < resizeChunkArray.length; j++) {
670
+ newStore[j] = resizeChunkArray[j];
671
+ }
672
+
673
+ storage[dim][lastChunkIndex] = newStore;
674
+ } // Create new chunks.
675
+
676
+
677
+ for (var k = chunkCount * chunkSize; k < end; k += chunkSize) {
678
+ storage[dim].push(new DataCtor(Math.min(end - k, chunkSize)));
679
+ }
680
+ }
681
+
607
682
  function prepareInvertedIndex(list) {
608
683
  var invertedIndicesMap = list._invertedIndicesMap;
609
684
  zrUtil.each(invertedIndicesMap, function (invertedIndices, dim) {
@@ -612,11 +687,11 @@ function prepareInvertedIndex(list) {
612
687
  var ordinalMeta = dimInfo.ordinalMeta;
613
688
 
614
689
  if (ordinalMeta) {
615
- invertedIndices = invertedIndicesMap[dim] = new CtorUint32Array(ordinalMeta.categories.length); // The default value of TypedArray is 0. To avoid miss
616
- // mapping to 0, we should set it as NaN.
690
+ invertedIndices = invertedIndicesMap[dim] = new CtorInt32Array(ordinalMeta.categories.length); // The default value of TypedArray is 0. To avoid miss
691
+ // mapping to 0, we should set it as INDEX_NOT_FOUND.
617
692
 
618
693
  for (var i = 0; i < invertedIndices.length; i++) {
619
- invertedIndices[i] = NaN;
694
+ invertedIndices[i] = INDEX_NOT_FOUND;
620
695
  }
621
696
 
622
697
  for (var i = 0; i < list._count; i++) {
@@ -1008,7 +1083,7 @@ listProto.rawIndexOf = function (dim, value) {
1008
1083
  var rawIndex = invertedIndices[value];
1009
1084
 
1010
1085
  if (rawIndex == null || isNaN(rawIndex)) {
1011
- return -1;
1086
+ return INDEX_NOT_FOUND;
1012
1087
  }
1013
1088
 
1014
1089
  return rawIndex;