echarts 3.5.4 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/LICENSE +21 -18
  2. package/dist/echarts.common.js +10072 -9330
  3. package/dist/echarts.common.min.js +13 -13
  4. package/dist/echarts.js +13084 -11412
  5. package/dist/echarts.min.js +22 -21
  6. package/dist/echarts.simple.js +9454 -8889
  7. package/dist/echarts.simple.min.js +9 -10
  8. package/index.js +1 -0
  9. package/lib/chart/bar/BarView.js +141 -49
  10. package/lib/chart/bar/BaseBarSeries.js +2 -6
  11. package/lib/chart/bar.js +1 -0
  12. package/lib/chart/boxplot/BoxplotSeries.js +1 -1
  13. package/lib/chart/boxplot/boxplotLayout.js +23 -7
  14. package/lib/chart/candlestick/CandlestickSeries.js +1 -21
  15. package/lib/chart/candlestick/candlestickLayout.js +23 -7
  16. package/lib/chart/custom.js +442 -0
  17. package/lib/chart/graph/categoryVisual.js +3 -2
  18. package/lib/chart/heatmap/HeatmapView.js +75 -73
  19. package/lib/chart/helper/Symbol.js +8 -31
  20. package/lib/chart/helper/createListFromArray.js +15 -10
  21. package/lib/chart/helper/labelHelper.js +48 -0
  22. package/lib/chart/helper/whiskerBoxCommon.js +25 -44
  23. package/lib/chart/map/mapDataStatistic.js +9 -8
  24. package/lib/chart/pie/pieLayout.js +25 -17
  25. package/lib/chart/radar/RadarSeries.js +1 -1
  26. package/lib/chart/scatter/ScatterSeries.js +2 -3
  27. package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
  28. package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
  29. package/lib/chart/treemap/TreemapSeries.js +3 -3
  30. package/lib/component/axisPointer/BaseAxisPointer.js +7 -6
  31. package/lib/component/axisPointer/axisTrigger.js +62 -51
  32. package/lib/component/axisPointer.js +1 -2
  33. package/lib/component/calendar/CalendarView.js +5 -5
  34. package/lib/component/dataZoom/AxisProxy.js +76 -13
  35. package/lib/component/dataZoom/DataZoomModel.js +21 -5
  36. package/lib/component/dataZoom/InsideZoomModel.js +4 -1
  37. package/lib/component/dataZoom/InsideZoomView.js +16 -26
  38. package/lib/component/dataZoom/SliderZoomView.js +63 -26
  39. package/lib/component/dataZoom/roams.js +8 -3
  40. package/lib/component/graphic.js +13 -12
  41. package/lib/component/helper/BrushTargetManager.js +5 -5
  42. package/lib/component/helper/MapDraw.js +3 -3
  43. package/lib/component/helper/RoamController.js +43 -20
  44. package/lib/component/helper/brushHelper.js +2 -13
  45. package/lib/component/helper/selectableMixin.js +7 -7
  46. package/lib/component/helper/sliderMove.js +65 -36
  47. package/lib/component/legend/LegendView.js +6 -6
  48. package/lib/component/legend/legendAction.js +1 -1
  49. package/lib/component/marker/MarkAreaView.js +3 -6
  50. package/lib/component/marker/MarkLineView.js +3 -5
  51. package/lib/component/marker/MarkPointView.js +3 -5
  52. package/lib/component/marker/MarkerView.js +10 -12
  53. package/lib/component/polar.js +5 -0
  54. package/lib/component/timeline/SliderTimelineView.js +1 -1
  55. package/lib/component/toolbox/feature/DataZoom.js +14 -1
  56. package/lib/component/tooltip/TooltipView.js +3 -3
  57. package/lib/component/visualMap/ContinuousView.js +6 -4
  58. package/lib/coord/Axis.js +34 -2
  59. package/lib/coord/axisDefault.js +2 -1
  60. package/lib/coord/axisHelper.js +6 -25
  61. package/lib/coord/axisModelCommonMixin.js +1 -1
  62. package/lib/coord/calendar/Calendar.js +14 -17
  63. package/lib/coord/calendar/prepareCustom.js +31 -0
  64. package/lib/coord/cartesian/Axis2D.js +0 -12
  65. package/lib/coord/cartesian/Cartesian2D.js +1 -0
  66. package/lib/coord/cartesian/Grid.js +5 -2
  67. package/lib/coord/cartesian/prepareCustom.js +36 -0
  68. package/lib/coord/geo/Geo.js +9 -14
  69. package/lib/coord/geo/GeoModel.js +5 -5
  70. package/lib/coord/geo/geoCreator.js +3 -3
  71. package/lib/coord/geo/prepareCustom.js +36 -0
  72. package/lib/coord/parallel/Parallel.js +12 -11
  73. package/lib/coord/polar/Polar.js +2 -1
  74. package/lib/coord/polar/prepareCustom.js +53 -0
  75. package/lib/coord/single/Single.js +9 -8
  76. package/lib/coord/single/SingleAxis.js +0 -27
  77. package/lib/coord/single/prepareCustom.js +33 -0
  78. package/lib/data/DataDiffer.js +2 -1
  79. package/lib/data/Graph.js +11 -7
  80. package/lib/data/List.js +58 -19
  81. package/lib/data/helper/completeDimensions.js +184 -23
  82. package/lib/echarts.js +38 -33
  83. package/lib/helper.js +1 -8
  84. package/lib/layout/barGrid.js +87 -18
  85. package/lib/layout/barPolar.js +286 -0
  86. package/lib/layout/points.js +22 -16
  87. package/lib/model/Global.js +34 -31
  88. package/lib/model/Series.js +41 -29
  89. package/lib/model/mixin/colorPalette.js +2 -1
  90. package/lib/model/mixin/textStyle.js +7 -13
  91. package/lib/scale/Interval.js +21 -14
  92. package/lib/scale/Log.js +5 -7
  93. package/lib/scale/Time.js +13 -7
  94. package/lib/scale/helper.js +5 -1
  95. package/lib/util/format.js +12 -0
  96. package/lib/util/graphic.js +53 -1
  97. package/lib/util/model.js +63 -7
  98. package/map/js/world.js +1 -1
  99. package/map/json/world.json +1 -1
  100. package/package.json +3 -3
  101. package/src/chart/bar/BarView.js +141 -49
  102. package/src/chart/bar/BaseBarSeries.js +2 -6
  103. package/src/chart/bar.js +1 -0
  104. package/src/chart/boxplot/BoxplotSeries.js +1 -1
  105. package/src/chart/boxplot/boxplotLayout.js +23 -7
  106. package/src/chart/candlestick/CandlestickSeries.js +1 -21
  107. package/src/chart/candlestick/candlestickLayout.js +23 -7
  108. package/src/chart/custom.js +442 -0
  109. package/src/chart/graph/categoryVisual.js +3 -2
  110. package/src/chart/heatmap/HeatmapView.js +75 -73
  111. package/src/chart/helper/Symbol.js +8 -31
  112. package/src/chart/helper/createListFromArray.js +15 -10
  113. package/src/chart/helper/labelHelper.js +49 -0
  114. package/src/chart/helper/whiskerBoxCommon.js +25 -44
  115. package/src/chart/map/mapDataStatistic.js +9 -8
  116. package/src/chart/pie/pieLayout.js +25 -17
  117. package/src/chart/radar/RadarSeries.js +1 -1
  118. package/src/chart/scatter/ScatterSeries.js +2 -3
  119. package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
  120. package/src/chart/themeRiver/themeRiverVisual.js +1 -1
  121. package/src/chart/treemap/TreemapSeries.js +3 -3
  122. package/src/component/axisPointer/BaseAxisPointer.js +7 -6
  123. package/src/component/axisPointer/axisTrigger.js +62 -51
  124. package/src/component/axisPointer.js +1 -2
  125. package/src/component/calendar/CalendarView.js +5 -5
  126. package/src/component/dataZoom/AxisProxy.js +76 -13
  127. package/src/component/dataZoom/DataZoomModel.js +21 -5
  128. package/src/component/dataZoom/InsideZoomModel.js +4 -1
  129. package/src/component/dataZoom/InsideZoomView.js +16 -26
  130. package/src/component/dataZoom/SliderZoomView.js +63 -26
  131. package/src/component/dataZoom/roams.js +8 -3
  132. package/src/component/graphic.js +13 -12
  133. package/src/component/helper/BrushTargetManager.js +5 -5
  134. package/src/component/helper/MapDraw.js +3 -3
  135. package/src/component/helper/RoamController.js +43 -20
  136. package/src/component/helper/brushHelper.js +2 -13
  137. package/src/component/helper/selectableMixin.js +7 -7
  138. package/src/component/helper/sliderMove.js +65 -36
  139. package/src/component/legend/LegendView.js +6 -6
  140. package/src/component/legend/legendAction.js +1 -1
  141. package/src/component/marker/MarkAreaView.js +3 -6
  142. package/src/component/marker/MarkLineView.js +3 -5
  143. package/src/component/marker/MarkPointView.js +3 -5
  144. package/src/component/marker/MarkerView.js +10 -12
  145. package/src/component/polar.js +5 -0
  146. package/src/component/timeline/SliderTimelineView.js +1 -1
  147. package/src/component/toolbox/feature/DataZoom.js +14 -1
  148. package/src/component/tooltip/TooltipView.js +3 -3
  149. package/src/component/visualMap/ContinuousView.js +6 -4
  150. package/src/coord/Axis.js +34 -2
  151. package/src/coord/axisDefault.js +2 -1
  152. package/src/coord/axisHelper.js +6 -25
  153. package/src/coord/axisModelCommonMixin.js +1 -1
  154. package/src/coord/calendar/Calendar.js +14 -17
  155. package/src/coord/calendar/prepareCustom.js +32 -0
  156. package/src/coord/cartesian/Axis2D.js +0 -12
  157. package/src/coord/cartesian/Cartesian2D.js +1 -0
  158. package/src/coord/cartesian/Grid.js +5 -2
  159. package/src/coord/cartesian/prepareCustom.js +37 -0
  160. package/src/coord/geo/Geo.js +9 -14
  161. package/src/coord/geo/GeoModel.js +5 -5
  162. package/src/coord/geo/geoCreator.js +3 -3
  163. package/src/coord/geo/prepareCustom.js +37 -0
  164. package/src/coord/parallel/Parallel.js +12 -11
  165. package/src/coord/polar/Polar.js +2 -1
  166. package/src/coord/polar/prepareCustom.js +54 -0
  167. package/src/coord/single/Single.js +9 -8
  168. package/src/coord/single/SingleAxis.js +0 -27
  169. package/src/coord/single/prepareCustom.js +34 -0
  170. package/src/data/DataDiffer.js +2 -1
  171. package/src/data/Graph.js +11 -7
  172. package/src/data/List.js +58 -19
  173. package/src/data/helper/completeDimensions.js +184 -23
  174. package/src/echarts.js +38 -33
  175. package/src/helper.js +1 -8
  176. package/src/layout/barGrid.js +87 -18
  177. package/src/layout/barPolar.js +287 -0
  178. package/src/layout/points.js +22 -16
  179. package/src/model/Global.js +34 -31
  180. package/src/model/Series.js +41 -29
  181. package/src/model/mixin/colorPalette.js +2 -1
  182. package/src/model/mixin/textStyle.js +7 -13
  183. package/src/scale/Interval.js +21 -14
  184. package/src/scale/Log.js +5 -7
  185. package/src/scale/Time.js +13 -7
  186. package/src/scale/helper.js +5 -1
  187. package/src/util/format.js +12 -0
  188. package/src/util/graphic.js +53 -1
  189. package/src/util/model.js +63 -7
  190. package/src/coord/cartesian/axisLabelInterval.js +0 -26
