echarts 4.5.0 → 4.6.0

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 (154) hide show
  1. package/dist/echarts-en.common.js +1790 -774
  2. package/dist/echarts-en.common.min.js +1 -1
  3. package/dist/echarts-en.js +2029 -849
  4. package/dist/echarts-en.js.map +1 -1
  5. package/dist/echarts-en.min.js +1 -1
  6. package/dist/echarts-en.simple.js +1676 -691
  7. package/dist/echarts-en.simple.min.js +1 -1
  8. package/dist/echarts.common.js +1790 -774
  9. package/dist/echarts.common.min.js +1 -1
  10. package/dist/echarts.js +2029 -849
  11. package/dist/echarts.js.map +1 -1
  12. package/dist/echarts.min.js +1 -1
  13. package/dist/echarts.simple.js +1676 -691
  14. package/dist/echarts.simple.min.js +1 -1
  15. package/lib/chart/bar/BarView.js +11 -1
  16. package/lib/chart/bar/BaseBarSeries.js +3 -1
  17. package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
  18. package/lib/chart/funnel/FunnelSeries.js +15 -5
  19. package/lib/chart/gauge/GaugeSeries.js +0 -2
  20. package/lib/chart/graph/GraphSeries.js +9 -4
  21. package/lib/chart/graph/GraphView.js +28 -8
  22. package/lib/chart/heatmap/HeatmapView.js +4 -4
  23. package/lib/chart/helper/createListFromArray.js +14 -8
  24. package/lib/chart/helper/whiskerBoxCommon.js +22 -16
  25. package/lib/chart/line/LineSeries.js +3 -1
  26. package/lib/chart/line/LineView.js +8 -2
  27. package/lib/chart/map/MapSeries.js +8 -1
  28. package/lib/chart/pie/PieSeries.js +27 -6
  29. package/lib/chart/pie/PieView.js +1 -1
  30. package/lib/chart/pie/labelLayout.js +102 -19
  31. package/lib/chart/pie/pieLayout.js +19 -7
  32. package/lib/chart/radar/RadarSeries.js +3 -3
  33. package/lib/chart/sankey/SankeyView.js +28 -9
  34. package/lib/chart/scatter/ScatterSeries.js +3 -1
  35. package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
  36. package/lib/chart/tree/TreeSeries.js +15 -1
  37. package/lib/component/axis/AngleAxisView.js +64 -7
  38. package/lib/component/axis/AxisBuilder.js +63 -24
  39. package/lib/component/axis/CartesianAxisView.js +55 -11
  40. package/lib/component/axis/RadiusAxisView.js +36 -4
  41. package/lib/component/dataZoom/SliderZoomView.js +4 -10
  42. package/lib/component/helper/BrushController.js +33 -43
  43. package/lib/component/legend/LegendModel.js +3 -3
  44. package/lib/component/legend/LegendView.js +17 -13
  45. package/lib/component/toolbox/ToolboxView.js +5 -1
  46. package/lib/component/toolbox/feature/MagicType.js +19 -14
  47. package/lib/coord/Axis.js +30 -2
  48. package/lib/coord/axisDefault.js +21 -2
  49. package/lib/data/DataDimensionInfo.js +157 -0
  50. package/lib/data/List.js +25 -19
  51. package/lib/data/Tree.js +2 -1
  52. package/lib/data/helper/completeDimensions.js +43 -32
  53. package/lib/data/helper/createDimensions.js +2 -0
  54. package/lib/data/helper/sourceHelper.js +214 -114
  55. package/lib/echarts.js +2 -2
  56. package/lib/layout/barGrid.js +2 -3
  57. package/lib/model/Series.js +3 -3
  58. package/lib/model/referHelper.js +40 -12
  59. package/lib/scale/Interval.js +87 -2
  60. package/lib/scale/Log.js +9 -2
  61. package/lib/scale/helper.js +1 -43
  62. package/lib/theme/dark.js +3 -0
  63. package/lib/util/graphic.js +1 -2
  64. package/lib/visual/LegendVisualProvider.js +75 -0
  65. package/lib/visual/dataColor.js +2 -12
  66. package/lib/visual/seriesColor.js +15 -7
  67. package/map/json/province/tianjin.json +1 -1
  68. package/package.json +3 -2
  69. package/src/chart/bar/BarView.js +12 -2
  70. package/src/chart/bar/BaseBarSeries.js +1 -1
  71. package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
  72. package/src/chart/funnel/FunnelSeries.js +11 -4
  73. package/src/chart/gauge/GaugeSeries.js +0 -1
  74. package/src/chart/graph/GraphSeries.js +8 -3
  75. package/src/chart/graph/GraphView.js +26 -8
  76. package/src/chart/heatmap/HeatmapView.js +4 -4
  77. package/src/chart/helper/createListFromArray.js +13 -8
  78. package/src/chart/helper/whiskerBoxCommon.js +21 -16
  79. package/src/chart/line/LineSeries.js +1 -1
  80. package/src/chart/line/LineView.js +6 -1
  81. package/src/chart/map/MapSeries.js +5 -1
  82. package/src/chart/pie/PieSeries.js +26 -5
  83. package/src/chart/pie/PieView.js +1 -1
  84. package/src/chart/pie/labelLayout.js +114 -22
  85. package/src/chart/pie/pieLayout.js +20 -7
  86. package/src/chart/radar/RadarSeries.js +5 -3
  87. package/src/chart/sankey/SankeyView.js +26 -9
  88. package/src/chart/scatter/ScatterSeries.js +1 -1
  89. package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
  90. package/src/chart/tree/TreeSeries.js +12 -1
  91. package/src/component/axis/AngleAxisView.js +75 -7
  92. package/src/component/axis/AxisBuilder.js +78 -33
  93. package/src/component/axis/CartesianAxisView.js +58 -11
  94. package/src/component/axis/RadiusAxisView.js +37 -4
  95. package/src/component/dataZoom/SliderZoomView.js +4 -9
  96. package/src/component/helper/BrushController.js +40 -47
  97. package/src/component/legend/LegendModel.js +3 -3
  98. package/src/component/legend/LegendView.js +18 -12
  99. package/src/component/toolbox/ToolboxView.js +5 -0
  100. package/src/component/toolbox/feature/MagicType.js +18 -13
  101. package/src/coord/Axis.js +29 -2
  102. package/src/coord/axisDefault.js +25 -1
  103. package/src/data/DataDimensionInfo.js +135 -0
  104. package/src/data/List.js +29 -16
  105. package/src/data/Tree.js +3 -1
  106. package/src/data/helper/completeDimensions.js +49 -30
  107. package/src/data/helper/createDimensions.js +2 -0
  108. package/src/data/helper/sourceHelper.js +216 -124
  109. package/src/echarts.js +2 -2
  110. package/src/layout/barGrid.js +6 -3
  111. package/src/model/Series.js +3 -3
  112. package/src/model/referHelper.js +34 -11
  113. package/src/scale/Interval.js +84 -4
  114. package/src/scale/Log.js +9 -2
  115. package/src/scale/helper.js +1 -39
  116. package/src/theme/dark.js +3 -0
  117. package/src/util/graphic.js +1 -2
  118. package/src/visual/LegendVisualProvider.js +55 -0
  119. package/src/visual/dataColor.js +0 -13
  120. package/src/visual/seriesColor.js +13 -7
  121. package/theme/azul.js +163 -0
  122. package/theme/bee-inspired.js +178 -0
  123. package/theme/blue.js +178 -0
  124. package/theme/caravan.js +178 -0
  125. package/theme/carp.js +163 -0
  126. package/theme/cool.js +180 -0
  127. package/theme/dark-blue.js +168 -0
  128. package/theme/dark-bold.js +168 -0
  129. package/theme/dark-digerati.js +168 -0
  130. package/theme/dark-fresh-cut.js +168 -0
  131. package/theme/dark-mushroom.js +168 -0
  132. package/theme/dark.js +69 -62
  133. package/theme/eduardo.js +178 -0
  134. package/theme/forest.js +163 -0
  135. package/theme/fresh-cut.js +163 -0
  136. package/theme/fruit.js +178 -0
  137. package/theme/gray.js +220 -0
  138. package/theme/green.js +222 -0
  139. package/theme/helianthus.js +263 -0
  140. package/theme/infographic.js +72 -57
  141. package/theme/inspired.js +163 -0
  142. package/theme/jazz.js +163 -0
  143. package/theme/london.js +163 -0
  144. package/theme/macarons.js +80 -57
  145. package/theme/macarons2.js +251 -0
  146. package/theme/mint.js +155 -0
  147. package/theme/red-velvet.js +163 -0
  148. package/theme/red.js +225 -0
  149. package/theme/roma.js +55 -22
  150. package/theme/royal.js +163 -0
  151. package/theme/sakura.js +140 -0
  152. package/theme/shine.js +52 -45
  153. package/theme/tech-blue.js +180 -0
  154. package/theme/vintage.js +37 -23
