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.
- package/LICENSE +21 -18
- package/README.md +10 -0
- package/dist/echarts.common.js +11010 -9830
- package/dist/echarts.common.min.js +13 -13
- package/dist/echarts.js +13291 -10852
- package/dist/echarts.min.js +22 -21
- package/dist/echarts.simple.js +9904 -8990
- package/dist/echarts.simple.min.js +9 -10
- package/index.js +1 -0
- package/lib/ExtensionAPI.js +2 -4
- 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 +3 -22
- package/lib/chart/candlestick/candlestickLayout.js +23 -7
- package/lib/chart/custom.js +442 -0
- package/lib/chart/funnel/funnelLayout.js +10 -3
- package/lib/chart/gauge/GaugeView.js +1 -1
- package/lib/chart/graph/GraphView.js +15 -9
- package/lib/chart/graph/categoryVisual.js +3 -2
- package/lib/chart/heatmap/HeatmapLayer.js +1 -1
- 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/parallel/ParallelSeries.js +2 -0
- package/lib/chart/parallel/ParallelView.js +13 -12
- package/lib/chart/parallel/parallelVisual.js +9 -1
- package/lib/chart/pie/pieLayout.js +25 -17
- package/lib/chart/radar/RadarSeries.js +1 -1
- package/lib/chart/sankey/sankeyLayout.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/chart/treemap/TreemapView.js +1 -1
- package/lib/chart/treemap/treemapLayout.js +6 -1
- package/lib/component/axis/AxisBuilder.js +53 -34
- package/lib/component/axis/ParallelAxisView.js +45 -37
- package/lib/component/axisPointer/AxisPointerModel.js +1 -1
- package/lib/component/axisPointer/BaseAxisPointer.js +20 -15
- package/lib/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/lib/component/axisPointer/PolarAxisPointer.js +10 -8
- package/lib/component/axisPointer/SingleAxisPointer.js +11 -7
- package/lib/component/axisPointer/axisTrigger.js +87 -72
- package/lib/component/axisPointer/viewHelper.js +6 -3
- package/lib/component/axisPointer.js +2 -2
- package/lib/component/brush/BrushModel.js +6 -4
- package/lib/component/brush/BrushView.js +1 -1
- package/lib/component/brush/visualEncoding.js +6 -4
- 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 +17 -27
- package/lib/component/dataZoom/SliderZoomView.js +63 -26
- package/lib/component/dataZoom/roams.js +9 -4
- package/lib/component/graphic.js +13 -12
- package/lib/component/helper/BrushController.js +75 -114
- package/lib/component/helper/BrushTargetManager.js +16 -8
- package/lib/component/helper/MapDraw.js +25 -11
- package/lib/component/helper/RoamController.js +111 -139
- package/lib/component/helper/brushHelper.js +25 -213
- package/lib/component/helper/cursorHelper.js +21 -0
- package/lib/component/helper/roamHelper.js +54 -0
- package/lib/component/helper/selectableMixin.js +7 -7
- package/lib/component/helper/sliderMove.js +66 -37
- 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/marker/markerHelper.js +1 -1
- package/lib/component/parallel.js +94 -29
- package/lib/component/polar.js +5 -0
- package/lib/component/timeline/SliderTimelineView.js +1 -1
- package/lib/component/toolbox/feature/Brush.js +7 -0
- package/lib/component/toolbox/feature/DataZoom.js +17 -4
- package/lib/component/tooltip/TooltipView.js +92 -20
- package/lib/component/visualMap/ContinuousView.js +6 -4
- package/lib/coord/Axis.js +34 -2
- package/lib/coord/axisDefault.js +4 -1
- package/lib/coord/axisHelper.js +32 -26
- 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/parseGeoJson.js +11 -4
- package/lib/coord/geo/prepareCustom.js +36 -0
- package/lib/coord/parallel/Parallel.js +225 -101
- package/lib/coord/parallel/ParallelModel.js +7 -1
- 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 +59 -20
- package/lib/data/helper/completeDimensions.js +184 -23
- package/lib/echarts.js +68 -36
- package/lib/helper.js +1 -8
- package/lib/layout/barGrid.js +91 -19
- 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/globalDefault.js +4 -1
- package/lib/model/mixin/colorPalette.js +2 -1
- package/lib/model/mixin/textStyle.js +7 -13
- package/lib/scale/Interval.js +46 -76
- package/lib/scale/Log.js +5 -7
- package/lib/scale/Scale.js +10 -1
- package/lib/scale/Time.js +34 -12
- package/lib/scale/helper.js +93 -0
- package/lib/util/format.js +20 -9
- package/lib/util/graphic.js +70 -8
- package/lib/util/layout.js +7 -3
- package/lib/util/model.js +63 -7
- package/lib/util/number.js +59 -19
- package/lib/util/throttle.js +14 -3
- package/map/js/world.js +1 -1
- package/map/json/world.json +1 -1
- package/package.json +3 -3
- package/src/ExtensionAPI.js +2 -4
- 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 +3 -22
- package/src/chart/candlestick/candlestickLayout.js +23 -7
- package/src/chart/custom.js +442 -0
- package/src/chart/funnel/funnelLayout.js +10 -4
- package/src/chart/gauge/GaugeView.js +1 -1
- package/src/chart/graph/GraphView.js +15 -9
- package/src/chart/graph/categoryVisual.js +3 -2
- package/src/chart/heatmap/HeatmapLayer.js +1 -1
- 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/parallel/ParallelSeries.js +2 -0
- package/src/chart/parallel/ParallelView.js +13 -12
- package/src/chart/parallel/parallelVisual.js +9 -1
- package/src/chart/pie/pieLayout.js +25 -17
- package/src/chart/radar/RadarSeries.js +1 -1
- package/src/chart/sankey/sankeyLayout.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/chart/treemap/TreemapView.js +1 -1
- package/src/chart/treemap/treemapLayout.js +6 -1
- package/src/component/axis/AxisBuilder.js +53 -34
- package/src/component/axis/ParallelAxisView.js +45 -37
- package/src/component/axisPointer/AxisPointerModel.js +1 -1
- package/src/component/axisPointer/BaseAxisPointer.js +20 -15
- package/src/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/src/component/axisPointer/PolarAxisPointer.js +10 -8
- package/src/component/axisPointer/SingleAxisPointer.js +11 -7
- package/src/component/axisPointer/axisTrigger.js +87 -72
- package/src/component/axisPointer/viewHelper.js +6 -3
- package/src/component/axisPointer.js +2 -2
- package/src/component/brush/BrushModel.js +6 -4
- package/src/component/brush/BrushView.js +1 -1
- package/src/component/brush/visualEncoding.js +6 -4
- 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 +17 -27
- package/src/component/dataZoom/SliderZoomView.js +63 -26
- package/src/component/dataZoom/roams.js +9 -4
- package/src/component/graphic.js +13 -12
- package/src/component/helper/BrushController.js +75 -114
- package/src/component/helper/BrushTargetManager.js +16 -8
- package/src/component/helper/MapDraw.js +25 -11
- package/src/component/helper/RoamController.js +111 -139
- package/src/component/helper/brushHelper.js +41 -0
- package/src/component/helper/cursorHelper.js +22 -0
- package/src/component/helper/roamHelper.js +55 -0
- package/src/component/helper/selectableMixin.js +7 -7
- package/src/component/helper/sliderMove.js +66 -37
- 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/marker/markerHelper.js +1 -1
- package/src/component/parallel.js +94 -29
- package/src/component/polar.js +5 -0
- package/src/component/timeline/SliderTimelineView.js +1 -1
- package/src/component/toolbox/feature/Brush.js +7 -0
- package/src/component/toolbox/feature/DataZoom.js +17 -4
- package/src/component/tooltip/TooltipView.js +92 -20
- package/src/component/visualMap/ContinuousView.js +6 -4
- package/src/coord/Axis.js +34 -2
- package/src/coord/axisDefault.js +4 -1
- package/src/coord/axisHelper.js +32 -26
- 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/parseGeoJson.js +11 -4
- package/src/coord/geo/prepareCustom.js +37 -0
- package/src/coord/parallel/Parallel.js +225 -101
- package/src/coord/parallel/ParallelModel.js +7 -1
- 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 +59 -20
- package/src/data/helper/completeDimensions.js +184 -23
- package/src/echarts.js +68 -36
- package/src/helper.js +1 -8
- package/src/layout/barGrid.js +91 -19
- 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/globalDefault.js +4 -1
- package/src/model/mixin/colorPalette.js +2 -1
- package/src/model/mixin/textStyle.js +7 -13
- package/src/scale/Interval.js +46 -76
- package/src/scale/Log.js +5 -7
- package/src/scale/Scale.js +10 -1
- package/src/scale/Time.js +34 -12
- package/src/scale/helper.js +94 -0
- package/src/util/format.js +20 -9
- package/src/util/graphic.js +70 -8
- package/src/util/layout.js +7 -3
- package/src/util/model.js +63 -7
- package/src/util/number.js +59 -19
- package/src/util/throttle.js +14 -3
- package/src/coord/cartesian/axisLabelInterval.js +0 -26
- package/theme/default.js +0 -23
- package/theme/halloween.js +0 -528
package/src/data/DataDiffer.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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
|
-
|
|
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];
|
|
@@ -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.
|
|
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
|
|
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
|
}
|