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
@@ -35,12 +35,12 @@
35
35
 
36
36
  option.regions = geoCreator.getFilledRegions(option.regions, option.map);
37
37
 
38
- this._optionModelMap = zrUtil.reduce(option.regions || [], function (obj, regionOpt) {
38
+ this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
39
39
  if (regionOpt.name) {
40
- obj[regionOpt.name] = new Model(regionOpt, self);
40
+ optionModelMap.set(regionOpt.name, new Model(regionOpt, self));
41
41
  }
42
- return obj;
43
- }, {});
42
+ return optionModelMap;
43
+ }, zrUtil.createHashMap());
44
44
 
45
45
  this.updateSelectedMap(option.regions);
46
46
  },
@@ -128,7 +128,7 @@
128
128
  * @return {module:echarts/model/Model}
129
129
  */
130
130
  getRegionModel: function (name) {
131
- return this._optionModelMap[name] || new Model(null, this, this.ecModel);
131
+ return this._optionModelMap.get(name) || new Model(null, this, this.ecModel);
132
132
  },
133
133
 
134
134
  /**
@@ -260,15 +260,15 @@
260
260
  return originRegionArr;
261
261
  }
262
262
 
263
- var dataNameMap = {};
263
+ var dataNameMap = zrUtil.createHashMap();
264
264
  var features = geoJson.features;
265
265
  for (var i = 0; i < regionsArr.length; i++) {
266
- dataNameMap[regionsArr[i].name] = regionsArr[i];
266
+ dataNameMap.set(regionsArr[i].name, regionsArr[i]);
267
267
  }
268
268
 
269
269
  for (var i = 0; i < features.length; i++) {
270
270
  var name = features[i].properties.name;
271
- if (!dataNameMap[name]) {
271
+ if (!dataNameMap.get(name)) {
272
272
  regionsArr.push({
273
273
  name: name
274
274
  });
@@ -12,6 +12,11 @@
12
12
  if (!json.UTF8Encoding) {
13
13
  return json;
14
14
  }
15
+ var encodeScale = json.UTF8Scale;
16
+ if (encodeScale == null) {
17
+ encodeScale = 1024;
18
+ }
19
+
15
20
  var features = json.features;
16
21
 
17
22
  for (var f = 0; f < features.length; f++) {
@@ -26,7 +31,8 @@
26
31
  if (geometry.type === 'Polygon') {
27
32
  coordinates[c] = decodePolygon(
28
33
  coordinate,
29
- encodeOffsets[c]
34
+ encodeOffsets[c],
35
+ encodeScale
30
36
  );
31
37
  }
32
38
  else if (geometry.type === 'MultiPolygon') {
@@ -34,7 +40,8 @@
34
40
  var polygon = coordinate[c2];
35
41
  coordinate[c2] = decodePolygon(
36
42
  polygon,
37
- encodeOffsets[c][c2]
43
+ encodeOffsets[c][c2],
44
+ encodeScale
38
45
  );
39
46
  }
40
47
  }
@@ -45,7 +52,7 @@
45
52
  return json;
46
53
  }
47
54
 
48
- function decodePolygon(coordinate, encodeOffsets) {
55
+ function decodePolygon(coordinate, encodeOffsets, encodeScale) {
49
56
  var result = [];
50
57
  var prevX = encodeOffsets[0];
51
58
  var prevY = encodeOffsets[1];
@@ -63,7 +70,7 @@
63
70
  prevX = x;
64
71
  prevY = y;
65
72
  // Dequantize
66
- result.push([x / 1024, y / 1024]);
73
+ result.push([x / encodeScale, y / encodeScale]);
67
74
  }
68
75
 
69
76
  return result;
@@ -0,0 +1,36 @@
1
+
2
+
3
+ var zrUtil = require('zrender/lib/core/util');
4
+
5
+ function dataToCoordSize(dataSize, dataItem) {
6
+ dataItem = dataItem || [0, 0];
7
+ return zrUtil.map([0, 1], function (dimIdx) {
8
+ var val = dataItem[dimIdx];
9
+ var halfSize = dataSize[dimIdx] / 2;
10
+ var p1 = [];
11
+ var p2 = [];
12
+ p1[dimIdx] = val - halfSize;
13
+ p2[dimIdx] = val + halfSize;
14
+ p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
15
+ return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
16
+ }, this);
17
+ }
18
+
19
+ function prepareCustom(coordSys) {
20
+ var rect = coordSys.getBoundingRect();
21
+ return {
22
+ coordSys: {
23
+ type: 'geo',
24
+ x: rect.x,
25
+ y: rect.y,
26
+ width: rect.width,
27
+ height: rect.height
28
+ },
29
+ api: {
30
+ coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
31
+ size: zrUtil.bind(dataToCoordSize, coordSys)
32
+ }
33
+ };
34
+ }
35
+
36
+ module.exports = prepareCustom;
@@ -4,14 +4,21 @@
4
4
  */