package/lib/data/List.js CHANGED
@@ -31,7 +31,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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];
@@ -598,7 +634,7 @@
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 @@
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 @@
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 @@
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
 
5
5
 
6
6
  var zrUtil = require('zrender/lib/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 @@
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
  }
package/lib/echarts.js CHANGED
@@ -276,14 +276,7 @@ if (typeof __DEV__ === 'undefined') {
276
276
  ecModel.init(null, null, theme, optionManager);
277
277
  }
278
278
 
279
- // FIXME
280
- // ugly
281
- this.__lastOnlyGraphic = !!(option && option.graphic);
282
- zrUtil.each(option, function (o, mainType) {
283
- mainType !== 'graphic' && (this.__lastOnlyGraphic = false);
284
- }, this);
285
-
286
- this._model.setOption(option, optionPreprocessorFuncs, this.__lastOnlyGraphic);
279
+ this._model.setOption(option, optionPreprocessorFuncs);
287
280
 
288
281
  if (lazyUpdate) {
289
282
  this[OPTION_UPDATED] = {silent: silent};
@@ -809,21 +802,7 @@ if (typeof __DEV__ === 'undefined') {
809
802
 
810
803
  prepareView.call(this, 'chart', ecModel);
811
804
 
812
- // FIXME
813
- // ugly
814
- if (this.__lastOnlyGraphic) {
815
- each(this._componentsViews, function (componentView) {
816
- var componentModel = componentView.__model;
817
- if (componentModel && componentModel.mainType === 'graphic') {
818
- componentView.render(componentModel, ecModel, this._api, payload);
819
- updateZ(componentModel, componentView);
820
- }
821
- }, this);
822
- this.__lastOnlyGraphic = false;
823
- }
824
- else {
825
- updateMethods.update.call(this, payload);
826
- }
805
+ updateMethods.update.call(this, payload);
827
806
  }
828
807
  };
