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.
- package/LICENSE +21 -18
- package/dist/echarts.common.js +10072 -9330
- package/dist/echarts.common.min.js +13 -13
- package/dist/echarts.js +13084 -11412
- package/dist/echarts.min.js +22 -21
- package/dist/echarts.simple.js +9454 -8889
- package/dist/echarts.simple.min.js +9 -10
- package/index.js +1 -0
- package/lib/chart/bar/BarView.js +141 -49
- package/lib/chart/bar/BaseBarSeries.js +2 -6
- package/lib/chart/bar.js +1 -0
- package/lib/chart/boxplot/BoxplotSeries.js +1 -1
- package/lib/chart/boxplot/boxplotLayout.js +23 -7
- package/lib/chart/candlestick/CandlestickSeries.js +1 -21
- package/lib/chart/candlestick/candlestickLayout.js +23 -7
- package/lib/chart/custom.js +442 -0
- package/lib/chart/graph/categoryVisual.js +3 -2
- package/lib/chart/heatmap/HeatmapView.js +75 -73
- package/lib/chart/helper/Symbol.js +8 -31
- package/lib/chart/helper/createListFromArray.js +15 -10
- package/lib/chart/helper/labelHelper.js +48 -0
- package/lib/chart/helper/whiskerBoxCommon.js +25 -44
- package/lib/chart/map/mapDataStatistic.js +9 -8
- package/lib/chart/pie/pieLayout.js +25 -17
- package/lib/chart/radar/RadarSeries.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -3
- package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +3 -3
- package/lib/component/axisPointer/BaseAxisPointer.js +7 -6
- package/lib/component/axisPointer/axisTrigger.js +62 -51
- package/lib/component/axisPointer.js +1 -2
- package/lib/component/calendar/CalendarView.js +5 -5
- package/lib/component/dataZoom/AxisProxy.js +76 -13
- package/lib/component/dataZoom/DataZoomModel.js +21 -5
- package/lib/component/dataZoom/InsideZoomModel.js +4 -1
- package/lib/component/dataZoom/InsideZoomView.js +16 -26
- package/lib/component/dataZoom/SliderZoomView.js +63 -26
- package/lib/component/dataZoom/roams.js +8 -3
- package/lib/component/graphic.js +13 -12
- package/lib/component/helper/BrushTargetManager.js +5 -5
- package/lib/component/helper/MapDraw.js +3 -3
- package/lib/component/helper/RoamController.js +43 -20
- package/lib/component/helper/brushHelper.js +2 -13
- package/lib/component/helper/selectableMixin.js +7 -7
- package/lib/component/helper/sliderMove.js +65 -36
- package/lib/component/legend/LegendView.js +6 -6
- package/lib/component/legend/legendAction.js +1 -1
- package/lib/component/marker/MarkAreaView.js +3 -6
- package/lib/component/marker/MarkLineView.js +3 -5
- package/lib/component/marker/MarkPointView.js +3 -5
- package/lib/component/marker/MarkerView.js +10 -12
- package/lib/component/polar.js +5 -0
- package/lib/component/timeline/SliderTimelineView.js +1 -1
- package/lib/component/toolbox/feature/DataZoom.js +14 -1
- package/lib/component/tooltip/TooltipView.js +3 -3
- package/lib/component/visualMap/ContinuousView.js +6 -4
- package/lib/coord/Axis.js +34 -2
- package/lib/coord/axisDefault.js +2 -1
- package/lib/coord/axisHelper.js +6 -25
- package/lib/coord/axisModelCommonMixin.js +1 -1
- package/lib/coord/calendar/Calendar.js +14 -17
- package/lib/coord/calendar/prepareCustom.js +31 -0
- package/lib/coord/cartesian/Axis2D.js +0 -12
- package/lib/coord/cartesian/Cartesian2D.js +1 -0
- package/lib/coord/cartesian/Grid.js +5 -2
- package/lib/coord/cartesian/prepareCustom.js +36 -0
- package/lib/coord/geo/Geo.js +9 -14
- package/lib/coord/geo/GeoModel.js +5 -5
- package/lib/coord/geo/geoCreator.js +3 -3
- package/lib/coord/geo/prepareCustom.js +36 -0
- package/lib/coord/parallel/Parallel.js +12 -11
- package/lib/coord/polar/Polar.js +2 -1
- package/lib/coord/polar/prepareCustom.js +53 -0
- package/lib/coord/single/Single.js +9 -8
- package/lib/coord/single/SingleAxis.js +0 -27
- package/lib/coord/single/prepareCustom.js +33 -0
- package/lib/data/DataDiffer.js +2 -1
- package/lib/data/Graph.js +11 -7
- package/lib/data/List.js +58 -19
- package/lib/data/helper/completeDimensions.js +184 -23
- package/lib/echarts.js +38 -33
- package/lib/helper.js +1 -8
- package/lib/layout/barGrid.js +87 -18
- package/lib/layout/barPolar.js +286 -0
- package/lib/layout/points.js +22 -16
- package/lib/model/Global.js +34 -31
- package/lib/model/Series.js +41 -29
- package/lib/model/mixin/colorPalette.js +2 -1
- package/lib/model/mixin/textStyle.js +7 -13
- package/lib/scale/Interval.js +21 -14
- package/lib/scale/Log.js +5 -7
- package/lib/scale/Time.js +13 -7
- package/lib/scale/helper.js +5 -1
- package/lib/util/format.js +12 -0
- package/lib/util/graphic.js +53 -1
- package/lib/util/model.js +63 -7
- package/map/js/world.js +1 -1
- package/map/json/world.json +1 -1
- package/package.json +3 -3
- package/src/chart/bar/BarView.js +141 -49
- package/src/chart/bar/BaseBarSeries.js +2 -6
- package/src/chart/bar.js +1 -0
- package/src/chart/boxplot/BoxplotSeries.js +1 -1
- package/src/chart/boxplot/boxplotLayout.js +23 -7
- package/src/chart/candlestick/CandlestickSeries.js +1 -21
- package/src/chart/candlestick/candlestickLayout.js +23 -7
- package/src/chart/custom.js +442 -0
- package/src/chart/graph/categoryVisual.js +3 -2
- package/src/chart/heatmap/HeatmapView.js +75 -73
- package/src/chart/helper/Symbol.js +8 -31
- package/src/chart/helper/createListFromArray.js +15 -10
- package/src/chart/helper/labelHelper.js +49 -0
- package/src/chart/helper/whiskerBoxCommon.js +25 -44
- package/src/chart/map/mapDataStatistic.js +9 -8
- package/src/chart/pie/pieLayout.js +25 -17
- package/src/chart/radar/RadarSeries.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -3
- package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/src/chart/themeRiver/themeRiverVisual.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +3 -3
- package/src/component/axisPointer/BaseAxisPointer.js +7 -6
- package/src/component/axisPointer/axisTrigger.js +62 -51
- package/src/component/axisPointer.js +1 -2
- package/src/component/calendar/CalendarView.js +5 -5
- package/src/component/dataZoom/AxisProxy.js +76 -13
- package/src/component/dataZoom/DataZoomModel.js +21 -5
- package/src/component/dataZoom/InsideZoomModel.js +4 -1
- package/src/component/dataZoom/InsideZoomView.js +16 -26
- package/src/component/dataZoom/SliderZoomView.js +63 -26
- package/src/component/dataZoom/roams.js +8 -3
- package/src/component/graphic.js +13 -12
- package/src/component/helper/BrushTargetManager.js +5 -5
- package/src/component/helper/MapDraw.js +3 -3
- package/src/component/helper/RoamController.js +43 -20
- package/src/component/helper/brushHelper.js +2 -13
- package/src/component/helper/selectableMixin.js +7 -7
- package/src/component/helper/sliderMove.js +65 -36
- package/src/component/legend/LegendView.js +6 -6
- package/src/component/legend/legendAction.js +1 -1
- package/src/component/marker/MarkAreaView.js +3 -6
- package/src/component/marker/MarkLineView.js +3 -5
- package/src/component/marker/MarkPointView.js +3 -5
- package/src/component/marker/MarkerView.js +10 -12
- package/src/component/polar.js +5 -0
- package/src/component/timeline/SliderTimelineView.js +1 -1
- package/src/component/toolbox/feature/DataZoom.js +14 -1
- package/src/component/tooltip/TooltipView.js +3 -3
- package/src/component/visualMap/ContinuousView.js +6 -4
- package/src/coord/Axis.js +34 -2
- package/src/coord/axisDefault.js +2 -1
- package/src/coord/axisHelper.js +6 -25
- package/src/coord/axisModelCommonMixin.js +1 -1
- package/src/coord/calendar/Calendar.js +14 -17
- package/src/coord/calendar/prepareCustom.js +32 -0
- package/src/coord/cartesian/Axis2D.js +0 -12
- package/src/coord/cartesian/Cartesian2D.js +1 -0
- package/src/coord/cartesian/Grid.js +5 -2
- package/src/coord/cartesian/prepareCustom.js +37 -0
- package/src/coord/geo/Geo.js +9 -14
- package/src/coord/geo/GeoModel.js +5 -5
- package/src/coord/geo/geoCreator.js +3 -3
- package/src/coord/geo/prepareCustom.js +37 -0
- package/src/coord/parallel/Parallel.js +12 -11
- package/src/coord/polar/Polar.js +2 -1
- package/src/coord/polar/prepareCustom.js +54 -0
- package/src/coord/single/Single.js +9 -8
- package/src/coord/single/SingleAxis.js +0 -27
- package/src/coord/single/prepareCustom.js +34 -0
- package/src/data/DataDiffer.js +2 -1
- package/src/data/Graph.js +11 -7
- package/src/data/List.js +58 -19
- package/src/data/helper/completeDimensions.js +184 -23
- package/src/echarts.js +38 -33
- package/src/helper.js +1 -8
- package/src/layout/barGrid.js +87 -18
- package/src/layout/barPolar.js +287 -0
- package/src/layout/points.js +22 -16
- package/src/model/Global.js +34 -31
- package/src/model/Series.js +41 -29
- package/src/model/mixin/colorPalette.js +2 -1
- package/src/model/mixin/textStyle.js +7 -13
- package/src/scale/Interval.js +21 -14
- package/src/scale/Log.js +5 -7
- package/src/scale/Time.js +13 -7
- package/src/scale/helper.js +5 -1
- package/src/util/format.js +12 -0
- package/src/util/graphic.js +53 -1
- package/src/util/model.js +63 -7
- package/src/coord/cartesian/axisLabelInterval.js +0 -26
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
|
-
|
|
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 (!
|
|
228
|
-
throw new Error('
|
|
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
|
|
275
|
-
|
|
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[
|
|
320
|
+
dimStorage[i] = dimValueGetter(dataItem, dim, i, k);
|
|
289
321
|
}
|
|
290
322
|
|
|
291
|
-
indices.push(
|
|
323
|
+
indices.push(i);
|
|
292
324
|
}
|
|
293
325
|
|
|
294
326
|
// Use the name in option and create id
|
|
295
|
-
for (var i = 0; i <
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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 =
|
|
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]
|
|
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 @@ define(function (require) {
|
|
|
598
634
|
* @return {number}
|
|
599
635
|
*/
|
|
600
636
|
listProto.getRawDataItem = function (idx) {
|
|
601
|
-
return this._rawData
|
|
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
|
|
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
|
|
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
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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(
|
|
19
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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 (
|
|
220
|
+
else if (isString(value) && value !== '-') {
|
|
60
221
|
return true;
|
|
61
222
|
}
|
|
62
223
|
}
|
package/src/echarts.js
CHANGED
|
@@ -276,14 +276,7 @@ define(function (require) {
|
|
|
276
276
|
ecModel.init(null, null, theme, optionManager);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
|
|
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 @@ define(function (require) {
|
|
|
809
802
|
|
|
810
803
|
prepareView.call(this, 'chart', ecModel);
|
|
811
804
|
|
|
812
|
-
|
|
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 @@ define(function (require) {
|
|
|
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 @@ define(function (require) {
|
|
|
1206
1185
|
var data = series.getData();
|
|
1207
1186
|
if (stack && data.type === 'list') {
|
|
1208
1187
|
var previousStack = stackedDataMap[stack];
|
|
1209
|
-
|
|
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 @@ define(function (require) {
|
|
|
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 @@ define(function (require) {
|
|
|
1535
1516
|
/**
|
|
1536
1517
|
* @type {number}
|
|
1537
1518
|
*/
|
|
1538
|
-
version: '3.
|
|
1519
|
+
version: '3.6.0',
|
|
1539
1520
|
dependencies: {
|
|
1540
|
-
zrender: '3.
|
|
1521
|
+
zrender: '3.5.0'
|
|
1541
1522
|
}
|
|
1542
1523
|
};
|
|
1543
1524
|
|
|
@@ -1604,9 +1585,21 @@ define(function (require) {
|
|
|
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 @@ define(function (require) {
|
|
|
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 @@ define(function (require) {
|
|
|
1671
1668
|
* @param {module:echarts~ECharts|HTMLDomElement|string} chart
|
|
1672
1669
|
*/
|
|
1673
1670
|
echarts.dispose = function (chart) {
|
|
1674
|
-
if (
|
|
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 @@ define(function (require) {
|
|
|
1687
1685
|
* @return {echarts~ECharts}
|
|
1688
1686
|
*/
|
|
1689
1687
|
echarts.getInstanceByDom = function (dom) {
|
|
1690
|
-
var 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/src/helper.js
CHANGED
|
@@ -19,14 +19,7 @@ define(function (require) {
|
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
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
|
|