echarts 3.5.1 → 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 (261) hide show
  1. package/LICENSE +21 -18
  2. package/README.md +10 -0
  3. package/dist/echarts.common.js +11010 -9830
  4. package/dist/echarts.common.min.js +13 -13
  5. package/dist/echarts.js +13291 -10852
  6. package/dist/echarts.min.js +22 -21
  7. package/dist/echarts.simple.js +9904 -8990
  8. package/dist/echarts.simple.min.js +9 -10
  9. package/index.js +1 -0
  10. package/lib/ExtensionAPI.js +2 -4
  11. package/lib/chart/bar/BarView.js +141 -49
  12. package/lib/chart/bar/BaseBarSeries.js +2 -6
  13. package/lib/chart/bar.js +1 -0
  14. package/lib/chart/boxplot/BoxplotSeries.js +1 -1
  15. package/lib/chart/boxplot/boxplotLayout.js +23 -7
  16. package/lib/chart/candlestick/CandlestickSeries.js +3 -22
  17. package/lib/chart/candlestick/candlestickLayout.js +23 -7
  18. package/lib/chart/custom.js +442 -0
  19. package/lib/chart/funnel/funnelLayout.js +10 -3
  20. package/lib/chart/gauge/GaugeView.js +1 -1
  21. package/lib/chart/graph/GraphView.js +15 -9
  22. package/lib/chart/graph/categoryVisual.js +3 -2
  23. package/lib/chart/heatmap/HeatmapLayer.js +1 -1
  24. package/lib/chart/heatmap/HeatmapView.js +75 -73
  25. package/lib/chart/helper/Symbol.js +8 -31
  26. package/lib/chart/helper/createListFromArray.js +15 -10
  27. package/lib/chart/helper/labelHelper.js +48 -0
  28. package/lib/chart/helper/whiskerBoxCommon.js +25 -44
  29. package/lib/chart/map/mapDataStatistic.js +9 -8
  30. package/lib/chart/parallel/ParallelSeries.js +2 -0
  31. package/lib/chart/parallel/ParallelView.js +13 -12
  32. package/lib/chart/parallel/parallelVisual.js +9 -1
  33. package/lib/chart/pie/pieLayout.js +25 -17
  34. package/lib/chart/radar/RadarSeries.js +1 -1
  35. package/lib/chart/sankey/sankeyLayout.js +1 -1
  36. package/lib/chart/scatter/ScatterSeries.js +2 -3
  37. package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
  38. package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
  39. package/lib/chart/treemap/TreemapSeries.js +3 -3
  40. package/lib/chart/treemap/TreemapView.js +1 -1
  41. package/lib/chart/treemap/treemapLayout.js +6 -1
  42. package/lib/component/axis/AxisBuilder.js +53 -34
  43. package/lib/component/axis/ParallelAxisView.js +45 -37
  44. package/lib/component/axisPointer/AxisPointerModel.js +1 -1
  45. package/lib/component/axisPointer/BaseAxisPointer.js +20 -15
  46. package/lib/component/axisPointer/CartesianAxisPointer.js +9 -6
  47. package/lib/component/axisPointer/PolarAxisPointer.js +10 -8
  48. package/lib/component/axisPointer/SingleAxisPointer.js +11 -7
  49. package/lib/component/axisPointer/axisTrigger.js +87 -72
  50. package/lib/component/axisPointer/viewHelper.js +6 -3
  51. package/lib/component/axisPointer.js +2 -2
  52. package/lib/component/brush/BrushModel.js +6 -4
  53. package/lib/component/brush/BrushView.js +1 -1
  54. package/lib/component/brush/visualEncoding.js +6 -4
  55. package/lib/component/calendar/CalendarView.js +5 -5
  56. package/lib/component/dataZoom/AxisProxy.js +76 -13
  57. package/lib/component/dataZoom/DataZoomModel.js +21 -5
  58. package/lib/component/dataZoom/InsideZoomModel.js +4 -1
  59. package/lib/component/dataZoom/InsideZoomView.js +17 -27
  60. package/lib/component/dataZoom/SliderZoomView.js +63 -26
  61. package/lib/component/dataZoom/roams.js +9 -4
  62. package/lib/component/graphic.js +13 -12
  63. package/lib/component/helper/BrushController.js +75 -114
  64. package/lib/component/helper/BrushTargetManager.js +16 -8
  65. package/lib/component/helper/MapDraw.js +25 -11
  66. package/lib/component/helper/RoamController.js +111 -139
  67. package/lib/component/helper/brushHelper.js +25 -213
  68. package/lib/component/helper/cursorHelper.js +21 -0
  69. package/lib/component/helper/roamHelper.js +54 -0
  70. package/lib/component/helper/selectableMixin.js +7 -7
  71. package/lib/component/helper/sliderMove.js +66 -37
  72. package/lib/component/legend/LegendView.js +6 -6
  73. package/lib/component/legend/legendAction.js +1 -1
  74. package/lib/component/marker/MarkAreaView.js +3 -6
  75. package/lib/component/marker/MarkLineView.js +3 -5
  76. package/lib/component/marker/MarkPointView.js +3 -5
  77. package/lib/component/marker/MarkerView.js +10 -12
  78. package/lib/component/marker/markerHelper.js +1 -1
  79. package/lib/component/parallel.js +94 -29
  80. package/lib/component/polar.js +5 -0
  81. package/lib/component/timeline/SliderTimelineView.js +1 -1
  82. package/lib/component/toolbox/feature/Brush.js +7 -0
  83. package/lib/component/toolbox/feature/DataZoom.js +17 -4
  84. package/lib/component/tooltip/TooltipView.js +92 -20
  85. package/lib/component/visualMap/ContinuousView.js +6 -4
  86. package/lib/coord/Axis.js +34 -2
  87. package/lib/coord/axisDefault.js +4 -1
  88. package/lib/coord/axisHelper.js +32 -26
  89. package/lib/coord/axisModelCommonMixin.js +1 -1
  90. package/lib/coord/calendar/Calendar.js +14 -17
  91. package/lib/coord/calendar/prepareCustom.js +31 -0
  92. package/lib/coord/cartesian/Axis2D.js +0 -12
  93. package/lib/coord/cartesian/Cartesian2D.js +1 -0
  94. package/lib/coord/cartesian/Grid.js +5 -2
  95. package/lib/coord/cartesian/prepareCustom.js +36 -0
  96. package/lib/coord/geo/Geo.js +9 -14
  97. package/lib/coord/geo/GeoModel.js +5 -5
  98. package/lib/coord/geo/geoCreator.js +3 -3
  99. package/lib/coord/geo/parseGeoJson.js +11 -4
  100. package/lib/coord/geo/prepareCustom.js +36 -0
  101. package/lib/coord/parallel/Parallel.js +225 -101
  102. package/lib/coord/parallel/ParallelModel.js +7 -1
  103. package/lib/coord/polar/Polar.js +2 -1
  104. package/lib/coord/polar/prepareCustom.js +53 -0
  105. package/lib/coord/single/Single.js +9 -8
  106. package/lib/coord/single/SingleAxis.js +0 -27
  107. package/lib/coord/single/prepareCustom.js +33 -0
  108. package/lib/data/DataDiffer.js +2 -1
  109. package/lib/data/Graph.js +11 -7
  110. package/lib/data/List.js +59 -20
  111. package/lib/data/helper/completeDimensions.js +184 -23
  112. package/lib/echarts.js +68 -36
  113. package/lib/helper.js +1 -8
  114. package/lib/layout/barGrid.js +91 -19
  115. package/lib/layout/barPolar.js +286 -0
  116. package/lib/layout/points.js +22 -16
  117. package/lib/model/Global.js +34 -31
  118. package/lib/model/Series.js +41 -29
  119. package/lib/model/globalDefault.js +4 -1
  120. package/lib/model/mixin/colorPalette.js +2 -1
  121. package/lib/model/mixin/textStyle.js +7 -13
  122. package/lib/scale/Interval.js +46 -76
  123. package/lib/scale/Log.js +5 -7
  124. package/lib/scale/Scale.js +10 -1
  125. package/lib/scale/Time.js +34 -12
  126. package/lib/scale/helper.js +93 -0
  127. package/lib/util/format.js +20 -9
  128. package/lib/util/graphic.js +70 -8
  129. package/lib/util/layout.js +7 -3
  130. package/lib/util/model.js +63 -7
  131. package/lib/util/number.js +59 -19
  132. package/lib/util/throttle.js +14 -3
  133. package/map/js/world.js +1 -1
  134. package/map/json/world.json +1 -1
  135. package/package.json +3 -3
  136. package/src/ExtensionAPI.js +2 -4
  137. package/src/chart/bar/BarView.js +141 -49
  138. package/src/chart/bar/BaseBarSeries.js +2 -6
  139. package/src/chart/bar.js +1 -0
  140. package/src/chart/boxplot/BoxplotSeries.js +1 -1
  141. package/src/chart/boxplot/boxplotLayout.js +23 -7
  142. package/src/chart/candlestick/CandlestickSeries.js +3 -22
  143. package/src/chart/candlestick/candlestickLayout.js +23 -7
  144. package/src/chart/custom.js +442 -0
  145. package/src/chart/funnel/funnelLayout.js +10 -4
  146. package/src/chart/gauge/GaugeView.js +1 -1
  147. package/src/chart/graph/GraphView.js +15 -9
  148. package/src/chart/graph/categoryVisual.js +3 -2
  149. package/src/chart/heatmap/HeatmapLayer.js +1 -1
  150. package/src/chart/heatmap/HeatmapView.js +75 -73
  151. package/src/chart/helper/Symbol.js +8 -31
  152. package/src/chart/helper/createListFromArray.js +15 -10
  153. package/src/chart/helper/labelHelper.js +49 -0
  154. package/src/chart/helper/whiskerBoxCommon.js +25 -44
  155. package/src/chart/map/mapDataStatistic.js +9 -8
  156. package/src/chart/parallel/ParallelSeries.js +2 -0
  157. package/src/chart/parallel/ParallelView.js +13 -12
  158. package/src/chart/parallel/parallelVisual.js +9 -1
  159. package/src/chart/pie/pieLayout.js +25 -17
  160. package/src/chart/radar/RadarSeries.js +1 -1
  161. package/src/chart/sankey/sankeyLayout.js +1 -1
  162. package/src/chart/scatter/ScatterSeries.js +2 -3
  163. package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
  164. package/src/chart/themeRiver/themeRiverVisual.js +1 -1
  165. package/src/chart/treemap/TreemapSeries.js +3 -3
  166. package/src/chart/treemap/TreemapView.js +1 -1
  167. package/src/chart/treemap/treemapLayout.js +6 -1
  168. package/src/component/axis/AxisBuilder.js +53 -34
  169. package/src/component/axis/ParallelAxisView.js +45 -37
  170. package/src/component/axisPointer/AxisPointerModel.js +1 -1
  171. package/src/component/axisPointer/BaseAxisPointer.js +20 -15
  172. package/src/component/axisPointer/CartesianAxisPointer.js +9 -6
  173. package/src/component/axisPointer/PolarAxisPointer.js +10 -8
  174. package/src/component/axisPointer/SingleAxisPointer.js +11 -7
  175. package/src/component/axisPointer/axisTrigger.js +87 -72
  176. package/src/component/axisPointer/viewHelper.js +6 -3
  177. package/src/component/axisPointer.js +2 -2
  178. package/src/component/brush/BrushModel.js +6 -4
  179. package/src/component/brush/BrushView.js +1 -1
  180. package/src/component/brush/visualEncoding.js +6 -4
  181. package/src/component/calendar/CalendarView.js +5 -5
  182. package/src/component/dataZoom/AxisProxy.js +76 -13
  183. package/src/component/dataZoom/DataZoomModel.js +21 -5
  184. package/src/component/dataZoom/InsideZoomModel.js +4 -1
  185. package/src/component/dataZoom/InsideZoomView.js +17 -27
  186. package/src/component/dataZoom/SliderZoomView.js +63 -26
  187. package/src/component/dataZoom/roams.js +9 -4
  188. package/src/component/graphic.js +13 -12
  189. package/src/component/helper/BrushController.js +75 -114
  190. package/src/component/helper/BrushTargetManager.js +16 -8
  191. package/src/component/helper/MapDraw.js +25 -11
  192. package/src/component/helper/RoamController.js +111 -139
  193. package/src/component/helper/brushHelper.js +41 -0
  194. package/src/component/helper/cursorHelper.js +22 -0
  195. package/src/component/helper/roamHelper.js +55 -0
  196. package/src/component/helper/selectableMixin.js +7 -7
  197. package/src/component/helper/sliderMove.js +66 -37
  198. package/src/component/legend/LegendView.js +6 -6
  199. package/src/component/legend/legendAction.js +1 -1
  200. package/src/component/marker/MarkAreaView.js +3 -6
  201. package/src/component/marker/MarkLineView.js +3 -5
  202. package/src/component/marker/MarkPointView.js +3 -5
  203. package/src/component/marker/MarkerView.js +10 -12
  204. package/src/component/marker/markerHelper.js +1 -1
  205. package/src/component/parallel.js +94 -29
  206. package/src/component/polar.js +5 -0
  207. package/src/component/timeline/SliderTimelineView.js +1 -1
  208. package/src/component/toolbox/feature/Brush.js +7 -0
  209. package/src/component/toolbox/feature/DataZoom.js +17 -4
  210. package/src/component/tooltip/TooltipView.js +92 -20
  211. package/src/component/visualMap/ContinuousView.js +6 -4
  212. package/src/coord/Axis.js +34 -2
  213. package/src/coord/axisDefault.js +4 -1
  214. package/src/coord/axisHelper.js +32 -26
  215. package/src/coord/axisModelCommonMixin.js +1 -1
  216. package/src/coord/calendar/Calendar.js +14 -17
  217. package/src/coord/calendar/prepareCustom.js +32 -0
  218. package/src/coord/cartesian/Axis2D.js +0 -12
  219. package/src/coord/cartesian/Cartesian2D.js +1 -0
  220. package/src/coord/cartesian/Grid.js +5 -2
  221. package/src/coord/cartesian/prepareCustom.js +37 -0
  222. package/src/coord/geo/Geo.js +9 -14
  223. package/src/coord/geo/GeoModel.js +5 -5
  224. package/src/coord/geo/geoCreator.js +3 -3
  225. package/src/coord/geo/parseGeoJson.js +11 -4
  226. package/src/coord/geo/prepareCustom.js +37 -0
  227. package/src/coord/parallel/Parallel.js +225 -101
  228. package/src/coord/parallel/ParallelModel.js +7 -1
  229. package/src/coord/polar/Polar.js +2 -1
  230. package/src/coord/polar/prepareCustom.js +54 -0
  231. package/src/coord/single/Single.js +9 -8
  232. package/src/coord/single/SingleAxis.js +0 -27
  233. package/src/coord/single/prepareCustom.js +34 -0
  234. package/src/data/DataDiffer.js +2 -1
  235. package/src/data/Graph.js +11 -7
  236. package/src/data/List.js +59 -20
  237. package/src/data/helper/completeDimensions.js +184 -23
  238. package/src/echarts.js +68 -36
  239. package/src/helper.js +1 -8
  240. package/src/layout/barGrid.js +91 -19
  241. package/src/layout/barPolar.js +287 -0
  242. package/src/layout/points.js +22 -16
  243. package/src/model/Global.js +34 -31
  244. package/src/model/Series.js +41 -29
  245. package/src/model/globalDefault.js +4 -1
  246. package/src/model/mixin/colorPalette.js +2 -1
  247. package/src/model/mixin/textStyle.js +7 -13
  248. package/src/scale/Interval.js +46 -76
  249. package/src/scale/Log.js +5 -7
  250. package/src/scale/Scale.js +10 -1
  251. package/src/scale/Time.js +34 -12
  252. package/src/scale/helper.js +94 -0
  253. package/src/util/format.js +20 -9
  254. package/src/util/graphic.js +70 -8
  255. package/src/util/layout.js +7 -3
  256. package/src/util/model.js +63 -7
  257. package/src/util/number.js +59 -19
  258. package/src/util/throttle.js +14 -3
  259. package/src/coord/cartesian/axisLabelInterval.js +0 -26
  260. package/theme/default.js +0 -23
  261. package/theme/halloween.js +0 -528
