echarts 3.5.4 → 3.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 (190) hide show
  1. package/LICENSE +21 -18
  2. package/dist/echarts.common.js +10072 -9330
  3. package/dist/echarts.common.min.js +13 -13
  4. package/dist/echarts.js +13084 -11412
  5. package/dist/echarts.min.js +22 -21
  6. package/dist/echarts.simple.js +9454 -8889
  7. package/dist/echarts.simple.min.js +9 -10
  8. package/index.js +1 -0
  9. package/lib/chart/bar/BarView.js +141 -49
  10. package/lib/chart/bar/BaseBarSeries.js +2 -6
  11. package/lib/chart/bar.js +1 -0
  12. package/lib/chart/boxplot/BoxplotSeries.js +1 -1
  13. package/lib/chart/boxplot/boxplotLayout.js +23 -7
  14. package/lib/chart/candlestick/CandlestickSeries.js +1 -21
  15. package/lib/chart/candlestick/candlestickLayout.js +23 -7
  16. package/lib/chart/custom.js +442 -0
  17. package/lib/chart/graph/categoryVisual.js +3 -2
  18. package/lib/chart/heatmap/HeatmapView.js +75 -73
  19. package/lib/chart/helper/Symbol.js +8 -31
  20. package/lib/chart/helper/createListFromArray.js +15 -10
  21. package/lib/chart/helper/labelHelper.js +48 -0
  22. package/lib/chart/helper/whiskerBoxCommon.js +25 -44
  23. package/lib/chart/map/mapDataStatistic.js +9 -8
  24. package/lib/chart/pie/pieLayout.js +25 -17
  25. package/lib/chart/radar/RadarSeries.js +1 -1
  26. package/lib/chart/scatter/ScatterSeries.js +2 -3
  27. package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
  28. package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
  29. package/lib/chart/treemap/TreemapSeries.js +3 -3
  30. package/lib/component/axisPointer/BaseAxisPointer.js +7 -6
  31. package/lib/component/axisPointer/axisTrigger.js +62 -51
  32. package/lib/component/axisPointer.js +1 -2
  33. package/lib/component/calendar/CalendarView.js +5 -5
  34. package/lib/component/dataZoom/AxisProxy.js +76 -13
  35. package/lib/component/dataZoom/DataZoomModel.js +21 -5
  36. package/lib/component/dataZoom/InsideZoomModel.js +4 -1
  37. package/lib/component/dataZoom/InsideZoomView.js +16 -26
  38. package/lib/component/dataZoom/SliderZoomView.js +63 -26
  39. package/lib/component/dataZoom/roams.js +8 -3
  40. package/lib/component/graphic.js +13 -12
  41. package/lib/component/helper/BrushTargetManager.js +5 -5
  42. package/lib/component/helper/MapDraw.js +3 -3
  43. package/lib/component/helper/RoamController.js +43 -20
  44. package/lib/component/helper/brushHelper.js +2 -13
  45. package/lib/component/helper/selectableMixin.js +7 -7
  46. package/lib/component/helper/sliderMove.js +65 -36
  47. package/lib/component/legend/LegendView.js +6 -6
  48. package/lib/component/legend/legendAction.js +1 -1
  49. package/lib/component/marker/MarkAreaView.js +3 -6
  50. package/lib/component/marker/MarkLineView.js +3 -5
  51. package/lib/component/marker/MarkPointView.js +3 -5
  52. package/lib/component/marker/MarkerView.js +10 -12
  53. package/lib/component/polar.js +5 -0
  54. package/lib/component/timeline/SliderTimelineView.js +1 -1
  55. package/lib/component/toolbox/feature/DataZoom.js +14 -1
  56. package/lib/component/tooltip/TooltipView.js +3 -3
  57. package/lib/component/visualMap/ContinuousView.js +6 -4
  58. package/lib/coord/Axis.js +34 -2
  59. package/lib/coord/axisDefault.js +2 -1
  60. package/lib/coord/axisHelper.js +6 -25
  61. package/lib/coord/axisModelCommonMixin.js +1 -1
  62. package/lib/coord/calendar/Calendar.js +14 -17
  63. package/lib/coord/calendar/prepareCustom.js +31 -0
  64. package/lib/coord/cartesian/Axis2D.js +0 -12
  65. package/lib/coord/cartesian/Cartesian2D.js +1 -0
  66. package/lib/coord/cartesian/Grid.js +5 -2
  67. package/lib/coord/cartesian/prepareCustom.js +36 -0
  68. package/lib/coord/geo/Geo.js +9 -14
  69. package/lib/coord/geo/GeoModel.js +5 -5
  70. package/lib/coord/geo/geoCreator.js +3 -3
  71. package/lib/coord/geo/prepareCustom.js +36 -0
  72. package/lib/coord/parallel/Parallel.js +12 -11
  73. package/lib/coord/polar/Polar.js +2 -1
  74. package/lib/coord/polar/prepareCustom.js +53 -0
  75. package/lib/coord/single/Single.js +9 -8
  76. package/lib/coord/single/SingleAxis.js +0 -27
  77. package/lib/coord/single/prepareCustom.js +33 -0
  78. package/lib/data/DataDiffer.js +2 -1
  79. package/lib/data/Graph.js +11 -7
  80. package/lib/data/List.js +58 -19
  81. package/lib/data/helper/completeDimensions.js +184 -23
  82. package/lib/echarts.js +38 -33
  83. package/lib/helper.js +1 -8
  84. package/lib/layout/barGrid.js +87 -18
  85. package/lib/layout/barPolar.js +286 -0
  86. package/lib/layout/points.js +22 -16
  87. package/lib/model/Global.js +34 -31
  88. package/lib/model/Series.js +41 -29
  89. package/lib/model/mixin/colorPalette.js +2 -1
  90. package/lib/model/mixin/textStyle.js +7 -13
  91. package/lib/scale/Interval.js +21 -14
  92. package/lib/scale/Log.js +5 -7
  93. package/lib/scale/Time.js +13 -7
  94. package/lib/scale/helper.js +5 -1
  95. package/lib/util/format.js +12 -0
  96. package/lib/util/graphic.js +53 -1
  97. package/lib/util/model.js +63 -7
  98. package/map/js/world.js +1 -1
  99. package/map/json/world.json +1 -1
  100. package/package.json +3 -3
  101. package/src/chart/bar/BarView.js +141 -49
  102. package/src/chart/bar/BaseBarSeries.js +2 -6
  103. package/src/chart/bar.js +1 -0
  104. package/src/chart/boxplot/BoxplotSeries.js +1 -1
  105. package/src/chart/boxplot/boxplotLayout.js +23 -7
  106. package/src/chart/candlestick/CandlestickSeries.js +1 -21
  107. package/src/chart/candlestick/candlestickLayout.js +23 -7
  108. package/src/chart/custom.js +442 -0
  109. package/src/chart/graph/categoryVisual.js +3 -2
  110. package/src/chart/heatmap/HeatmapView.js +75 -73
  111. package/src/chart/helper/Symbol.js +8 -31
  112. package/src/chart/helper/createListFromArray.js +15 -10
  113. package/src/chart/helper/labelHelper.js +49 -0
  114. package/src/chart/helper/whiskerBoxCommon.js +25 -44
  115. package/src/chart/map/mapDataStatistic.js +9 -8
  116. package/src/chart/pie/pieLayout.js +25 -17
  117. package/src/chart/radar/RadarSeries.js +1 -1
  118. package/src/chart/scatter/ScatterSeries.js +2 -3
  119. package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
  120. package/src/chart/themeRiver/themeRiverVisual.js +1 -1
  121. package/src/chart/treemap/TreemapSeries.js +3 -3
  122. package/src/component/axisPointer/BaseAxisPointer.js +7 -6
  123. package/src/component/axisPointer/axisTrigger.js +62 -51
  124. package/src/component/axisPointer.js +1 -2
  125. package/src/component/calendar/CalendarView.js +5 -5
  126. package/src/component/dataZoom/AxisProxy.js +76 -13
  127. package/src/component/dataZoom/DataZoomModel.js +21 -5
  128. package/src/component/dataZoom/InsideZoomModel.js +4 -1
  129. package/src/component/dataZoom/InsideZoomView.js +16 -26
  130. package/src/component/dataZoom/SliderZoomView.js +63 -26
  131. package/src/component/dataZoom/roams.js +8 -3
  132. package/src/component/graphic.js +13 -12
  133. package/src/component/helper/BrushTargetManager.js +5 -5
  134. package/src/component/helper/MapDraw.js +3 -3
  135. package/src/component/helper/RoamController.js +43 -20
  136. package/src/component/helper/brushHelper.js +2 -13
  137. package/src/component/helper/selectableMixin.js +7 -7
  138. package/src/component/helper/sliderMove.js +65 -36
  139. package/src/component/legend/LegendView.js +6 -6
  140. package/src/component/legend/legendAction.js +1 -1
  141. package/src/component/marker/MarkAreaView.js +3 -6
  142. package/src/component/marker/MarkLineView.js +3 -5
  143. package/src/component/marker/MarkPointView.js +3 -5
  144. package/src/component/marker/MarkerView.js +10 -12
  145. package/src/component/polar.js +5 -0
  146. package/src/component/timeline/SliderTimelineView.js +1 -1
  147. package/src/component/toolbox/feature/DataZoom.js +14 -1
  148. package/src/component/tooltip/TooltipView.js +3 -3
  149. package/src/component/visualMap/ContinuousView.js +6 -4
  150. package/src/coord/Axis.js +34 -2
  151. package/src/coord/axisDefault.js +2 -1
  152. package/src/coord/axisHelper.js +6 -25
  153. package/src/coord/axisModelCommonMixin.js +1 -1
  154. package/src/coord/calendar/Calendar.js +14 -17
  155. package/src/coord/calendar/prepareCustom.js +32 -0
  156. package/src/coord/cartesian/Axis2D.js +0 -12
  157. package/src/coord/cartesian/Cartesian2D.js +1 -0
  158. package/src/coord/cartesian/Grid.js +5 -2
  159. package/src/coord/cartesian/prepareCustom.js +37 -0
  160. package/src/coord/geo/Geo.js +9 -14
  161. package/src/coord/geo/GeoModel.js +5 -5
  162. package/src/coord/geo/geoCreator.js +3 -3
  163. package/src/coord/geo/prepareCustom.js +37 -0
  164. package/src/coord/parallel/Parallel.js +12 -11
  165. package/src/coord/polar/Polar.js +2 -1
  166. package/src/coord/polar/prepareCustom.js +54 -0
  167. package/src/coord/single/Single.js +9 -8
  168. package/src/coord/single/SingleAxis.js +0 -27
  169. package/src/coord/single/prepareCustom.js +34 -0
  170. package/src/data/DataDiffer.js +2 -1
  171. package/src/data/Graph.js +11 -7
  172. package/src/data/List.js +58 -19
  173. package/src/data/helper/completeDimensions.js +184 -23
  174. package/src/echarts.js +38 -33
  175. package/src/helper.js +1 -8
  176. package/src/layout/barGrid.js +87 -18
  177. package/src/layout/barPolar.js +287 -0
  178. package/src/layout/points.js +22 -16
  179. package/src/model/Global.js +34 -31
  180. package/src/model/Series.js +41 -29
  181. package/src/model/mixin/colorPalette.js +2 -1
  182. package/src/model/mixin/textStyle.js +7 -13
  183. package/src/scale/Interval.js +21 -14
  184. package/src/scale/Log.js +5 -7
  185. package/src/scale/Time.js +13 -7
  186. package/src/scale/helper.js +5 -1
  187. package/src/util/format.js +12 -0
  188. package/src/util/graphic.js +53 -1
  189. package/src/util/model.js +63 -7
  190. package/src/coord/cartesian/axisLabelInterval.js +0 -26