829
808
 
@@ -1140,7 +1119,7 @@ if (typeof __DEV__ === 'undefined') {
1140
1119
  }
1141
1120
 
1142
1121
  // Consider: id same and type changed.
1143
- var viewId = model.id + '_' + model.type;
1122
+ var viewId = '_ec_' + model.id + '_' + model.type;
1144
1123
  var view = viewMap[viewId];
1145
1124
  if (!view) {
1146
1125
  var classType = parseClassType(model.type);
@@ -1206,7 +1185,8 @@ if (typeof __DEV__ === 'undefined') {
1206
1185
  var data = series.getData();
1207
1186
  if (stack && data.type === 'list') {
1208
1187
  var previousStack = stackedDataMap[stack];
1209
- if (previousStack) {
1188
+ // Avoid conflict with Object.prototype
1189
+ if (stackedDataMap.hasOwnProperty(stack) && previousStack) {
1210
1190
  data.stackedOn = previousStack;
1211
1191
  }
1212
1192
  stackedDataMap[stack] = data;
@@ -1528,6 +1508,7 @@ if (typeof __DEV__ === 'undefined') {
1528
1508
  var idBase = new Date() - 0;
1529
1509
  var groupIdBase = new Date() - 0;
1530
1510
  var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
1511
+
1531
1512
  /**
1532
1513
  * @alias module:echarts
1533
1514
  */
@@ -1535,9 +1516,9 @@ if (typeof __DEV__ === 'undefined') {
1535
1516
  /**
1536
1517
  * @type {number}
1537
1518
  */
1538
- version: '3.5.4',
1519
+ version: '3.6.0',
1539
1520
  dependencies: {
1540
- zrender: '3.4.4'
1521
+ zrender: '3.5.0'
1541
1522
  }
1542
1523
  };
1543
1524
 
@@ -1604,9 +1585,21 @@ if (typeof __DEV__ === 'undefined') {
1604
1585
  + echarts.dependencies.zrender + '+'
1605
1586
  );
1606
1587
  }
1588
+
1607
1589
  if (!dom) {
1608
1590
  throw new Error('Initialize failed: invalid dom.');
1609
1591
  }
1592
+ }
1593
+
1594
+ var existInstance = echarts.getInstanceByDom(dom);
1595
+ if (existInstance) {
1596
+ if (__DEV__) {
1597
+ console.warn('There is a chart instance already initialized on the dom.');
1598
+ }
1599
+ return existInstance;
1600
+ }
1601
+
1602
+ if (__DEV__) {
1610
1603
  if (zrUtil.isDom(dom)
1611
1604
  && dom.nodeName.toUpperCase() !== 'CANVAS'
1612
1605
  && (
@@ -1622,8 +1615,12 @@ if (typeof __DEV__ === 'undefined') {
1622
1615
  chart.id = 'ec_' + idBase++;
1623
1616
  instances[chart.id] = chart;
1624
1617
 
1625
- dom.setAttribute &&
1618
+ if (dom.setAttribute) {
1626
1619
  dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
1620
+ }
1621
+ else {
1622
+ dom[DOM_ATTRIBUTE_KEY] = chart.id;
1623
+ }
1627
1624
 
1628
1625
  enableConnect(chart);
1629
1626
 
@@ -1671,12 +1668,13 @@ if (typeof __DEV__ === 'undefined') {
1671
1668
  * @param {module:echarts~ECharts|HTMLDomElement|string} chart
1672
1669
  */
1673
1670
  echarts.dispose = function (chart) {
1674
- if (zrUtil.isDom(chart)) {
1675
- chart = echarts.getInstanceByDom(chart);
1676
- }
1677
- else if (typeof chart === 'string') {
1671
+ if (typeof chart === 'string') {
1678
1672
  chart = instances[chart];
1679
1673
  }
1674
+ else if (!(chart instanceof ECharts)){
1675
+ // Try to treat as dom
1676
+ chart = echarts.getInstanceByDom(chart);
1677
+ }
1680
1678
  if ((chart instanceof ECharts) && !chart.isDisposed()) {
1681
1679
  chart.dispose();
1682
1680
  }
@@ -1687,9 +1685,16 @@ if (typeof __DEV__ === 'undefined') {
1687
1685
  * @return {echarts~ECharts}
1688
1686
  */
1689
1687
  echarts.getInstanceByDom = function (dom) {
1690
- var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
1688
+ var key;
1689
+ if (dom.getAttribute) {
1690
+ key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
1691
+ }
1692
+ else {
1693
+ key = dom[DOM_ATTRIBUTE_KEY];
1694
+ }
1691
1695
  return instances[key];
1692
1696
  };
1697
+
1693
1698
  /**
1694
1699
  * @param {string} key
1695
1700
  * @return {echarts~ECharts}
package/lib/helper.js CHANGED
@@ -19,14 +19,7 @@
19
19
  },
20
20
 
21
21
  /**
22
- * Complete the dimensions array guessed from the data structure.
23
- * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
24
- * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
25
- * @param {Object} [opt]
26
- * @param {Array.<string>} [opt.defaultNames] Default names to fill not necessary dimensions, like ['value']
27
- * @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
28
- * @param {number} [opt.dimCount] If not specified, guess by the first data item.
29
- * @return {Array.<string>}
22
+ * @see {module:echarts/data/helper/completeDimensions}
30
23
  */
31
24
  completeDimensions: require('./data/helper/completeDimensions'),
32
25