@@ -4,11 +4,16 @@
4
4
  var zrUtil = require('zrender/lib/core/util');
5
5
 
6
6
  var pathTool = require('zrender/lib/tool/path');
7
- var round = Math.round;
8
7
  var Path = require('zrender/lib/graphic/Path');
9
8
  var colorTool = require('zrender/lib/tool/color');
10
9
  var matrix = require('zrender/lib/core/matrix');
11
10
  var vector = require('zrender/lib/core/vector');
11
+ var Transformable = require('zrender/lib/mixin/Transformable');
12
+ var BoundingRect = require('zrender/lib/core/BoundingRect');
13
+
14
+ var round = Math.round;
15
+ var mathMax = Math.max;
16
+ var mathMin = Math.min;
12
17
 
13
18
  var graphic = {};
14
19
 
@@ -42,7 +47,7 @@
42
47
 
43
48
  graphic.RadialGradient = require('zrender/lib/graphic/RadialGradient');
44
49
 
45
- graphic.BoundingRect = require('zrender/lib/core/BoundingRect');
50
+ graphic.BoundingRect = BoundingRect;
46
51
 
47
52
  /**
48
53
  * Extend shape with parameters
@@ -404,6 +409,17 @@
404
409
  });
405
410
  };
406
411
 
412
+ graphic.getFont = function (opt, ecModel) {
413
+ var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
414
+ return [
415
+ // FIXME in node-canvas fontWeight is before fontStyle
416
+ opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
417
+ opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '',
418
+ (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px',
419
+ opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'
420
+ ].join(' ');
421
+ };
422
+
407
423
  function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
408
424
  if (typeof dataIndex === 'function') {
409
425
  cb = dataIndex;
@@ -433,9 +449,10 @@
433
449
 
434
450
  duration > 0
435
451
  ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
436
- : (el.attr(props), cb && cb());
452
+ : (el.stopAnimation(), el.attr(props), cb && cb());
437
453
  }
438
454
  else {
455
+ el.stopAnimation();
439
456
  el.attr(props);
440
457
  cb && cb();
441
458
  }
@@ -493,16 +510,22 @@
493
510
 
494
511
  /**
495
512
  * Apply transform to an vertex.
496
- * @param {Array.<number>} vertex [x, y]
497
- * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
513
+ * @param {Array.<number>} target [x, y]
514
+ * @param {Array.<number>|TypedArray.<number>|Object} transform Can be:
515
+ * + Transform matrix: like [1, 0, 0, 1, 0, 0]
516
+ * + {position, rotation, scale}, the same as `zrender/Transformable`.
498
517
  * @param {boolean=} invert Whether use invert matrix.
499
518
  * @return {Array.<number>} [x, y]
500
519
  */