5
5
 
6
6
 
7
- var layout = require('../../util/layout');
7
+ var layoutUtil = require('../../util/layout');
8
8
  var axisHelper = require('../../coord/axisHelper');
9
9
  var zrUtil = require('zrender/lib/core/util');
10
10
  var ParallelAxis = require('./ParallelAxis');
11
11
  var graphic = require('../../util/graphic');
12
12
  var matrix = require('zrender/lib/core/matrix');
13
+ var numberUtil = require('../../util/number');
14
+ var sliderMove = require('../../component/helper/sliderMove');
13
15
 
14
16
  var each = zrUtil.each;
17
+ var mathMin = Math.min;
18
+ var mathMax = Math.max;
19
+ var mathFloor = Math.floor;
20
+ var mathCeil = Math.ceil;
21
+ var round = numberUtil.round;
15
22
 
16
23
  var PI = Math.PI;
17
24
 
@@ -22,7 +29,7 @@
22
29
  * @type {Object.<string, module:echarts/coord/parallel/Axis>}
23
30
  * @private
24
31
  */
25
- this._axesMap = {};
32
+ this._axesMap = zrUtil.createHashMap();
26
33
 
27
34
  /**
28
35
  * key: dimension
@@ -72,23 +79,23 @@
72
79
  var axisIndex = parallelAxisIndex[idx];
73
80
  var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
74
81
 
75
- var axis = this._axesMap[dim] = new ParallelAxis(
82
+ var axis = this._axesMap.set(dim, new ParallelAxis(
76
83
  dim,
77
84
  axisHelper.createScaleByModel(axisModel),
78
85
  [0, 0],
79
86
  axisModel.get('type'),
80
87
  axisIndex
81
- );
88
+ ));
82
89
 
83
90
  var isCategory = axis.type === 'category';
84
91
  axis.onBand = isCategory && axisModel.get('boundaryGap');
85
92
  axis.inverse = axisModel.get('inverse');
86
93
 
87
- // Inject axis into axisModel
94
+ // Injection
88
95
  axisModel.axis = axis;
89
-
90
- // Inject axisModel into axis
91
96
  axis.model = axisModel;
97
+ axis.coordinateSystem = axisModel.coordinateSystem = this;
98
+
92
99
  }, this);
93
100
  },
94
101
 
@@ -101,6 +108,23 @@
101
108
  this._updateAxesFromSeries(this._model, ecModel);
102
109
  },
103
110
 
111
+ /**
112
+ * @override
113
+ */
114
+ containPoint: function (point) {
115
+ var layoutInfo = this._makeLayoutInfo();
116
+ var axisBase = layoutInfo.axisBase;
117
+ var layoutBase = layoutInfo.layoutBase;
118
+ var pixelDimIndex = layoutInfo.pixelDimIndex;
119
+ var pAxis = point[1 - pixelDimIndex];
120
+ var pLayout = point[pixelDimIndex];
121
+
122
+ return pAxis >= axisBase
123
+ && pAxis <= axisBase + layoutInfo.axisLength
124
+ && pLayout >= layoutBase
125
+ && pLayout <= layoutBase + layoutInfo.layoutLength;
126
+ },
127
+
104
128
  /**
105
129
  * Update properties from series
106
130
  * @private
@@ -115,7 +139,7 @@
115
139
  var data = seriesModel.getData();
116
140
 
117
141
  each(this.dimensions, function (dim) {
118
- var axis = this._axesMap[dim];
142
+ var axis = this._axesMap.get(dim);
119
143
  axis.scale.unionExtentFromData(data, dim);
120
144
  axisHelper.niceScaleExtent(axis.scale, axis.model);
121
145
  }, this);
@@ -128,7 +152,7 @@
128
152
  * @param {module:echarts/ExtensionAPI} api
129
153
  */