@@ -63,7 +63,7 @@ define(function (require) {
63
63
  this._optionManager = optionManager;
64
64
  },
65
65
 
66
- setOption: function (option, optionPreprocessorFuncs, onlyGraphic) {
66
+ setOption: function (option, optionPreprocessorFuncs) {
67
67
  zrUtil.assert(
68
68
  !(OPTION_INNER_KEY in option),
69
69
  'please use chart.getOption()'
@@ -71,7 +71,7 @@ define(function (require) {
71
71
 
72
72
  this._optionManager.setOption(option, optionPreprocessorFuncs);
73
73
 
74
- this.resetOption(null, onlyGraphic);
74
+ this.resetOption(null);
75
75
  },
76
76
 
77
77
  /**
@@ -81,7 +81,7 @@ define(function (require) {
81
81
  * 'media': only reset media query option
82
82
  * @return {boolean} Whether option changed.
83
83
  */
84
- resetOption: function (type, onlyGraphic) {
84
+ resetOption: function (type) {
85
85
  var optionChanged = false;
86
86
  var optionManager = this._optionManager;
87
87
 
@@ -92,11 +92,7 @@ define(function (require) {
92
92
  initBase.call(this, baseOption);
93
93
  }
94
94
  else {
95
- // If only graphic, other series and component will not
96
- // go through update process, data should not be restored.
97
- // Otherwise grphic els mounted on data will be eliminated
98
- // and downplay will not work.
99
- !onlyGraphic && this.restoreData();
95
+ this.restoreData();
100
96
  this.mergeOption(baseOption);
101
97
  }
102
98
  optionChanged = true;
@@ -158,7 +154,7 @@ define(function (require) {
158
154
  var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
159
155
 
160
156
  var mapResult = modelUtil.mappingToExists(
161
- componentsMap[mainType], newCptOptionList
157
+ componentsMap.get(mainType), newCptOptionList
162
158
  );
163
159
 
164
160
  modelUtil.makeIdAndName(mapResult);
@@ -177,7 +173,7 @@ define(function (require) {
177
173
  );
178
174
 
179
175
  option[mainType] = [];
180
- componentsMap[mainType] = [];
176
+ componentsMap.set(mainType, []);
181
177
 
182
178
  each(mapResult, function (resultItem, index) {
183
179
  var componentModel = resultItem.exist;
@@ -227,13 +223,13 @@ define(function (require) {
227
223
  }
228
224
  }
229
225
 
230
- componentsMap[mainType][index] = componentModel;
226
+ componentsMap.get(mainType)[index] = componentModel;
231
227
  option[mainType][index] = componentModel.option;
232
228
  }, this);
233
229
 
234
230
  // Backup series for filtering.
235
231
  if (mainType === 'series') {
236
- this._seriesIndices = createSeriesIndices(componentsMap.series);
232
+ this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
237
233
  }
238
234
  }
239
235
  },
@@ -277,7 +273,7 @@ define(function (require) {
277
273
  * @return {module:echarts/model/Component}
278
274
  */
279
275
  getComponent: function (mainType, idx) {
280
- var list = this._componentsMap[mainType];
276
+ var list = this._componentsMap.get(mainType);
281
277
  if (list) {
282
278
  return list[idx || 0];
283
279
  }
@@ -303,7 +299,7 @@ define(function (require) {
303
299
  var id = condition.id;
304
300
  var name = condition.name;
305
301
 
306
- var cpts = this._componentsMap[mainType];
302
+ var cpts = this._componentsMap.get(mainType);
307
303
 
308
304
  if (!cpts || !cpts.length) {
309
305
  return [];
@@ -378,7 +374,7 @@ define(function (require) {
378
374
  var queryCond = getQueryCond(query);
379
375
  var result = queryCond
380
376
  ? this.queryComponents(queryCond)
381
- : this._componentsMap[mainType];
377
+ : this._componentsMap.get(mainType);
382
378
 
383
379
  return doFilter(filterBySubType(result, condition));
384
380
 
@@ -437,14 +433,14 @@ define(function (require) {
437
433
  if (typeof mainType === 'function') {
438
434
  context = cb;
439
435
  cb = mainType;
440
- each(componentsMap, function (components, componentType) {
436
+ componentsMap.each(function (components, componentType) {
441
437
  each(components, function (component, index) {
442
438
  cb.call(context, componentType, component, index);
443
439
  });
444
440
  });
445
441
  }
446
442
  else if (zrUtil.isString(mainType)) {
447
- each(componentsMap[mainType], cb, context);
443
+ each(componentsMap.get(mainType), cb, context);
448
444
  }
449
445
  else if (isObject(mainType)) {
450
446
  var queryResult = this.findComponents(mainType);
@@ -457,7 +453,7 @@ define(function (require) {
457
453
  * @return {Array.<module:echarts/model/Series>}
458
454
  */
459
455
  getSeriesByName: function (name) {
460
- var series = this._componentsMap.series;
456
+ var series = this._componentsMap.get('series');
461
457
  return filter(series, function (oneSeries) {
462
458
  return oneSeries.name === name;
463
459
  });
@@ -468,7 +464,7 @@ define(function (require) {
468
464
  * @return {module:echarts/model/Series}
469
465
  */
470
466
  getSeriesByIndex: function (seriesIndex) {
471
- return this._componentsMap.series[seriesIndex];
467
+ return this._componentsMap.get('series')[seriesIndex];
472
468
  },
473
469
 
474
470
  /**
@@ -476,7 +472,7 @@ define(function (require) {
476
472
  * @return {Array.<module:echarts/model/Series>}
477
473
  */
478
474
  getSeriesByType: function (subType) {
479
- var series = this._componentsMap.series;
475
+ var series = this._componentsMap.get('series');
480
476
  return filter(series, function (oneSeries) {
481
477
  return oneSeries.subType === subType;
482
478
  });
@@ -486,7 +482,7 @@ define(function (require) {
486
482
  * @return {Array.<module:echarts/model/Series>}
487
483
  */
488
484
  getSeries: function () {
489
- return this._componentsMap.series.slice();
485
+ return this._componentsMap.get('series').slice();
490
486
  },
491
487
 
492
488
  /**
@@ -499,7 +495,7 @@ define(function (require) {
499
495
  eachSeries: function (cb, context) {
500
496
  assertSeriesInitialized(this);
501
497
  each(this._seriesIndices, function (rawSeriesIndex) {
502
- var series = this._componentsMap.series[rawSeriesIndex];
498
+ var series = this._componentsMap.get('series')[rawSeriesIndex];
503
499
  cb.call(context, series, rawSeriesIndex);
504
500
  }, this);
505
501
  },
@@ -511,7 +507,7 @@ define(function (require) {
511
507
  * @param {*} context
512
508
  */
513
509
  eachRawSeries: function (cb, context) {
514
- each(this._componentsMap.series, cb, context);
510
+ each(this._componentsMap.get('series'), cb, context);
515
511
  },
516
512
 
517
513
  /**
@@ -525,7 +521,7 @@ define(function (require) {
525
521
  eachSeriesByType: function (subType, cb, context) {
526
522
  assertSeriesInitialized(this);
527
523
  each(this._seriesIndices, function (rawSeriesIndex) {
528
- var series = this._componentsMap.series[rawSeriesIndex];
524
+ var series = this._componentsMap.get('series')[rawSeriesIndex];
529
525
  if (series.subType === subType) {
530
526
  cb.call(context, series, rawSeriesIndex);
531
527
  }
@@ -551,6 +547,13 @@ define(function (require) {
551
547
  return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
552
548
  },
553
549
 
550
+ /**
551
+ * @return {Array.<number>}
552
+ */
553
+ getCurrentSeriesIndices: function () {
554
+ return (this._seriesIndices || []).slice();
555
+ },
556
+
554
557
  /**
555
558
  * @param {Function} cb
556
559
  * @param {*} context
@@ -558,7 +561,7 @@ define(function (require) {
558
561
  filterSeries: function (cb, context) {
559
562
  assertSeriesInitialized(this);
560
563
  var filteredSeries = filter(
561
- this._componentsMap.series, cb, context
564
+ this._componentsMap.get('series'), cb, context
562
565
  );
563
566
  this._seriesIndices = createSeriesIndices(filteredSeries);
564
567
  },
@@ -566,10 +569,10 @@ define(function (require) {
566
569
  restoreData: function () {
567
570
  var componentsMap = this._componentsMap;
568
571
 
569
- this._seriesIndices = createSeriesIndices(componentsMap.series);
572
+ this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
570
573
 
571
574
  var componentTypes = [];
572
- each(componentsMap, function (components, componentType) {
575
+ componentsMap.each(function (components, componentType) {
573
576
  componentTypes.push(componentType);
574
577
  });
575
578
 
@@ -577,7 +580,7 @@ define(function (require) {
577
580
  componentTypes,
578
581
  ComponentModel.getAllClassMainTypes(),
579
582
  function (componentType, dependencies) {
580
- each(componentsMap[componentType], function (component) {
583
+ each(componentsMap.get(componentType), function (component) {
581
584
  component.restoreData();
582
585
  });
583
586
  }
@@ -621,7 +624,7 @@ define(function (require) {
621
624
  * @type {Object.<string, Array.<module:echarts/model/Model>>}
622
625
  * @private
623
626
  */
624
- this._componentsMap = {series: []};
627
+ this._componentsMap = zrUtil.createHashMap({series: []});
625
628
 
626
629
  /**
627
630
  * Mapping between filtered series list and raw series list.
@@ -651,7 +654,7 @@ define(function (require) {
651
654
 
652
655
  var ret = {};
653
656
  each(types, function (type) {
654
- ret[type] = (componentsMap[type] || []).slice();
657
+ ret[type] = (componentsMap.get(type) || []).slice();
655
658
  });
656
659
 
657
660
  return ret;
@@ -702,7 +705,7 @@ define(function (require) {
702
705
  // which make sure that their initialization is after series.
703
706
  if (__DEV__) {
704
707
  if (!ecModel._seriesIndices) {
705
- throw new Error('Series has not been initialized yet.');
708
+ throw new Error('Option should contains series.');
706
709
  }
707
710
  }
708
711
  }
@@ -182,7 +182,7 @@ define(function(require) {
182
182
  * @return {Array.<string>} dimensions on the axis.
183
183
  */
184
184
  coordDimToDataDim: function (coordDim) {
185
- return [coordDim];
185
+ return modelUtil.coordDimToDataDim(this.getData(), coordDim);
186
186
  },
187
187
 
188
188
  /**
@@ -192,7 +192,7 @@ define(function(require) {
192
192
  * @return {string}
193
193
  */
194
194
  dataDimToCoordDim: function (dataDim) {
195
- return dataDim;
195
+ return modelUtil.dataDimToCoordDim(this.getData(), dataDim);
196
196
  },
197
197
 
198
198
  /**
@@ -216,35 +216,46 @@ define(function(require) {
216
216
  */
217
217
  formatTooltip: function (dataIndex, multipleSeries, dataType) {
218
218
  function formatArrayValue(value) {
219
- var result = [];
220
-
221
- zrUtil.each(value, function (val, idx) {
222
- var dimInfo = data.getDimensionInfo(idx);
223
- var dimType = dimInfo && dimInfo.type;
224
- var valStr;
219
+ var vertially = zrUtil.reduce(value, function (vertially, val, idx) {
220
+ var dimItem = data.getDimensionInfo(idx);
221
+ return vertially |= dimItem.tooltip !== false && dimItem.tooltipName != null;
222
+ }, 0);
225
223
 
226
- if (dimType === 'ordinal') {
227
- valStr = val + '';
228
- }
229
- else if (dimType === 'time') {
230
- valStr = multipleSeries ? '' : formatUtil.formatTime('yyyy/MM/dd hh:mm:ss', val);
231
- }
232
- else {
233
- valStr = addCommas(val);
224
+ var result = [];
225
+ var tooltipDims = modelUtil.otherDimToDataDim(data, 'tooltip');
226
+
227
+ tooltipDims.length
228
+ ? zrUtil.each(tooltipDims, function (dimIdx) {
229
+ setEachItem(data.get(dimIdx, dataIndex), dimIdx);
230
+ })
231
+ // By default, all dims is used on tooltip.
232
+ : zrUtil.each(value, setEachItem);
233
+
234
+ function setEachItem(val, dimIdx) {
235
+ var dimInfo = data.getDimensionInfo(dimIdx);
236
+ // If `dimInfo.tooltip` is not set, show tooltip.
237
+ if (!dimInfo || dimInfo.otherDims.tooltip === false) {
238
+ return;
234
239
  }
240
+ var dimType = dimInfo.type;
241
+ var valStr = (vertially ? '- ' + (dimInfo.tooltipName || dimInfo.name) + ': ' : '')
242
+ + (dimType === 'ordinal'
243
+ ? val + ''
244
+ : dimType === 'time'
245
+ ? (multipleSeries ? '' : formatUtil.formatTime('yyyy/MM/dd hh:mm:ss', val))
246
+ : addCommas(val)
247
+ );
248
+ valStr && result.push(encodeHTML(valStr));
249
+ }
235
250
 
236
- valStr && result.push(valStr);
237
- });
238
-
239
- return result.join(', ');
251
+ return (vertially ? '<br/>' : '') + result.join(vertially ? '<br/>' : ', ');
240
252
  }
241
253
 
242
254
  var data = get(this, 'data');
243
255
 
244
256
  var value = this.getRawValue(dataIndex);
245
- var formattedValue = encodeHTML(
246
- zrUtil.isArray(value) ? formatArrayValue(value) : addCommas(value)
247
- );
257
+ var formattedValue = zrUtil.isArray(value)
258
+ ? formatArrayValue(value) : encodeHTML(addCommas(value));
248
259
  var name = data.getName(dataIndex);
249
260
 
250
261
  var color = data.getItemVisual(dataIndex, 'color');
@@ -253,8 +264,7 @@ define(function(require) {
253
264
  }
254
265
  color = color || 'transparent';
255
266
 
256
- var colorEl = '<span style="display:inline-block;margin-right:5px;'
257
- + 'border-radius:10px;width:9px;height:9px;background-color:' + encodeHTML(color) + '"></span>';
267
+ var colorEl = formatUtil.getTooltipMarker(color);
258
268
 
259
269
  var seriesName = this.name;
260
270
  // FIXME
@@ -262,14 +272,16 @@ define(function(require) {
262
272
  // Not show '-'
263
273
  seriesName = '';
264
274
  }
275
+ seriesName = seriesName
276
+ ? encodeHTML(seriesName) + (!multipleSeries ? '<br/>' : ': ')
277
+ : '';
265
278
  return !multipleSeries
266
- ? ((seriesName && encodeHTML(seriesName) + '<br />') + colorEl
279
+ ? seriesName + colorEl
267
280
  + (name
268
- ? encodeHTML(name) + ' : ' + formattedValue
281
+ ? encodeHTML(name) + ': ' + formattedValue
269
282
  : formattedValue
270
283
  )
271
- )
272
- : (colorEl + encodeHTML(this.name) + ' : ' + formattedValue);
284
+ : colorEl + seriesName + formattedValue;
273
285
  },
274
286
 
275
287
  /**
@@ -14,7 +14,8 @@ define(function (require) {
14
14
  scope = scope || this;
15
15
  var colorIdx = get(scope, 'colorIdx') || 0;
16
16
  var colorNameMap = get(scope, 'colorNameMap') || set(scope, 'colorNameMap', {});
17
- if (colorNameMap[name]) {
17
+ // Use `hasOwnProperty` to avoid conflict with Object.prototype.
18
+ if (colorNameMap.hasOwnProperty(name)) {
18
19
  return colorNameMap[name];
19
20
  }
20
21
  var colorPalette = this.get('color', true) || [];
@@ -1,10 +1,7 @@
1
1
  define(function (require) {
2
2
 
3
3
  var textContain = require('zrender/contain/text');
4
-
5
- function getShallow(model, path) {
6
- return model && model.getShallow(path);
7
- }
4
+ var graphicUtil = require('../../util/graphic');
8
5
 
9
6
  return {
10
7
  /**
@@ -22,15 +19,12 @@ define(function (require) {
22
19
  * @return {string}
23
20
  */
24
21
  getFont: function () {
25
- var ecModel = this.ecModel;
26
- var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
27
- return [
28
- // FIXME in node-canvas fontWeight is before fontStyle
29
- this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'),
30
- this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'),
31
- (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px',
32
- this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif'
33
- ].join(' ');
22
+ return graphicUtil.getFont({
23
+ fontStyle: this.getShallow('fontStyle'),
24
+ fontWeight: this.getShallow('fontWeight'),
25
+ fontSize: this.getShallow('fontSize'),
26
+ fontFamily: this.getShallow('fontFamily')
27
+ }, this.ecModel);
34
28
  },
35
29
 
36
30
  getTextRect: function (text) {
@@ -47,8 +47,10 @@ define(function (require) {
47
47
  * Get interval
48
48
  */
49
49
  getInterval: function () {
50
- if (!this._interval) {
51
- this.niceTicks();
50
+ if (__DEV__) {
51
+ if (this._interval == null) {
52
+ throw new Error('`nice` should be called firstly' );
53
+ }
52
54
  }
53
55
  return this._interval;
54
56
  },
@@ -67,8 +69,10 @@ define(function (require) {
67
69
  * @return {Array.<number>}
68
70
  */
69
71
  getTicks: function () {
70
- if (!this._interval) {
71
- this.niceTicks();
72
+ if (__DEV__) {
73
+ if (this._interval == null) {
74
+ throw new Error('`nice` should be called firstly' );
75
+ }
72
76
  }
73
77
  return helper.intervalScaleGetTicks(
74
78
  this._interval, this._extent, this._niceExtent, this._intervalPrecision
@@ -120,8 +124,9 @@ define(function (require) {
120
124
  * Update interval and extent of intervals for nice ticks
121
125
  *
122
126
  * @param {number} [splitNumber = 5] Desired number of ticks
127
+ * @param {number} [minInterval]
123
128
  */
124
- niceTicks: function (splitNumber) {
129
+ niceTicks: function (splitNumber, minInterval) {
125
130
  splitNumber = splitNumber || 5;
126
131
  var extent = this._extent;
127
132
  var span = extent[1] - extent[0];
@@ -135,7 +140,7 @@ define(function (require) {
135
140
  extent.reverse();
136
141
  }
137
142
 
138
- var result = helper.intervalScaleNiceTicks(extent, splitNumber);
143
+ var result = helper.intervalScaleNiceTicks(extent, splitNumber, minInterval);
139
144
 
140
145
  this._intervalPrecision = result.intervalPrecision;
141
146
  this._interval = result.interval;
@@ -144,11 +149,13 @@ define(function (require) {
144
149
 
145
150
  /**
146
151
  * Nice extent.
147
- * @param {number} [splitNumber = 5] Given approx tick number
148
- * @param {boolean} [fixMin=false]
149
- * @param {boolean} [fixMax=false]
152
+ * @param {Object} opt
153
+ * @param {number} [opt.splitNumber = 5] Given approx tick number
154
+ * @param {boolean} [opt.fixMin=false]
155
+ * @param {boolean} [opt.fixMax=false]
156
+ * @param {boolean} [opt.minInterval=false]
150
157
  */
151
- niceExtent: function (splitNumber, fixMin, fixMax) {
158
+ niceExtent: function (opt) {
152
159
  var extent = this._extent;
153
160
  // If extent start and end are same, expand them
154
161
  if (extent[0] === extent[1]) {
@@ -160,7 +167,7 @@ define(function (require) {
160
167
  // Plus data are all 100 and axis extent are [100, 100].
161
168
  // Extend to the both side will cause expanded max is larger than fixed max.
162
169
  // So only expand to the smaller side.
163
- if (!fixMax) {
170
+ if (!opt.fixMax) {
164
171
  extent[1] += expandSize / 2;
165
172
  extent[0] -= expandSize / 2;
166
173
  }
@@ -179,15 +186,15 @@ define(function (require) {
179
186
  extent[1] = 1;
180
187
  }
181
188
 
182
- this.niceTicks(splitNumber);
189
+ this.niceTicks(opt.splitNumber, opt.minInterval);
183
190
 
184
191
  // var extent = this._extent;
185
192
  var interval = this._interval;
186
193
 
187
- if (!fixMin) {
194
+ if (!opt.fixMin) {
188
195
  extent[0] = roundNumber(Math.floor(extent[0] / interval) * interval);
189
196
  }
190
- if (!fixMax) {
197
+ if (!opt.fixMax) {
191
198
  extent[1] = roundNumber(Math.ceil(extent[1] / interval) * interval);
192
199
  }
193
200
  }
package/src/scale/Log.js CHANGED
@@ -158,16 +158,14 @@ define(function (require) {
158
158
 
159
159
  /**
160
160
  * Nice extent.
161
- * @param {number} [approxTickNum = 10] Given approx tick number
162
- * @param {boolean} [fixMin=false]
163
- * @param {boolean} [fixMax=false]
161
+ * @override
164
162
  */
165
- niceExtent: function (splitNumber, fixMin, fixMax) {
166
- intervalScaleProto.niceExtent.call(this, splitNumber, fixMin, fixMax);
163
+ niceExtent: function (opt) {
164
+ intervalScaleProto.niceExtent.call(this, opt);
167
165
 
168
166
  var originalScale = this._originalScale;
169
- originalScale.__fixMin = fixMin;
170
- originalScale.__fixMax = fixMax;
167
+ originalScale.__fixMin = opt.fixMin;
168
+ originalScale.__fixMax = opt.fixMax;
171
169
  }
172
170
 
173
171
  });
package/src/scale/Time.js CHANGED
@@ -52,7 +52,9 @@ define(function (require) {
52
52
  var TimeScale = IntervalScale.extend({
53
53
  type: 'time',
54
54
 
55
- // Overwrite
55
+ /**
56
+ * @override
57
+ */
56
58
  getLabel: function (val) {
57
59
  var stepLvl = this._stepLvl;
58
60
 
@@ -61,8 +63,10 @@ define(function (require) {
61
63
  return formatUtil.formatTime(stepLvl[0], date, this.getSetting('useUTC'));
62
64
  },
63
65
 
64
- // Overwrite
65
- niceExtent: function (approxTickNum, fixMin, fixMax) {
66
+ /**
67
+ * @override
68
+ */
69
+ niceExtent: function (opt) {
66
70
  var extent = this._extent;
67
71
  // If extent start and end are same, expand them
68
72
  if (extent[0] === extent[1]) {
@@ -77,20 +81,22 @@ define(function (require) {
77
81
  extent[0] = extent[1] - ONE_DAY;
78
82
  }
79
83
 
80
- this.niceTicks(approxTickNum);
84
+ this.niceTicks(opt.splitNumber);
81
85
 
82
86
  // var extent = this._extent;
83
87
  var interval = this._interval;
84
88
 
85
- if (!fixMin) {
89
+ if (!opt.fixMin) {
86
90
  extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
87
91
  }
88
- if (!fixMax) {
92
+ if (!opt.fixMax) {
89
93
  extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
90
94
  }
91
95
  },
92
96
 
93
- // Overwrite
97
+ /**
98
+ * @override
99
+ */
94
100
  niceTicks: function (approxTickNum) {
95
101
  var timezoneOffset = this.getSetting('useUTC')
96
102
  ? 0 : numberUtil.getTimezoneOffset() * 60 * 1000;
@@ -13,13 +13,17 @@ define(function (require) {
13
13
  * @param {Array.<number>} extent Both extent[0] and extent[1] should be valid number.
14
14
  * Should be extent[0] < extent[1].
15
15
  * @param {number} splitNumber splitNumber should be >= 1.
16
+ * @param {number} [minInterval]
16
17
  * @return {Object} {interval, intervalPrecision, niceTickExtent}
17
18
  */
18
- helper.intervalScaleNiceTicks = function (extent, splitNumber) {
19
+ helper.intervalScaleNiceTicks = function (extent, splitNumber, minInterval) {
19
20
  var result = {};
20
21
  var span = extent[1] - extent[0];
21
22
 
22
23
  var interval = result.interval = numberUtil.nice(span / splitNumber, true);
24
+ if (minInterval != null && interval < minInterval) {
25
+ interval = result.interval = minInterval;
26
+ }
23
27
  // Tow more digital for tick.
24
28
  var precision = result.intervalPrecision = numberUtil.getPrecisionSafe(interval) + 2;
25
29
  // Niced extent inside original extent
@@ -129,6 +129,18 @@ define(function (require) {
129
129
  return tpl;
130
130
  };
131
131
 
132
+ /**
133
+ * @param {string} color
134
+ * @param {string} [extraCssText]
135
+ * @return {string}
136
+ */
137
+ formatUtil.getTooltipMarker = function (color, extraCssText) {
138
+ return color
139
+ ? '<span style="display:inline-block;margin-right:5px;'
140
+ + 'border-radius:10px;width:9px;height:9px;background-color:'
141
+ + formatUtil.encodeHTML(color) + ';' + (extraCssText || '') + '"></span>'
142
+ : '';
143
+ };
132
144
 
133
145
  /**
134
146
  * @param {string} str