501
- graphic.applyTransform = function (vertex, transform, invert) {
520
+ graphic.applyTransform = function (target, transform, invert) {
521
+ if (transform && !zrUtil.isArrayLike(transform)) {
522
+ transform = Transformable.getLocalTransform(transform);
523
+ }
524
+
502
525
  if (invert) {
503
526
  transform = matrix.invert([], transform);
504
527
  }
505
- return vector.applyTransform([], vertex, transform);
528
+ return vector.applyTransform([], target, transform);
506
529
  };
507
530
 
508
531
  /**
@@ -532,7 +555,8 @@
532
555
  };
533
556
 
534
557
  /**
535
- * Apply group transition animation from g1 to g2
558
+ * Apply group transition animation from g1 to g2.
559
+ * If no animatableModel, no animation.
536
560
  */
537
561
  graphic.groupTransition = function (g1, g2, animatableModel, cb) {
538
562
  if (!g1 || !g2) {
@@ -577,5 +601,43 @@
577
601
  });
578
602
  };
579
603
 
604
+ /**
605
+ * @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...]
606
+ * @param {Object} rect {x, y, width, height}
607
+ * @return {Array.<Array.<number>>} A new clipped points.
608
+ */
609
+ graphic.clipPointsByRect = function (points, rect) {
610
+ return zrUtil.map(points, function (point) {
611
+ var x = point[0];
612
+ x = mathMax(x, rect.x);
613
+ x = mathMin(x, rect.x + rect.width);
614
+ var y = point[1];
615
+ y = mathMax(y, rect.y);
616
+ y = mathMin(y, rect.y + rect.height);
617
+ return [x, y];
618
+ });
619
+ };
620
+
621
+ /**
622
+ * @param {Object} targetRect {x, y, width, height}
623
+ * @param {Object} rect {x, y, width, height}
624
+ * @return {Object} A new clipped rect. If rect size are negative, return undefined.
625
+ */
626
+ graphic.clipRectByRect = function (targetRect, rect) {
627
+ var x = mathMax(targetRect.x, rect.x);
628
+ var x2 = mathMin(targetRect.x + targetRect.width, rect.x + rect.width);
629
+ var y = mathMax(targetRect.y, rect.y);
630
+ var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height);
631
+
632
+ if (x2 >= x && y2 >= y) {
633
+ return {
634
+ x: x,
635
+ y: y,
636
+ width: x2 - x,
637
+ height: y2 - y
638
+ };
639
+ }
640
+ };
641
+
580
642
  module.exports = graphic;