130
154
  resize: function (parallelModel, api) {
131
- this._rect = layout.getLayoutRect(
155
+ this._rect = layoutUtil.getLayoutRect(
132
156
  parallelModel.getBoxLayoutParams(),
133
157
  {
134
158
  width: api.getWidth(),
@@ -136,7 +160,7 @@
136
160
  }
137
161
  );
138
162
 
139
- this._layoutAxes(parallelModel);
163
+ this._layoutAxes();
140
164
  },
141
165
 
142
166
  /**
@@ -149,87 +173,97 @@
149
173
  /**
150
174
  * @private
151
175
  */
152
- _layoutAxes: function (parallelModel) {
176
+ _makeLayoutInfo: function () {
177
+ var parallelModel = this._model;
153
178
  var rect = this._rect;
179
+ var xy = ['x', 'y'];
180
+ var wh = ['width', 'height'];
154
181
  var layout = parallelModel.get('layout');
182
+ var pixelDimIndex = layout === 'horizontal' ? 0 : 1;
183
+ var layoutLength = rect[wh[pixelDimIndex]];
184
+ var layoutExtent = [0, layoutLength];
185
+ var axisCount = this.dimensions.length;
186
+
187
+ var axisExpandWidth = restrict(parallelModel.get('axisExpandWidth'), layoutExtent);
188
+ var axisExpandCount = restrict(parallelModel.get('axisExpandCount') || 0, [0, axisCount]);
189
+ var axisExpandable = parallelModel.get('axisExpandable')
190
+ && axisCount > 3
191
+ && axisCount > axisExpandCount
192
+ && axisExpandCount > 1
193
+ && axisExpandWidth > 0
194
+ && layoutLength > 0;
195
+
196
+ // `axisExpandWindow` is According to the coordinates of [0, axisExpandLength],
197
+ // for sake of consider the case that axisCollapseWidth is 0 (when screen is narrow),
198
+ // where collapsed axes should be overlapped.
199
+ var axisExpandWindow = parallelModel.get('axisExpandWindow');
200
+ var winSize;
201
+ if (!axisExpandWindow) {
202
+ winSize = restrict(axisExpandWidth * (axisExpandCount - 1), layoutExtent);
203
+ var axisExpandCenter = parallelModel.get('axisExpandCenter') || mathFloor(axisCount / 2);
204
+ axisExpandWindow = [axisExpandWidth * axisExpandCenter - winSize / 2];
205
+ axisExpandWindow[1] = axisExpandWindow[0] + winSize;
206
+ }
207
+ else {
208
+ winSize = restrict(axisExpandWindow[1] - axisExpandWindow[0], layoutExtent);
209
+ axisExpandWindow[1] = axisExpandWindow[0] + winSize;
210
+ }
211
+
212
+ var axisCollapseWidth = (layoutLength - winSize) / (axisCount - axisExpandCount);
213
+ // Avoid axisCollapseWidth is too small.
214
+ axisCollapseWidth < 3 && (axisCollapseWidth = 0);
215
+
216
+ // Find the first and last indices > ewin[0] and < ewin[1].
217
+ var winInnerIndices = [
218
+ mathFloor(round(axisExpandWindow[0] / axisExpandWidth, 1)) + 1,
219
+ mathCeil(round(axisExpandWindow[1] / axisExpandWidth, 1)) - 1
220
+ ];
221
+
222
+ // Pos in ec coordinates.
223
+ var axisExpandWindow0Pos = axisCollapseWidth / axisExpandWidth * axisExpandWindow[0];
224
+
225
+ return {
226
+ layout: layout,
227
+ pixelDimIndex: pixelDimIndex,
228
+ layoutBase: rect[xy[pixelDimIndex]],
229
+ layoutLength: layoutLength,
230
+ axisBase: rect[xy[1 - pixelDimIndex]],
231
+ axisLength: rect[wh[1 - pixelDimIndex]],
232
+ axisExpandable: axisExpandable,
233
+ axisExpandWidth: axisExpandWidth,
234
+ axisCollapseWidth: axisCollapseWidth,
235
+ axisExpandWindow: axisExpandWindow,
236
+ axisCount: axisCount,
237
+ winInnerIndices: winInnerIndices,
238
+ axisExpandWindow0Pos: axisExpandWindow0Pos
239
+ };
240
+ },
241
+
242
+ /**
243
+ * @private
244
+ */
245
+ _layoutAxes: function () {
246
+ var rect = this._rect;
155
247
  var axes = this._axesMap;
156
248
  var dimensions = this.dimensions;
249
+ var layoutInfo = this._makeLayoutInfo();
250
+ var layout = layoutInfo.layout;
157
251
 
158
- var size = [rect.width, rect.height];
159
- var sizeIdx = layout === 'horizontal' ? 0 : 1;
160
- var layoutLength = size[sizeIdx];
161
- var axisLength = size[1 - sizeIdx];
162
- var axisExtent = [0, axisLength];
163
-
164
- each(axes, function (axis) {
252
+ axes.each(function (axis) {
253
+ var axisExtent = [0, layoutInfo.axisLength];
165
254
  var idx = axis.inverse ? 1 : 0;
166
255
  axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
167
256
  });
168
257
 
169
- var axisExpandable = parallelModel.get('axisExpandable');
170
- var axisExpandWidth = parallelModel.get('axisExpandWidth');
171
- var axisExpandCenter = parallelModel.get('axisExpandCenter');
172
- var axisExpandCount = parallelModel.get('axisExpandCount') || 0;
173
- var axisExpandWindow;
174
-
175
- if (axisExpandCenter != null) {
176
- // Clamp
177
- var left = Math.max(0, Math.floor(axisExpandCenter - (axisExpandCount - 1) / 2));
178
- var right = left + axisExpandCount - 1;
179
- if (right >= dimensions.length) {
180
- right = dimensions.length - 1;
181
- left = Math.max(0, Math.floor(right - axisExpandCount + 1));
182
- }
183
- axisExpandWindow = [left, right];
184
- }
185
-
186
- var calcPos = (axisExpandable && axisExpandWindow && axisExpandWidth)
187
- ? function (axisIndex, layoutLength, axisCount) {
188
- var peekIntervalCount = axisExpandWindow[1] - axisExpandWindow[0];
189
- var otherWidth = (
190
- layoutLength - axisExpandWidth * peekIntervalCount
191
- ) / (axisCount - 1 - peekIntervalCount);
192
-
193
- var position;
194
-
195
- if (axisIndex < axisExpandWindow[0]) {
196
- position = (axisIndex - 1) * otherWidth;
197
- }
198
- else if (axisIndex <= axisExpandWindow[1]) {
199
- position = axisExpandWindow[0] * otherWidth
200
- + (axisIndex - axisExpandWindow[0]) * axisExpandWidth;
201
- }
202
- else if (axisIndex === axisCount - 1) {
203
- position = layoutLength;
204
- }
205
- else {
206
- position = axisExpandWindow[0] * otherWidth
207
- + peekIntervalCount * axisExpandWidth
208
- + (axisIndex - axisExpandWindow[1]) * otherWidth;
209
- }
210
-
211
- return {
212
- position: position,
213
- axisNameAvailableWidth: (
214
- axisExpandWindow[0] < axisIndex && axisIndex < axisExpandWindow[1]
215
- ) ? axisExpandWidth : otherWidth
216
- };
217
- }
218
- : function (axisIndex, layoutLength, axisCount) {
219
- var step = layoutLength / (axisCount - 1);
220
- return {
221
- position: step * axisIndex,
222
- axisNameAvailableWidth: step
223
- };
224
- };
225
-
226
258
  each(dimensions, function (dim, idx) {
227
- var posInfo = calcPos(idx, layoutLength, dimensions.length);
259
+ var posInfo = (layoutInfo.axisExpandable
260
+ ? layoutAxisWithExpand : layoutAxisWithoutExpand
261
+ )(idx, layoutInfo);
228
262
 
229
263
  var positionTable = {
230
264
  horizontal: {
231
265
  x: posInfo.position,
232
- y: axisLength
266
+ y: layoutInfo.axisLength
233
267
  },
234
268
  vertical: {
235
269
  x: 0,
@@ -262,9 +296,11 @@
262
296
  rotation: rotation,
263
297
  transform: transform,
264
298
  axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
299
+ axisLabelShow: posInfo.axisLabelShow,
300
+ nameTruncateMaxWidth: posInfo.nameTruncateMaxWidth,
265
301
  tickDirection: 1,
266
302
  labelDirection: 1,
267
- axisExpandWindow: axisExpandWindow
303
+ labelInterval: axes.get(dim).getLabelInterval()
268
304
  };
269
305
  }, this);
270
306
  },
@@ -275,7 +311,7 @@
275
311
  * @return {module:echarts/coord/parallel/ParallelAxis} [description]
276
312
  */
277
313
  getAxis: function (dim) {
278
- return this._axesMap[dim];
314
+ return this._axesMap.get(dim);
279
315
  },
280
316
 
281
317
  /**
@@ -286,7 +322,7 @@
286
322
  */
287
323
  dataToPoint: function (value, dim) {
288
324
  return this.axisCoordToPoint(
289
- this._axesMap[dim].dataToCoord(value),
325
+ this._axesMap.get(dim).dataToCoord(value),
290
326
  dim
291
327
  );
292
328
  },
@@ -301,7 +337,7 @@
301
337
  eachActiveState: function (data, callback, context) {
302
338
  var dimensions = this.dimensions;
303
339
  var axesMap = this._axesMap;
304
- var hasActiveSet = this.hasAxisbrushed();
340
+ var hasActiveSet = this.hasAxisBrushed();
305
341
 
306
342
  for (var i = 0, len = data.count(); i < len; i++) {
307
343
  var values = data.getValues(dimensions, i);
@@ -314,7 +350,7 @@
314
350
  activeState = 'active';
315
351
  for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
316
352
  var dimName = dimensions[j];
317
- var state = axesMap[dimName].model.getActiveState(values[j], j);
353
+ var state = axesMap.get(dimName).model.getActiveState(values[j], j);
318
354
 
319
355
  if (state === 'inactive') {
320
356
  activeState = 'inactive';
@@ -331,13 +367,13 @@
331
367
  * Whether has any activeSet.
332
368
  * @return {boolean}
333
369
  */
334
- hasAxisbrushed: function () {
370
+ hasAxisBrushed: function () {
335
371
  var dimensions = this.dimensions;
336
372
  var axesMap = this._axesMap;
337
373
  var hasActiveSet = false;
338
374
 
339
375
  for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
340
- if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') {
376
+ if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
341
377
  hasActiveSet = true;
342
378
  }
343
379
  }
@@ -364,28 +400,116 @@
364
400
  return zrUtil.clone(this._axesLayout[dim]);
365
401
  },
366
402
 
367
- findClosestAxisDim: function (point) {
368
- var axisDim;
369
- var minDist = Infinity;
370
-
371
- zrUtil.each(this._axesLayout, function (axisLayout, dim) {
372
- var localPoint = graphic.applyTransform(point, axisLayout.transform, true);
373
- var extent = this._axesMap[dim].getExtent();
403
+ /**
404
+ * @param {Array.<number>} point
405
+ * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.
406
+ */
407
+ getSlidedAxisExpandWindow: function (point) {
408
+ var layoutInfo = this._makeLayoutInfo();
409
+ var pixelDimIndex = layoutInfo.pixelDimIndex;
410
+ var axisExpandWindow = layoutInfo.axisExpandWindow.slice();
411
+ var winSize = axisExpandWindow[1] - axisExpandWindow[0];
412
+ var extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)];
413
+
414
+ // Out of the area of coordinate system.
415
+ if (!this.containPoint(point)) {
416
+ return {behavior: 'none', axisExpandWindow: axisExpandWindow};
417
+ }
374
418
 
375
- if (localPoint[0] < extent[0] || localPoint[0] > extent[1]) {
376
- return;
419
+ // Conver the point from global to expand coordinates.
420
+ var pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos;
421
+
422
+ // For dragging operation convenience, the window should not be
423
+ // slided when mouse is the center area of the window.
424
+ var delta;
425
+ var behavior = 'slide';
426
+ var axisCollapseWidth = layoutInfo.axisCollapseWidth;
427
+ var triggerArea = this._model.get('axisExpandSlideTriggerArea');
428
+ // But consider touch device, jump is necessary.
429
+ var useJump = triggerArea[0] != null;
430
+
431
+ if (axisCollapseWidth) {
432
+ if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {
433
+ behavior = 'jump';
434
+ delta = pointCoord - winSize * triggerArea[2];
377
435
  }
378
-
379
- var dist = Math.abs(localPoint[1]);
380
- if (dist < minDist) {
381
- minDist = dist;
382
- axisDim = dim;
436
+ else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {
437
+ behavior = 'jump';
438
+ delta = pointCoord - winSize * (1 - triggerArea[2]);
383
439
  }
384
- }, this);
440
+ else {
441
+ (delta = pointCoord - winSize * triggerArea[1]) >= 0
442
+ && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0
443
+ && (delta = 0);
444
+ }
445
+ delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;
446
+ delta
447
+ ? sliderMove(delta, axisExpandWindow, extent, 'all')
448
+ // Avoid nonsense triger on mousemove.
449
+ : (behavior = 'none');
450
+ }
451
+ // When screen is too narrow, make it visible and slidable, although it is hard to interact.
452
+ else {
453
+ var winSize = axisExpandWindow[1] - axisExpandWindow[0];
454
+ var pos = extent[1] * pointCoord / winSize;
455
+ axisExpandWindow = [mathMax(0, pos - winSize / 2)];
456
+ axisExpandWindow[1] = mathMin(extent[1], axisExpandWindow[0] + winSize);
457
+ axisExpandWindow[0] = axisExpandWindow[1] - winSize;
458
+ }
385
459
 
386
- return axisDim;
460
+ return {
461
+ axisExpandWindow: axisExpandWindow,
462
+ behavior: behavior
463
+ };
387
464
  }
388
-
389
465
  };
390
466
 
467
+ function restrict(len, extent) {
468
+ return mathMin(mathMax(len, extent[0]), extent[1]);
469
+ }
470
+
471
+ function layoutAxisWithoutExpand(axisIndex, layoutInfo) {
472
+ var step = layoutInfo.layoutLength / (layoutInfo.axisCount - 1);
473
+ return {
474
+ position: step * axisIndex,
475
+ axisNameAvailableWidth: step,
476
+ axisLabelShow: true
477
+ };
478
+ }
479
+
480
+ function layoutAxisWithExpand(axisIndex, layoutInfo) {
481
+ var layoutLength = layoutInfo.layoutLength;
482
+ var axisExpandWidth = layoutInfo.axisExpandWidth;
483
+ var axisCount = layoutInfo.axisCount;
484
+ var axisCollapseWidth = layoutInfo.axisCollapseWidth;
485
+ var winInnerIndices = layoutInfo.winInnerIndices;
486
+
487
+ var position;
488
+ var axisNameAvailableWidth = axisCollapseWidth;
489
+ var axisLabelShow = false;
490
+ var nameTruncateMaxWidth;
491
+
492
+ if (axisIndex < winInnerIndices[0]) {
493
+ position = axisIndex * axisCollapseWidth;
494
+ nameTruncateMaxWidth = axisCollapseWidth;
495
+ }
496
+ else if (axisIndex <= winInnerIndices[1]) {
497
+ position = layoutInfo.axisExpandWindow0Pos
498
+ + axisIndex * axisExpandWidth - layoutInfo.axisExpandWindow[0];
499
+ axisNameAvailableWidth = axisExpandWidth;
500
+ axisLabelShow = true;
501
+ }
502
+ else {
503
+ position = layoutLength - (axisCount - 1 - axisIndex) * axisCollapseWidth;
504
+ nameTruncateMaxWidth = axisCollapseWidth;
505
+ }
506
+
507
+ return {
508
+ position: position,
509
+ axisNameAvailableWidth: axisNameAvailableWidth,
510
+ axisLabelShow: axisLabelShow,
511
+ nameTruncateMaxWidth: nameTruncateMaxWidth
512
+ };
513
+ }
514
+
391
515
  module.exports = Parallel;
@@ -50,6 +50,12 @@
50
50
  axisExpandCenter: null,
51
51
  axisExpandCount: 0,
52
52
  axisExpandWidth: 50, // FIXME '10%' ?
53
+ axisExpandRate: 17,
54
+ axisExpandDebounce: 50,
55
+ // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
56
+ // Do not doc to user until necessary.
57
+ axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
58
+ axisExpandTriggerOn: 'click', // 'mousemove' or 'click'
53
59
 
54
60
  parallelAxisDefault: null
55
61
  },
@@ -87,7 +93,7 @@
87
93
 
88
94
  setAxisExpand: function (opt) {
89
95
  zrUtil.each(
90
- ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth'],
96
+ ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'],
91
97
  function (name) {
92
98
  if (opt.hasOwnProperty(name)) {
93
99
  this.option[name] = opt[name];
@@ -173,7 +173,7 @@
173
173
  dataToPoints: function (data) {
174
174
  return data.mapArray(this.dimensions, function (radius, angle) {
175
175
  return this.dataToPoint([radius, angle]);
176
- }, this);
176
+ }, true, this);
177
177
  },
178
178
 
179
179
  /**
@@ -251,6 +251,7 @@
251
251
 
252
252
  return [x, y];
253
253
  }
254
+
254
255
  };
255
256
 
256
257
  module.exports = Polar;