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
@@ -105,7 +105,8 @@ define(function(require) {
105
105
 
106
106
  function initIndexMap(arr, map, keyArr, keyGetter) {
107
107
  for (var i = 0; i < arr.length; i++) {
108
- var key = keyGetter(arr[i], i);
108
+ // Add prefix to avoid conflict with Object.prototype.
109
+ var key = '_ec_' + keyGetter(arr[i], i);
109
110
  var existence = map[key];
110
111
  if (existence == null) {
111
112
  keyArr.push(key);
package/src/data/Graph.js CHANGED
@@ -10,6 +10,10 @@ define(function(require) {
10
10
 
11
11
  var zrUtil = require('zrender/core/util');
12
12
 
13
+ // id may be function name of Object, add a prefix to avoid this problem.
14
+ function generateNodeKey (id) {
15
+ return '_EC_' + id;
16
+ }
13
17
  /**
14
18
  * @alias module:echarts/data/Graph
15
19
  * @constructor
@@ -83,7 +87,7 @@ define(function(require) {
83
87
 
84
88
  var nodesMap = this._nodesMap;
85
89
 
86
- if (nodesMap[id]) {
90
+ if (nodesMap[generateNodeKey(id)]) {
87
91
  return;
88
92
  }
89
93
 
@@ -92,7 +96,7 @@ define(function(require) {
92
96
 
93
97
  this.nodes.push(node);
94
98
 
95
- nodesMap[id] = node;
99
+ nodesMap[generateNodeKey(id)] = node;
96
100
  return node;
97
101
  };
98
102
 
@@ -111,7 +115,7 @@ define(function(require) {
111
115
  * @return {module:echarts/data/Graph.Node}
112
116
  */
113
117
  graphProto.getNodeById = function (id) {
114
- return this._nodesMap[id];
118
+ return this._nodesMap[generateNodeKey(id)];
115
119
  };
116
120
 
117
121
  /**
@@ -134,10 +138,10 @@ define(function(require) {
134
138
  }
135
139
 
136
140
  if (!(n1 instanceof Node)) {
137
- n1 = nodesMap[n1];
141
+ n1 = nodesMap[generateNodeKey(n1)];
138
142
  }
139
143
  if (!(n2 instanceof Node)) {
140
- n2 = nodesMap[n2];
144
+ n2 = nodesMap[generateNodeKey(n2)];
141
145
  }
142
146
  if (!n1 || !n2) {
143
147
  return;
@@ -244,7 +248,7 @@ define(function(require) {
244
248
  cb, startNode, direction, context
245
249
  ) {
246
250
  if (!(startNode instanceof Node)) {
247
- startNode = this._nodesMap[startNode];
251
+ startNode = this._nodesMap[generateNodeKey(startNode)];
248
252
  }
249
253
  if (!startNode) {
250
254
  return;
@@ -271,7 +275,7 @@ define(function(require) {
271
275
  var otherNode = e.node1 === currentNode
272
276
  ? e.node2 : e.node1;
273
277
  if (!otherNode.__visited) {
274
- if (cb.call(otherNode, otherNode, currentNode)) {
278
+ if (cb.call(context, otherNode, currentNode)) {
275
279
  // Stop traversing
276
280
  return;
277
281
  }
package/src/data/List.js CHANGED
@@ -31,7 +31,7 @@ define(function (require) {
31
31
  'stackedOn', 'hasItemOption', '_nameList', '_idList', '_rawData'
32
32
  ];
33
33
 
34
- var transferProperties = function (a, b) {
34
+ function transferProperties(a, b) {
35
35
  zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
36
36
  if (b.hasOwnProperty(propName)) {
37
37
  a[propName] = b[propName];
@@ -39,6 +39,19 @@ define(function (require) {
39
39
  });
40
40
 
41
41
  a.__wrappedMethods = b.__wrappedMethods;
42
+ }
43
+
44
+ function DefaultDataProvider(dataArray) {
45
+ this._array = dataArray || [];
46
+ }
47
+
48
+ DefaultDataProvider.prototype.pure = false;
49
+
50
+ DefaultDataProvider.prototype.count = function () {
51
+ return this._array.length;
52
+ };
53
+ DefaultDataProvider.prototype.getItem = function (idx) {
54
+ return this._array[idx];
42
55
  };
43
56
 
44
57
  /**
@@ -63,6 +76,8 @@ define(function (require) {
63
76
  dimensionName = dimensions[i];
64
77
  dimensionInfo = {
65
78
  name: dimensionName,
79
+ coordDim: dimensionName,
80
+ coordDimIndex: 0,
66
81
  stackable: false,
67
82
  // Type can be 'float', 'int', 'number'
68
83
  // Default is number, Precision of float may not enough
@@ -73,10 +88,16 @@ define(function (require) {
73
88
  dimensionInfo = dimensions[i];
74
89
  dimensionName = dimensionInfo.name;
75
90
  dimensionInfo.type = dimensionInfo.type || 'number';
91
+ if (!dimensionInfo.coordDim) {
92
+ dimensionInfo.coordDim = dimensionName;
93
+ dimensionInfo.coordDimIndex = 0;
94
+ }
76
95
  }
96
+ dimensionInfo.otherDims = dimensionInfo.otherDims || {};
77
97
  dimensionNames.push(dimensionName);
78
98
  dimensionInfos[dimensionName] = dimensionInfo;
79
99
  }
100
+
80
101
  /**
81
102
  * @readOnly
82
103
  * @type {Array.<string>}
@@ -122,6 +143,7 @@ define(function (require) {
122
143
  * @type {Array.<string>}
123
144
  */
124
145
  this._idList = [];
146
+
125
147
  /**
126
148
  * Models of data option is stored sparse for optimizing memory cost
127
149
  * @type {Array.<module:echarts/model/Model>}
@@ -185,6 +207,7 @@ define(function (require) {
185
207
  var listProto = List.prototype;
186
208
 
187
209
  listProto.type = 'list';
210
+
188
211
  /**
189
212
  * If each data item has it's own option
190
213
  * @type {boolean}
@@ -204,6 +227,7 @@ define(function (require) {
204
227
  }
205
228
  return dim;
206
229
  };
230
+
207
231
  /**
208
232
  * Get type and stackable info of particular dimension
209
233
  * @param {string|number} dim
@@ -223,9 +247,13 @@ define(function (require) {
223
247
  listProto.initData = function (data, nameList, dimValueGetter) {
224
248
  data = data || [];
225
249
 
250
+ var isDataArray = zrUtil.isArray(data);
251
+ if (isDataArray) {
252
+ data = new DefaultDataProvider(data);
253
+ }
226
254
  if (__DEV__) {
227
- if (!zrUtil.isArray(data)) {
228
- throw new Error('Invalid data.');
255
+ if (!isDataArray && (typeof data.getItem != 'function' || typeof data.count != 'function')) {
256
+ throw new Error('Inavlid data provider.');
229
257
  }
230
258
  }
231
259
 
@@ -236,17 +264,20 @@ define(function (require) {
236
264
  var indices = this.indices = [];
237
265
 
238
266
  var dimensions = this.dimensions;
239
- var size = data.length;
240
267
  var dimensionInfoMap = this._dimensionInfos;
241
268
 
269
+ var size = data.count();
270
+
242
271
  var idList = [];
243
272
  var nameRepeatCount = {};
273
+ var nameDimIdx;
244
274
 
245
275
  nameList = nameList || [];
246
276
 
247
277
  // Init storage
248
278
  for (var i = 0; i < dimensions.length; i++) {
249
279
  var dimInfo = dimensionInfoMap[dimensions[i]];
280
+ dimInfo.otherDims.itemName === 0 && (nameDimIdx = i);
250
281
  var DataCtor = dataCtors[dimInfo.type];
251
282
  storage[dimensions[i]] = new DataCtor(size);
252
283
  }
@@ -271,8 +302,9 @@ define(function (require) {
271
302
  );
272
303
  };
273
304
 
274
- for (var idx = 0; idx < data.length; idx++) {
275
- var dataItem = data[idx];
305
+ for (var i = 0; i < size; i++) {
306
+ // NOTICE: Try not to write things into dataItem
307
+ var dataItem = data.getItem(i);
276
308
  // Each data item is value
277
309
  // [1, 2]
278
310
  // 2
@@ -285,22 +317,26 @@ define(function (require) {
285
317
  var dim = dimensions[k];
286
318
  var dimStorage = storage[dim];
287
319
  // PENDING NULL is empty or zero
288
- dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k);
320
+ dimStorage[i] = dimValueGetter(dataItem, dim, i, k);
289
321
  }
290
322
 
291
- indices.push(idx);
323
+ indices.push(i);
292
324
  }
293
325
 
294
326
  // Use the name in option and create id
295
- for (var i = 0; i < data.length; i++) {
296
- if (!nameList[i]) {
297
- if (data[i] && data[i].name != null) {
298
- nameList[i] = data[i].name;
327
+ for (var i = 0; i < size; i++) {
328
+ var dataItem = data.getItem(i);
329
+ if (!nameList[i] && dataItem) {
330
+ if (dataItem.name != null) {
331
+ nameList[i] = dataItem.name;
332
+ }
333
+ else if (nameDimIdx != null) {
334
+ nameList[i] = storage[dimensions[nameDimIdx]][i];
299
335
  }
300
336
  }
301
337
  var name = nameList[i] || '';
302
338
  // Try using the id in option
303
- var id = data[i] && data[i].id;
339
+ var id = dataItem && dataItem.id;
304
340
 
305
341
  if (!id && name) {
306
342
  // Use name as id and add counter to avoid same name
@@ -337,11 +373,11 @@ define(function (require) {
337
373
  var dataIndex = this.indices[idx];
338
374
 
339
375
  // If value not exists
340
- if (dataIndex == null) {
376
+ if (dataIndex == null || !storage[dim]) {
341
377
  return NaN;
342
378
  }
343
379
 
344
- var value = storage[dim] && storage[dim][dataIndex];
380
+ var value = storage[dim][dataIndex];
345
381
  // FIXME ordinal data type is not stackable
346
382
  if (stack) {
347
383
  var dimensionInfo = this._dimensionInfos[dim];
@@ -549,7 +585,7 @@ define(function (require) {
549
585
  * @param {number} [maxDistance=Infinity]
550
586
  * @return {Array.<number>} Considere multiple points has the same value.
551
587
  */
552
- listProto.indexOfNearest = function (dim, value, stack, maxDistance) {
588
+ listProto.indicesOfNearest = function (dim, value, stack, maxDistance) {
553
589
  var storage = this._storage;
554
590
  var dimData = storage[dim];
555
591
  var nearestIndices = [];
@@ -598,7 +634,7 @@ define(function (require) {
598
634
  * @return {number}
599
635
  */
600
636
  listProto.getRawDataItem = function (idx) {
601
- return this._rawData[this.getRawIndex(idx)];
637
+ return this._rawData.getItem(this.getRawIndex(idx));
602
638
  };
603
639
 
604
640
  /**
@@ -707,7 +743,10 @@ define(function (require) {
707
743
  for (var i = 0; i < indices.length; i++) {
708
744
  var keep;
709
745
  // Simple optimization
710
- if (dimSize === 1) {
746
+ if (!dimSize) {
747
+ keep = cb.call(context, i);
748
+ }
749
+ else if (dimSize === 1) {
711
750
  keep = cb.call(
712
751
  context, this.get(dimensions[0], i, stack), i
713
752
  );
@@ -882,7 +921,7 @@ define(function (require) {
882
921
  listProto.getItemModel = function (idx) {
883
922
  var hostModel = this.hostModel;
884
923
  idx = this.indices[idx];
885
- return new Model(this._rawData[idx], hostModel, hostModel && hostModel.ecModel);
924
+ return new Model(this._rawData.getItem(idx), hostModel, hostModel && hostModel.ecModel);
886
925
  };
887
926
 
888
927
  /**
@@ -999,7 +1038,7 @@ define(function (require) {
999
1038
  * Get visual property of single data item
1000
1039
  * @param {number} idx
1001
1040
  * @param {string} key
1002
- * @param {boolean} ignoreParent
1041
+ * @param {boolean} [ignoreParent=false]
1003
1042
  */
1004
1043
  listProto.getItemVisual = function (idx, key, ignoreParent) {
1005
1044
  var itemVisual = this._itemVisuals[idx];
@@ -4,42 +4,202 @@
4
4
  define(function (require) {
5
5
 
6
6
  var zrUtil = require('zrender/core/util');
7
+ var modelUtil = require('../../util/model');
8
+ var each = zrUtil.each;
9
+ var isString = zrUtil.isString;
10
+ var defaults = zrUtil.defaults;
11
+ var normalizeToArray = modelUtil.normalizeToArray;
12
+
13
+ var OTHER_DIMS = {tooltip: 1, label: 1, itemName: 1};
7
14
 
8
15
  /**
9
- * Complete the dimensions array guessed from the data structure.
10
- * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
11
- * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
12
- * @param {Object} [opt]
13
- * @param {Array.<string>} [opt.defaultNames] Default names to fill not necessary dimensions, like ['value']
14
- * @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
15
- * @param {number} [opt.dimCount] If not specified, guess by the first data item.
16
- * @return {Array.<string>}
16
+ * Complete the dimensions array, by user defined `dimension` and `encode`,
17
+ * and guessing from the data structure.
18
+ * If no 'value' dimension specified, the first no-named dimension will be
19
+ * named as 'value'.
20
+ *
21
+ * @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
22
+ * provides not only dim template, but also default order.
23
+ * `name` of each item provides default coord name.
24
+ * [{dimsDef: []}, ...] can be specified to give names.
25
+ * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]].
26
+ * @param {Object} [opt]
27
+ * @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
28
+ * For example: ['asdf', {name, type}, ...].
29
+ * @param {Object} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
30
+ * @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
31
+ * @param {string} [opt.extraFromZero] If specified, extra dim names will be:
32
+ * extraPrefix + 0, extraPrefix + extraBaseIndex + 1 ...
33
+ * If not specified, extra dim names will be:
34
+ * extraPrefix, extraPrefix + 0, extraPrefix + 1 ...
35
+ * @param {number} [opt.dimCount] If not specified, guess by the first data item.
36
+ * @return {Array.<Object>} [{
37
+ * name: string mandatory,
38
+ * coordDim: string mandatory,
39
+ * coordDimIndex: number mandatory,
40
+ * type: string optional,
41
+ * tooltipName: string optional,
42
+ * otherDims: {
43
+ * tooltip: number optional,
44
+ * label: number optional
45
+ * },
46
+ * isExtraCoord: boolean true or undefined.
47
+ * other props ...
48
+ * }]
17
49
  */
18
- function completeDimensions(dimensions, data, opt) {
19
- if (!data) {
20
- return dimensions;
21
- }
22
-
50
+ function completeDimensions(sysDims, data, opt) {
51
+ data = data || [];
23
52
  opt = opt || {};
53
+ sysDims = (sysDims || []).slice();
54
+ var dimsDef = (opt.dimsDef || []).slice();
55
+ var encodeDef = zrUtil.createHashMap(opt.encodeDef);
56
+ var dataDimNameMap = zrUtil.createHashMap();
57
+ var coordDimNameMap = zrUtil.createHashMap();
58
+ // var valueCandidate;
59
+ var result = [];
24
60
 
25
61
  var dimCount = opt.dimCount;
26
62
  if (dimCount == null) {
27
63
  var value0 = retrieveValue(data[0]);
28
- dimCount = zrUtil.isArray(value0) && value0.length || 1;
64
+ dimCount = Math.max(
65
+ zrUtil.isArray(value0) && value0.length || 1,
66
+ sysDims.length,
67
+ dimsDef.length
68
+ );
69
+ each(sysDims, function (sysDimItem) {
70
+ var sysDimItemDimsDef = sysDimItem.dimsDef;
71
+ sysDimItemDimsDef && (dimCount = Math.max(dimCount, sysDimItemDimsDef.length));
72
+ });
29
73
  }
30
74
 
31
- var defaultNames = opt.defaultNames || [];
32
- var extraPrefix = opt.extraPrefix || 'extra';
75
+ // Apply user defined dims (`name` and `type`) and init result.
33
76
  for (var i = 0; i < dimCount; i++) {
34
- if (!dimensions[i]) {
35
- var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length));
36
- dimensions[i] = guessOrdinal(data, i)
37
- ? {type: 'ordinal', name: name}
38
- : name;
77
+ var dimDefItem = isString(dimsDef[i]) ? {name: dimsDef[i]} : (dimsDef[i] || {});
78
+ var userDimName = dimDefItem.name;
79
+ var resultItem = result[i] = {otherDims: {}};
80
+ // Name will be applied later for avoiding duplication.
81
+ if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
82
+ // Only if `series.dimensions` is defined in option, tooltipName
83
+ // will be set, and dimension will be diplayed vertically in
84
+ // tooltip by default.
85
+ resultItem.name = resultItem.tooltipName = userDimName;
86
+ dataDimNameMap.set(userDimName, i);
87
+ }
88
+ dimDefItem.type != null && (resultItem.type = dimDefItem.type);
89
+ }
90
+
91
+ // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
92
+ encodeDef.each(function (dataDims, coordDim) {
93
+ dataDims = encodeDef.set(coordDim, normalizeToArray(dataDims).slice());
94
+ each(dataDims, function (resultDimIdx, coordDimIndex) {
95
+ // The input resultDimIdx can be dim name or index.
96
+ isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
97
+ if (resultDimIdx != null && resultDimIdx < dimCount) {
98
+ dataDims[coordDimIndex] = resultDimIdx;
99
+ applyDim(result[resultDimIdx], coordDim, coordDimIndex);
100
+ // coordDim === 'value' && valueCandidate == null && (valueCandidate = resultDimIdx);
101
+ }
102
+ });
103
+ });
104
+
105
+ // Apply templetes and default order from `sysDims`.
106
+ var availDimIdx = 0;
107
+ each(sysDims, function (sysDimItem, sysDimIndex) {
108
+ var coordDim;
109
+ var sysDimItem;
110
+ var sysDimItemDimsDef;
111
+ var sysDimItemOtherDims;
112
+ if (isString(sysDimItem)) {
113
+ coordDim = sysDimItem;
114
+ sysDimItem = {};
115
+ }
116
+ else {
117
+ coordDim = sysDimItem.name;
118
+ sysDimItem = zrUtil.clone(sysDimItem);
119
+ // `coordDimIndex` should not be set directly.
120
+ sysDimItemDimsDef = sysDimItem.dimsDef;
121
+ sysDimItemOtherDims = sysDimItem.otherDims;
122
+ sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex
123
+ = sysDimItem.dimsDef = sysDimItem.otherDims = null;
124
+ }
125
+
126
+ var dataDims = normalizeToArray(encodeDef.get(coordDim));
127
+ // dimensions provides default dim sequences.
128
+ if (!dataDims.length) {
129
+ for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
130
+ while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
131
+ availDimIdx++;
132
+ }
133
+ availDimIdx < result.length && dataDims.push(availDimIdx++);
134
+ }
135
+ }
136
+ // Apply templates.
137
+ each(dataDims, function (resultDimIdx, coordDimIndex) {
138
+ var resultItem = result[resultDimIdx];
139
+ applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
140
+ // coordDim === 'value' && valueCandidate == null && (valueCandidate = resultDimIdx);
141
+ if (resultItem.name == null && sysDimItemDimsDef) {
142
+ resultItem.name = resultItem.tooltipName = sysDimItemDimsDef[coordDimIndex];
143
+ }
144
+ sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
145
+ });
146
+ });
147
+
148
+ // Make sure the first extra dim is 'value'.
149
+ var extra = opt.extraPrefix || 'value';
150
+
151
+ // Set dim `name` and other `coordDim` and other props.
152
+ for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
153
+ var resultItem = result[resultDimIdx] = result[resultDimIdx] || {};
154
+ var coordDim = resultItem.coordDim;
155
+
156
+ coordDim == null && (
157
+ resultItem.coordDim = genName(extra, coordDimNameMap, opt.extraFromZero),
158
+ resultItem.coordDimIndex = 0,
159
+ resultItem.isExtraCoord = true
160
+ );
161
+
162
+ resultItem.name == null && (resultItem.name = genName(
163
+ // Ensure At least one value dim.
164
+ // (dataDimNameMap.get('value') == null
165
+ // && (valueCandidate == null || valueCandidate === resultDimIdx)
166
+ // // Try to set as 'value' only if coordDim is not set as 'extra'.
167
+ // && coordDim == null
168
+ // )
169
+ // ? 'value'
170
+ // :
171
+ resultItem.coordDim,
172
+ dataDimNameMap
173
+ ));
174
+
175
+ resultItem.type == null && guessOrdinal(data, resultDimIdx)
176
+ && (resultItem.type = 'ordinal');
177
+ }
178
+
179
+ return result;
180
+
181
+ function applyDim(resultItem, coordDim, coordDimIndex) {
182
+ if (OTHER_DIMS[coordDim]) {
183
+ resultItem.otherDims[coordDim] = coordDimIndex;
184
+ }
185
+ else {
186
+ resultItem.coordDim = coordDim;
187
+ resultItem.coordDimIndex = coordDimIndex;
188
+ coordDimNameMap.set(coordDim, true);
39
189
  }
40
190
  }
41
191
 
42
- return dimensions;
192
+ function genName(name, map, fromZero) {
193
+ if (fromZero || map.get(name) != null) {
194
+ var i = 0;
195
+ while (map.get(name + i) != null) {
196
+ i++;
197
+ }
198
+ name += i;
199
+ }
200
+ map.set(name, true);
201
+ return name;
202
+ }
43
203
  }
44
204
 
45
205
  // The rule should not be complex, otherwise user might not
@@ -53,10 +213,11 @@ define(function (require) {
53
213
  }
54
214
 
55
215
  var value = value[dimIndex];
216
+ // Consider usage convenience, '1', '2' will be treated as "number".
56
217
  if (value != null && isFinite(value)) {
57
218
  return false;
58
219
  }
59
- else if (zrUtil.isString(value) && value !== '-') {
220
+ else if (isString(value) && value !== '-') {
60
221
  return true;
61
222
  }
62
223
  }