581
643
 
@@ -405,9 +405,13 @@
405
405
  });
406
406
 
407
407
  if (ignoreSize[hvIdx]) {
408
- // Only one of left/height is premitted to exist.
409
- hasValue(newOption, names[2]) && (merged[names[1]] = null);
410
- hasValue(newOption, names[1]) && (merged[names[2]] = null);
408
+ // Only one of left/right is premitted to exist.
409
+ if (hasValue(newOption, names[1])) {
410
+ merged[names[2]] = null;
411
+ }
412
+ else if (hasValue(newOption, names[2])) {
413
+ merged[names[1]] = null;
414
+ }
411
415
  return merged;
412
416
  }
413
417
 
package/lib/util/model.js CHANGED
@@ -145,6 +145,7 @@
145
145
  var rawDataIndex = data.getRawIndex(dataIndex);
146
146
  var name = data.getName(dataIndex, true);
147
147
  var itemOpt = data.getRawDataItem(dataIndex);
148
+ var color = data.getItemVisual(dataIndex, 'color');
148
149
 
149
150
  return {
150
151
  componentType: this.mainType,
@@ -158,7 +159,8 @@
158
159
  data: itemOpt,
159
160
  dataType: dataType,
160
161
  value: rawValue,
161
- color: data.getItemVisual(dataIndex, 'color'),
162
+ color: color,
163
+ marker: formatUtil.getTooltipMarker(color),
162
164
 
163
165
  // Param name list for mapping `a`, `b`, `c`, `d`, `e`
164
166
  $vars: ['seriesName', 'name', 'value']
@@ -333,22 +335,22 @@
333
335
  // to specify multi components (like series) by one name.
334
336
 
335
337
  // Ensure that each id is distinct.
336
- var idMap = {};
338
+ var idMap = zrUtil.createHashMap();
337
339
 
338
340
  each(mapResult, function (item, index) {
339
341
  var existCpt = item.exist;
340
- existCpt && (idMap[existCpt.id] = item);
342
+ existCpt && idMap.set(existCpt.id, item);
341
343
  });
342
344
 
343
345
  each(mapResult, function (item, index) {
344
346
  var opt = item.option;
345
347
 
346
348
  zrUtil.assert(
347
- !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item,
349
+ !opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item,
348
350
  'id duplicates: ' + (opt && opt.id)
349
351
  );
350
352
 
351
- opt && opt.id != null && (idMap[opt.id] = item);
353
+ opt && opt.id != null && idMap.set(opt.id, item);
352
354
  !item.keyInfo && (item.keyInfo = {});
353
355
  });
354
356
 
@@ -388,10 +390,10 @@
388
390
  do {
389
391
  keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
390
392
  }
391
- while (idMap[keyInfo.id]);
393
+ while (idMap.get(keyInfo.id));
392
394
  }