@@ -136,12 +136,6 @@ function BrushController(zr) {
136
136
  */
137
137
  this._dragging;
138
138
 
139
- /**
140
- * @private
141
- * @type {Object}
142
- */
143
- this._lastMouseMovePoint = {};
144
-
145
139
  /**
146
140
  * @private
147
141
  * @type {Array}
@@ -186,7 +180,8 @@ function BrushController(zr) {
186
180
  * @type {Object}
187
181
  */
188
182
  this._handlers = {};
189
- each(mouseHandlers, function (handler, eventName) {
183
+
184
+ each(pointerHandlers, function (handler, eventName) {
190
185
  this._handlers[eventName] = zrUtil.bind(handler, this);
191
186
  }, this);
192
187
  }
@@ -382,9 +377,7 @@ function doEnableBrush(controller, brushOption) {
382
377
  interactionMutex.take(zr, MUTEX_RESOURCE_KEY, controller._uid);
383
378
  }
384
379
 
385
- each(controller._handlers, function (handler, eventName) {
386
- zr.on(eventName, handler);
387
- });
380
+ mountHandlers(zr, controller._handlers);
388
381
 
389
382
  controller._brushType = brushOption.brushType;
390
383
  controller._brushOption = zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
@@ -395,13 +388,23 @@ function doDisableBrush(controller) {
395
388
 
396
389
  interactionMutex.release(zr, MUTEX_RESOURCE_KEY, controller._uid);
397
390
 
398
- each(controller._handlers, function (handler, eventName) {
399
- zr.off(eventName, handler);
400
- });
391
+ unmountHandlers(zr, controller._handlers);
401
392
 
402
393
  controller._brushType = controller._brushOption = null;
403
394
  }
404
395
 
396
+ function mountHandlers(zr, handlers) {
397
+ each(handlers, function (handler, eventName) {
398
+ zr.on(eventName, handler);
399
+ });
400
+ }
401
+
402
+ function unmountHandlers(zr, handlers) {
403
+ each(handlers, function (handler, eventName) {
404
+ zr.off(eventName, handler);
405
+ });
406
+ }
407
+
405
408
  function createCover(controller, brushOption) {
406
409
  var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
407
410
  cover.__brushOption = brushOption;
@@ -715,8 +718,14 @@ function pointsToRect(points) {
715
718
  }
716
719
 
717
720
  function resetCursor(controller, e, localCursorPoint) {
718
- // Check active
719
- if (!controller._brushType) {
721
+ if (
722
+ // Check active
723
+ !controller._brushType
724
+ // resetCursor should be always called when mouse is in zr area,
725
+ // but not called when mouse is out of zr area to avoid bad influence
726
+ // if `mousemove`, `mouseup` are triggered from `document` event.
727
+ || isOutsideZrArea(controller, e)
728
+ ) {
720
729
  return;
721
730
  }
722
731
 
@@ -820,7 +829,7 @@ function determineBrushType(brushType, panel) {
820
829
  return brushType;
821
830
  }
822
831
 
823
- var mouseHandlers = {
832
+ var pointerHandlers = {
824
833
 
825
834
  mousedown: function (e) {
826
835
  if (this._dragging) {
@@ -845,56 +854,34 @@ var mouseHandlers = {
845
854
  },
846
855
 
847
856
  mousemove: function (e) {
848
- var lastPoint = this._lastMouseMovePoint;
849
- lastPoint.x = e.offsetX;
850
- lastPoint.y = e.offsetY;
857
+ var x = e.offsetX;
858
+ var y = e.offsetY;
851
859
 
852
- var localCursorPoint = this.group.transformCoordToLocal(lastPoint.x, lastPoint.y);
860
+ var localCursorPoint = this.group.transformCoordToLocal(x, y);
853
861
 
854
862
  resetCursor(this, e, localCursorPoint);
855
863
 
856
864
  if (this._dragging) {
857
-
858
865
  preventDefault(e);
859
-
860
866
  var eventParams = updateCoverByMouse(this, e, localCursorPoint, false);
861
-
862
867
  eventParams && trigger(this, eventParams);
863
868
  }
864
869
  },
865
870
 
866
871
  mouseup: function (e) {
867
872
  handleDragEnd(this, e);
868
- },
869
-
870
- globalout: function (e) {
871
- handleDragEnd(this, e, true);
872
873
  }
873
874
  };
874
875
 
875
- function handleDragEnd(controller, e, isGlobalOut) {
876
- if (controller._dragging) {
877
876
 
878
- // Just be worried about bring some side effect to the world
879
- // out of echarts, we do not `preventDefault` for globalout.
880
- !isGlobalOut && preventDefault(e);
877
+ function handleDragEnd(controller, e) {
878
+ if (controller._dragging) {
879
+ preventDefault(e);
881
880
 
882
- var pointerX = e.offsetX;
883
- var pointerY = e.offsetY;
884
- var lastPoint = controller._lastMouseMovePoint;
885
- if (isGlobalOut) {
886
- pointerX = lastPoint.x;
887
- pointerY = lastPoint.y;
888
- }
881
+ var x = e.offsetX;
882
+ var y = e.offsetY;
889
883
 
890
- var localCursorPoint = controller.group.transformCoordToLocal(pointerX, pointerY);
891
- // FIXME
892
- // Here `e` is used only in `onIrrelevantElement` finally. And it's OK
893
- // that pass the `e` of `globalout` to `onIrrelevantElement`. But it is
894
- // not a good design of these interfaces. However, we do not refactor
895
- // these code now because the implementation of `onIrrelevantElement`
896
- // need to be discussed and probably be changed in future, becuase it
897
- // slows down the performance of zrender in some cases.
884
+ var localCursorPoint = controller.group.transformCoordToLocal(x, y);
898
885
  var eventParams = updateCoverByMouse(controller, e, localCursorPoint, true);
899
886
 
900
887
  controller._dragging = false;
@@ -906,6 +893,12 @@ function handleDragEnd(controller, e, isGlobalOut) {
906
893
  }
907
894
  }
908
895
 
896
+ function isOutsideZrArea(controller, x, y) {
897
+ var zr = controller._zr;
898
+ return x < 0 || x > zr.getWidth() || y < 0 || y > zr.getHeight();
899
+ }
900
+
901
+
909
902
  /**
910
903
  * key: brushType
911
904
  * @type {Object}
@@ -111,9 +111,9 @@ var LegendModel = echarts.extendComponentModel({
111
111
  availableNames.push(seriesName);
112
112
  var isPotential;
113
113
 
114
- if (seriesModel.legendDataProvider) {
115
- var data = seriesModel.legendDataProvider();
116
- var names = data.mapArray(data.getName);
114
+ if (seriesModel.legendVisualProvider) {
115
+ var provider = seriesModel.legendVisualProvider;
116
+ var names = provider.getAllNames();
117
117
 
118
118
  if (!ecModel.isSeriesFiltered(seriesModel)) {
119
119
  availableNames = availableNames.concat(names);
@@ -175,7 +175,7 @@ export default echarts.extendComponentView({
175
175
  return;
176
176
  }
177
177
 
178
- // Series legend
178
+ // Legend to control series.
179
179
  if (seriesModel) {
180
180
  var data = seriesModel.getData();
181
181
  var color = data.getVisual('color');
@@ -204,29 +204,31 @@ export default echarts.extendComponentView({
204
204
  selectMode
205
205
  );
206
206
 
207
- itemGroup.on('click', curry(dispatchSelectAction, name, api))
207
+ itemGroup.on('click', curry(dispatchSelectAction, name, null, api, excludeSeriesId))
208
208
  .on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId))
209
209
  .on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));
210
210
 
211
211
  legendDrawnMap.set(name, true);
212
212
  }
213
213
  else {
214
- // Data legend of pie, funnel
214
+ // Legend to control data. In pie and funnel.
215
215
  ecModel.eachRawSeries(function (seriesModel) {
216
+
216
217
  // In case multiple series has same data name
217
218
  if (legendDrawnMap.get(name)) {
218
219
  return;
219
220
  }
220
221
 
221
- if (seriesModel.legendDataProvider) {
222
- var data = seriesModel.legendDataProvider();
223
- var idx = data.indexOfName(name);
224
- if (idx < 0) {
222
+ if (seriesModel.legendVisualProvider) {
223
+ var provider = seriesModel.legendVisualProvider;
224
+ if (!provider.containName(name)) {
225
225
  return;
226
226
  }
227
227
 
228
- var color = data.getItemVisual(idx, 'color');
229
- var borderColor = data.getItemVisual(idx, 'borderColor');
228
+ var idx = provider.indexOfName(name);
229
+
230
+ var color = provider.getItemVisual(idx, 'color');
231
+ var borderColor = provider.getItemVisual(idx, 'borderColor');
230
232
 
231
233
  var legendSymbolType = 'roundRect';
232
234
 
@@ -238,7 +240,7 @@ export default echarts.extendComponentView({
238
240
  );
239
241
 
240
242
  // FIXME: consider different series has items with the same name.
241
- itemGroup.on('click', curry(dispatchSelectAction, name, api))
243
+ itemGroup.on('click', curry(dispatchSelectAction, null, name, api, excludeSeriesId))
242
244
  // Should not specify the series name, consider legend controls
243
245
  // more than one pie series.
244
246
  .on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId))
@@ -518,11 +520,15 @@ function setSymbolStyle(symbol, symbolType, legendModelItemStyle, borderColor, i
518
520
  return symbol.setStyle(itemStyle);
519
521
  }
520
522
 
521
- function dispatchSelectAction(name, api) {
523
+ function dispatchSelectAction(seriesName, dataName, api, excludeSeriesId) {
524
+ // downplay before unselect
525
+ dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId);
522
526
  api.dispatchAction({
523
527
  type: 'legendToggleSelect',
524
- name: name
528
+ name: seriesName != null ? seriesName : dataName
525
529
  });
530
+ // highlight after select
531
+ dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId);
526
532
  }
527
533
 
528
534
  function dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId) {
@@ -63,6 +63,11 @@ export default echarts.extendComponentView({
63
63
  var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
64
64
  var feature;
65
65
 
66
+ // FIX#11236, merge feature title from MagicType newOption. TODO: consider seriesIndex ?
67
+ if (payload && payload.newTitle != null) {
68
+ featureOpt.title = payload.newTitle;
69
+ }
70
+
66
71
  if (featureName && !oldName) { // Create
67
72
  if (isUserFeatureName(featureName)) {
68
73
  feature = {
@@ -23,6 +23,7 @@ import lang from '../../../lang';
23
23
  import * as featureManager from '../featureManager';
24
24
 
25
25
  var magicTypeLang = lang.toolbox.magicType;
26
+ var INNER_STACK_KEYWORD = '__ec_magicType_stack__';
26
27
 
27
28
  function MagicType(model) {
28
29
  this.model = model;
@@ -36,8 +37,7 @@ MagicType.defaultOption = {
36
37
  /* eslint-disable */
37
38
  line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
38
39
  bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
39
- stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line
40
- tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
40
+ stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z' // jshint ignore:line
41
41
  /* eslint-enable */
42
42
  },
43
43
  // `line`, `bar`, `stack`, `tiled`
@@ -88,26 +88,20 @@ var seriesOptGenreator = {
88
88
  }
89
89
  },
90
90
  'stack': function (seriesType, seriesId, seriesModel, model) {
91
+ var isStack = seriesModel.get('stack') === INNER_STACK_KEYWORD;
91
92
  if (seriesType === 'line' || seriesType === 'bar') {
93
+ model.setIconStatus('stack', isStack ? 'normal' : 'emphasis');
92
94
  return zrUtil.merge({
93
95
  id: seriesId,
94
- stack: '__ec_magicType_stack__'
96
+ stack: isStack ? '' : INNER_STACK_KEYWORD
95
97
  }, model.get('option.stack') || {}, true);
96
98
  }
97
- },
98
- 'tiled': function (seriesType, seriesId, seriesModel, model) {
99
- if (seriesType === 'line' || seriesType === 'bar') {
100
- return zrUtil.merge({
101
- id: seriesId,
102
- stack: ''
103
- }, model.get('option.tiled') || {}, true);
104
- }
105
99
  }
106
100
  };
107
101
 
108
102
  var radioTypes = [
109
103
  ['line', 'bar'],
110
- ['stack', 'tiled']
104
+ ['stack']
111
105
  ];
112
106
 
113
107
  proto.onclick = function (ecModel, api, type) {
@@ -172,10 +166,21 @@ proto.onclick = function (ecModel, api, type) {
172
166
  }
173
167
  }, generateNewSeriesTypes
174
168
  );
169
+
170
+ var newTitle;
171
+ // Change title of stack
172
+ if (type === 'stack') {
173
+ var isStack = newOption.series && newOption.series[0] && newOption.series[0].stack === INNER_STACK_KEYWORD;
174
+ newTitle = isStack
175
+ ? zrUtil.merge({ stack: magicTypeLang.title.tiled }, magicTypeLang.title)
176
+ : zrUtil.clone(magicTypeLang.title);
177
+ }
178
+
175
179
  api.dispatchAction({
176
180
  type: 'changeMagicType',
177
181
  currentType: type,
178
- newOption: newOption
182
+ newOption: newOption,
183
+ newTitle: newTitle
179
184
  });
180
185
  };
181
186
 
package/src/coord/Axis.js CHANGED
@@ -85,7 +85,7 @@ Axis.prototype = {
85
85
  * @return {boolean}
86
86
  */
87
87
  containData: function (data) {
88
- return this.contain(this.dataToCoord(data));
88
+ return this.scale.contain(data);
89
89
  },
90
90
 
91
91
  /**
@@ -173,7 +173,7 @@ Axis.prototype = {
173
173
  * `axis.getTicksCoords` considers `onBand`, which is used by
174
174
  * `boundaryGap:true` of category axis and splitLine and splitArea.
175
175
  * @param {Object} [opt]
176
- * @param {number} [opt.tickModel=axis.model.getModel('axisTick')]
176
+ * @param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
177
177
  * @param {boolean} [opt.clamp] If `true`, the first and the last
178
178
  * tick must be at the axis end points. Otherwise, clip ticks
179
179
  * that outside the axis extent.
@@ -205,6 +205,33 @@ Axis.prototype = {
205
205
  return ticksCoords;
206
206
  },
207
207
 
208
+ /**
209
+ * @return {Array.<Array.<Object>>} [{ coord: ..., tickValue: ...}]
210
+ */
211
+ getMinorTicksCoords: function () {
212
+ if (this.scale.type === 'ordinal') {
213
+ // Category axis doesn't support minor ticks
214
+ return [];
215
+ }
216
+
217
+ var minorTickModel = this.model.getModel('minorTick');
218
+ var splitNumber = minorTickModel.get('splitNumber');
219
+ // Protection.
220
+ if (!(splitNumber > 0 && splitNumber < 100)) {
221
+ splitNumber = 5;
222
+ }
223
+ var minorTicks = this.scale.getMinorTicks(splitNumber);
224
+ var minorTicksCoords = map(minorTicks, function (minorTicksGroup) {
225
+ return map(minorTicksGroup, function (minorTick) {
226
+ return {
227
+ coord: this.dataToCoord(minorTick),
228
+ tickValue: minorTick
229
+ };
230
+ }, this);
231
+ }, this);
232
+ return minorTicksCoords;
233
+ },
234
+
208
235
  /**
209
236
  * @return {Array.<Object>} [{
210
237
  * formattedLabel: string,
@@ -166,7 +166,7 @@ axisDefault.valueAxis = zrUtil.merge({
166
166
  // scale: false,
167
167
 
168
168
  // AxisTick and axisLabel and splitLine are caculated based on splitNumber.
169
- splitNumber: 5
169
+ splitNumber: 5,
170
170
 
171
171
  // Interval specifies the span of the ticks is mandatorily.
172
172
  // interval: null
@@ -177,6 +177,30 @@ axisDefault.valueAxis = zrUtil.merge({
177
177
  // Specify max interval when auto calculate tick interval.
178
178
  // maxInterval: null
179
179
 
180
+ minorTick: {
181
+ // Minor tick, not available for cateogry axis.
182
+ show: false,
183
+ // Split number of minor ticks. The value should be in range of (0, 100)
184
+ splitNumber: 5,
185
+ // Lenght of minor tick
186
+ length: 3,
187
+
188
+ // Same inside with axisTick
189
+
190
+ // Line style
191
+ lineStyle: {
192
+ // Default to be same with axisTick
193
+ }
194
+ },
195
+
196
+ minorSplitLine: {
197
+ show: false,
198
+
199
+ lineStyle: {
200
+ color: '#eee',
201
+ width: 1
202
+ }
203
+ }
180
204
  }, defaultOption);
181
205
 
182
206
  axisDefault.timeAxis = zrUtil.defaults({
@@ -0,0 +1,135 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ import * as zrUtil from 'zrender/src/core/util';
21
+
22
+ /**
23
+ * @class
24
+ * @param {Object|DataDimensionInfo} [opt] All of the fields will be shallow copied.
25
+ */
26
+ function DataDimensionInfo(opt) {
27
+ if (opt != null) {
28
+ zrUtil.extend(this, opt);
29
+ }
30
+
31
+ /**
32
+ * Dimension name.
33
+ * Mandatory.
34
+ * @type {string}
35
+ */
36
+ // this.name;
37
+
38
+ /**
39
+ * The origin name in dimsDef, see source helper.
40
+ * If displayName given, the tooltip will displayed vertically.
41
+ * Optional.
42
+ * @type {string}
43
+ */
44
+ // this.displayName;
45
+
46
+ /**
47
+ * Which coordSys dimension this dimension mapped to.
48
+ * A `coordDim` can be a "coordSysDim" that the coordSys required
49
+ * (for example, an item in `coordSysDims` of `model/referHelper#CoordSysInfo`),
50
+ * or an generated "extra coord name" if does not mapped to any "coordSysDim"
51
+ * (That is determined by whether `isExtraCoord` is `true`).
52
+ * Mandatory.
53
+ * @type {string}
54
+ */
55
+ // this.coordDim;
56
+
57
+ /**
58
+ * The index of this dimension in `series.encode[coordDim]`.
59
+ * Mandatory.
60
+ * @type {number}
61
+ */
62
+ // this.coordDimIndex;
63
+
64
+ /**
65
+ * Dimension type. The enumerable values are the key of
66
+ * `dataCtors` of `data/List`.
67
+ * Optional.
68
+ * @type {string}
69
+ */
70
+ // this.type;
71
+
72
+ /**
73
+ * This index of this dimension info in `data/List#_dimensionInfos`.
74
+ * Mandatory after added to `data/List`.
75
+ * @type {number}
76
+ */
77
+ // this.index;
78
+
79
+ /**
80
+ * The format of `otherDims` is:
81
+ * ```js
82
+ * {
83
+ * tooltip: number optional,
84
+ * label: number optional,
85
+ * itemName: number optional,
86
+ * seriesName: number optional,
87
+ * }
88
+ * ```
89
+ *
90
+ * A `series.encode` can specified these fields:
91
+ * ```js
92
+ * encode: {
93
+ * // "3, 1, 5" is the index of data dimension.
94
+ * tooltip: [3, 1, 5],
95
+ * label: [0, 3],
96
+ * ...
97
+ * }
98
+ * ```
99
+ * `otherDims` is the parse result of the `series.encode` above, like:
100
+ * ```js
101
+ * // Suppose the index of this data dimension is `3`.
102
+ * this.otherDims = {
103
+ * // `3` is at the index `0` of the `encode.tooltip`
104
+ * tooltip: 0,
105
+ * // `3` is at the index `1` of the `encode.tooltip`
106
+ * label: 1
107
+ * };
108
+ * ```
109
+ *
110
+ * This prop should never be `null`/`undefined` after initialized.
111
+ * @type {Object}
112
+ */
113
+ this.otherDims = {};
114
+
115
+ /**
116
+ * Be `true` if this dimension is not mapped to any "coordSysDim" that the
117
+ * "coordSys" required.
118
+ * Mandatory.
119
+ * @type {boolean}
120
+ */
121
+ // this.isExtraCoord;
122
+
123
+ /**
124
+ * @type {module:data/OrdinalMeta}
125
+ */
126
+ // this.ordinalMeta;
127
+
128
+ /**
129
+ * Whether to create inverted indices.
130
+ * @type {boolean}
131
+ */
132
+ // this.createInvertedIndices;
133
+ };
134
+
135
+ export default DataDimensionInfo;
package/src/data/List.js CHANGED
@@ -31,6 +31,7 @@ import DataDiffer from './DataDiffer';
31
31
  import Source from './Source';
32
32
  import {defaultDimValueGetters, DefaultDataProvider} from './helper/dataProvider';
33
33
  import {summarizeDimensions} from './helper/dimensionHelper';
34
+ import DataDimensionInfo from './DataDimensionInfo';
34
35
 
35
36
  var isObject = zrUtil.isObject;
36
37
 
@@ -102,13 +103,9 @@ function transferProperties(target, source) {
102
103
  * @constructor
103
104
  * @alias module:echarts/data/List
104
105
  *
105
- * @param {Array.<string|Object>} dimensions
106
+ * @param {Array.<string|Object|module:data/DataDimensionInfo>} dimensions
106
107
  * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
107
108
  * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
108
- * Spetial fields: {
109
- * ordinalMeta: <module:echarts/data/OrdinalMeta>
110
- * createInvertedIndices: <boolean>
111
- * }
112
109
  * @param {module:echarts/model/Model} hostModel
113
110
  */
114
111
  var List = function (dimensions, hostModel) {
@@ -124,7 +121,10 @@ var List = function (dimensions, hostModel) {
124
121
  var dimensionInfo = dimensions[i];
125
122
 
126
123
  if (zrUtil.isString(dimensionInfo)) {
127
- dimensionInfo = {name: dimensionInfo};
124
+ dimensionInfo = new DataDimensionInfo({name: dimensionInfo});
125
+ }
126
+ else if (!(dimensionInfo instanceof DataDimensionInfo)) {
127
+ dimensionInfo = new DataDimensionInfo(dimensionInfo);
128
128
  }
129
129
 
130
130
  var dimensionName = dimensionInfo.name;
@@ -1144,7 +1144,8 @@ listProto.indexOfRawIndex = function (rawIndex) {
1144
1144
  * @param {string} dim
1145
1145
  * @param {number} value
1146
1146
  * @param {number} [maxDistance=Infinity]
1147
- * @return {Array.<number>} Considere multiple points has the same value.
1147
+ * @return {Array.<number>} If and only if multiple indices has
1148
+ * the same value, they are put to the result.
1148
1149
  */
1149
1150
  listProto.indicesOfNearest = function (dim, value, maxDistance) {
1150
1151
  var storage = this._storage;
@@ -1159,23 +1160,35 @@ listProto.indicesOfNearest = function (dim, value, maxDistance) {
1159
1160
  maxDistance = Infinity;
1160
1161
  }
1161
1162
 
1162
- var minDist = Number.MAX_VALUE;
1163
+ var minDist = Infinity;
1163
1164
  var minDiff = -1;
1165
+ var nearestIndicesLen = 0;
1166
+
1167
+ // Check the test case of `test/ut/spec/data/List.js`.
1164
1168
  for (var i = 0, len = this.count(); i < len; i++) {
1165
- var diff = value - this.get(dim, i /*, stack */);
1169
+ var diff = value - this.get(dim, i);
1166
1170
  var dist = Math.abs(diff);
1167
- if (diff <= maxDistance && dist <= minDist) {
1168
- // For the case of two data are same on xAxis, which has sequence data.
1169
- // Show the nearest index
1170
- // https://github.com/ecomfe/echarts/issues/2869
1171
- if (dist < minDist || (diff >= 0 && minDiff < 0)) {
1171
+ if (dist <= maxDistance) {
1172
+ // When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,
1173
+ // we'd better not push both of them to `nearestIndices`, otherwise it is easy to
1174
+ // get more than one item in `nearestIndices` (more specifically, in `tooltip`).
1175
+ // So we chose the one that `diff >= 0` in this csae.
1176
+ // But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them
1177
+ // should be push to `nearestIndices`.
1178
+ if (dist < minDist
1179
+ || (dist === minDist && diff >= 0 && minDiff < 0)
1180
+ ) {
1172
1181
  minDist = dist;
1173
1182
  minDiff = diff;
1174
- nearestIndices.length = 0;
1183
+ nearestIndicesLen = 0;
1184
+ }
1185
+ if (diff === minDiff) {
1186
+ nearestIndices[nearestIndicesLen++] = i;
1175
1187
  }
1176
- nearestIndices.push(i);
1177
1188
  }
1178
1189
  }
1190
+ nearestIndices.length = nearestIndicesLen;
1191
+
1179
1192
  return nearestIndices;
1180
1193
  };
1181
1194
 
package/src/data/Tree.js CHANGED
@@ -472,7 +472,7 @@ Tree.prototype = {
472
472
  * @param {Array.<Object>} treeOptions.leaves
473
473
  * @return module:echarts/data/Tree
474
474
  */
475
- Tree.createTree = function (dataRoot, hostModel, treeOptions) {
475
+ Tree.createTree = function (dataRoot, hostModel, treeOptions, beforeLink) {
476
476
 
477
477
  var tree = new Tree(hostModel, treeOptions.levels, treeOptions.leaves);
478
478
  var listData = [];
@@ -519,6 +519,8 @@ Tree.createTree = function (dataRoot, hostModel, treeOptions) {
519
519
 
520
520
  tree.update();
521
521
 
522
+ beforeLink && beforeLink(list);
523
+
522
524
  return tree;
523
525
  };
524
526