393
395
 
394
- idMap[keyInfo.id] = item;
396
+ idMap.set(keyInfo.id, item);
395
397
  });
396
398
  };
397
399
 
@@ -597,6 +599,60 @@
597
599
  return result;
598
600
  };
599
601
 
602
+ /**
603
+ * @see {module:echarts/data/helper/completeDimensions}
604
+ * @param {module:echarts/data/List} data
605
+ * @param {string|number} dataDim
606
+ * @return {string}
607
+ */
608
+ modelUtil.dataDimToCoordDim = function (data, dataDim) {
609
+ var dimensions = data.dimensions;
610
+ dataDim = data.getDimension(dataDim);
611
+ for (var i = 0; i < dimensions.length; i++) {
612
+ var dimItem = data.getDimensionInfo(dimensions[i]);
613
+ if (dimItem.name === dataDim) {
614
+ return dimItem.coordDim;
615
+ }
616
+ }
617
+ };
618
+
619
+ /**
620
+ * @see {module:echarts/data/helper/completeDimensions}
621
+ * @param {module:echarts/data/List} data
622
+ * @param {string} coordDim
623
+ * @return {Array.<string>} data dimensions on the coordDim.
624
+ */
625
+ modelUtil.coordDimToDataDim = function (data, coordDim) {
626
+ var dataDim = [];
627
+ each(data.dimensions, function (dimName) {
628
+ var dimItem = data.getDimensionInfo(dimName);
629
+ if (dimItem.coordDim === coordDim) {
630
+ dataDim[dimItem.coordDimIndex] = dimItem.name;
631
+ }
632
+ });
633
+ return dataDim;
634
+ };
635
+
636
+ /**
637
+ * @see {module:echarts/data/helper/completeDimensions}
638
+ * @param {module:echarts/data/List} data
639
+ * @param {string} otherDim Can be `otherDims`
640
+ * like 'label' or 'tooltip'.
641
+ * @return {Array.<string>} data dimensions on the otherDim.
642
+ */
643
+ modelUtil.otherDimToDataDim = function (data, otherDim) {
644
+ var dataDim = [];
645
+ each(data.dimensions, function (dimName) {
646
+ var dimItem = data.getDimensionInfo(dimName);
647
+ var otherDims = dimItem.otherDims;
648
+ var dimIndex = otherDims[otherDim];
649
+ if (dimIndex != null && dimIndex !== false) {
650
+ dataDim[dimIndex] = dimItem.name;
651
+ }
652
+ });
653
+ return dataDim;
654
+ };
655
+
600
656
  function has(obj, prop) {
601
657
  return obj && obj.hasOwnProperty(prop);
602
658
  }
@@ -102,7 +102,9 @@
102
102
  };
103
103
 
104
104
  /**
105
- * Fix rounding error of float numbers
105
+ * (1) Fix rounding error of float numbers.
106
+ * (2) Support return string to avoid scientific notation like '3.5e-7'.
107
+ *
106
108
  * @param {number} x
107
109
  * @param {number} [precision]
108
110
  * @param {boolean} [returnStr]
@@ -147,17 +149,28 @@
147
149
  return count;
148
150
  };
149
151
 
152
+ /**
153
+ * @param {string|number} val
154
+ * @return {number}
155
+ */
150
156
  number.getPrecisionSafe = function (val) {
151
157
  var str = val.toString();
152
- var dotIndex = str.indexOf('.');
153
- if (dotIndex < 0) {
154
- return 0;
158
+
159
+ // Consider scientific notation: '3.4e-12' '3.4e+12'
160
+ var eIndex = str.indexOf('e');
161
+ if (eIndex > 0) {
162
+ var precision = +str.slice(eIndex + 1);
163
+ return precision < 0 ? -precision : 0;
164
+ }
165
+ else {
166
+ var dotIndex = str.indexOf('.');
167
+ return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
155
168
  }
156
- return str.length - 1 - dotIndex;
157
169
  };
158
170
 
159
171
  /**
160
172
  * Minimal dicernible data precisioin according to a single pixel.
173
+ *
161
174
  * @param {Array.<number>} dataExtent
162
175
  * @param {Array.<number>} pixelExtent
163
176
  * @return {number} precision
@@ -193,8 +206,14 @@
193
206
  return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
194
207
  };
195
208
 
196
- var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(?:Z|([\+\-]\d\d):?\d\d)?)?)?)?)?$/; // jshint ignore:line
197
- var TIMEZONE_OFFSET = (new Date()).getTimezoneOffset();
209
+ var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
210
+
211
+ /**
212
+ * @return {number} in minutes
213
+ */
214
+ number.getTimezoneOffset = function () {
215
+ return (new Date()).getTimezoneOffset();
216
+ };
198
217
 
199
218
  /**
200
219
  * @param {string|Date|number} value These values can be accepted:
@@ -203,9 +222,9 @@
203
222
  * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
204
223
  * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
205
224
  * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
206
- * all of which will be treated as they reperent a time in UTC
207
- * if time zone is not specified.
208
- * + Or other string format, including:
225
+ * all of which will be treated as local time if time zone is not specified
226
+ * (see <https://momentjs.com/>).
227
+ * + Or other string format, including (all of which will be treated as loacal time):
209
228
  * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
210
229
  * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
211
230
  * + a timestamp, which represent a time in UTC.
@@ -228,6 +247,13 @@
228
247
  return new Date(NaN);
229
248
  }
230
249
 
250
+ var timezoneOffset = number.getTimezoneOffset();
251
+ var timeOffset = !match[8]
252
+ ? 0
253
+ : match[8].toUpperCase() === 'Z'
254
+ ? timezoneOffset
255
+ : +match[8].slice(0, 3) * 60 + timezoneOffset;
256
+
231
257
  // match[n] can only be string or undefined.
232
258
  // But take care of '12' + 1 => '121'.
233
259
  return new Date(
@@ -235,7 +261,7 @@
235
261
  +(match[2] || 1) - 1,
236
262
  +match[3] || 1,
237
263
  +match[4] || 0,
238
- +(match[5] || 0) - (match[8] || 0) * 60 - TIMEZONE_OFFSET,
264
+ +(match[5] || 0) - timeOffset,
239
265
  +match[6] || 0,
240
266
  +match[7] || 0
241
267
  );
@@ -249,24 +275,33 @@
249
275
 
250
276
  /**
251
277
  * Quantity of a number. e.g. 0.1, 1, 10, 100
278
+ *
252
279
  * @param {number} val
253
280
  * @return {number}
254
281
  */
255
282
  number.quantity = function (val) {
256
- return Math.pow(10, Math.floor(Math.log(val) / Math.LN10));
283
+ return Math.pow(10, quantityExponent(val));
257
284
  };
258
285
 
259
- // "Nice Numbers for Graph Labels" of Graphic Gems
286
+ function quantityExponent(val) {
287
+ return Math.floor(Math.log(val) / Math.LN10);
288
+ }
289
+
260
290
  /**
261
- * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false
262
- * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
263
- * @param {number} val
291
+ * find a “nice” number approximately equal to x. Round the number if round = true,
292
+ * take ceiling if round = false. The primary observation is that the “nicest”
293
+ * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
294
+ *
295
+ * See "Nice Numbers for Graph Labels" of Graphic Gems.
296
+ *
297
+ * @param {number} val Non-negative value.
264
298
  * @param {boolean} round
265
299
  * @return {number}
266
300
  */
267
301
  number.nice = function (val, round) {
268
- var exp10 = number.quantity(val);
269
- var f = val / exp10; // between 1 and 10
302
+ var exponent = quantityExponent(val);
303
+ var exp10 = Math.pow(10, exponent);
304
+ var f = val / exp10; // 1 <= f < 10
270
305
  var nf;
271
306
  if (round) {
272
307
  if (f < 1.5) { nf = 1; }
@@ -282,7 +317,11 @@
282
317
  else if (f < 5) { nf = 5; }
283
318
  else { nf = 10; }
284
319
  }
285
- return nf * exp10;
320
+ val = nf * exp10;
321
+
322
+ // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
323
+ // 20 is the uppper bound of toFixed.
324
+ return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
286
325
  };
287
326
 
288
327
  /**
@@ -353,6 +392,7 @@
353
392
  * parseFloat NaNs numeric-cast false positives (null|true|false|"")
354
393
  * ...but misinterprets leading-number strings, particularly hex literals ("0x...")
355
394
  * subtraction forces infinities to NaN
395
+ *
356
396
  * @param {*} v
357
397
  * @return {boolean}
358
398
  */
@@ -24,6 +24,7 @@
24
24
  var diff;
25
25
  var scope;
26
26
  var args;
27
+ var debounceNextCall;
27
28
 
28
29
  delay = delay || 0;
29
30
 
@@ -37,12 +38,15 @@
37
38
  currCall = (new Date()).getTime();
38
39
  scope = this;
39
40
  args = arguments;
40
- diff = currCall - (debounce ? lastCall : lastExec) - delay;
41
+ var thisDelay = debounceNextCall || delay;
42
+ var thisDebounce = debounceNextCall || debounce;
43
+ debounceNextCall = null;
44
+ diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;
41
45
 
42
46
  clearTimeout(timer);
43
47
 
44
- if (debounce) {
45
- timer = setTimeout(exec, delay);
48
+ if (thisDebounce) {
49
+ timer = setTimeout(exec, thisDelay);
46
50
  }
47
51
  else {
48
52
  if (diff >= 0) {
@@ -67,6 +71,13 @@
67
71
  }
68
72
  };
69
73
 
74
+ /**
75
+ * Enable debounce once.
76
+ */
77
+ cb.debounceNextCall = function (debounceDelay) {
78
+ debounceNextCall = debounceDelay;
79
+ };
80
+
70
81
  return cb;
71
82
  };
72
83