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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
var zrUtil = require('zrender/lib/core/util');
|
|
4
|
+
|
|
5
|
+
function dataToCoordSize(dataSize, dataItem) {
|
|
6
|
+
// dataItem is necessary in log axis.
|
|
7
|
+
return zrUtil.map(['Radius', 'Angle'], function (dim, dimIdx) {
|
|
8
|
+
var axis = this['get' + dim + 'Axis']();
|
|
9
|
+
var val = dataItem[dimIdx];
|
|
10
|
+
var halfSize = dataSize[dimIdx] / 2;
|
|
11
|
+
var method = 'dataTo' + dim;
|
|
12
|
+
|
|
13
|
+
var result = axis.type === 'category'
|
|
14
|
+
? axis.getBandWidth()
|
|
15
|
+
: Math.abs(axis[method](val - halfSize) - axis[method](val + halfSize));
|
|
16
|
+
|
|
17
|
+
if (dim === 'Angle') {
|
|
18
|
+
result = result * Math.PI / 180;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
|
|
23
|
+
}, this);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function prepareCustom(coordSys) {
|
|
27
|
+
var radiusAxis = coordSys.getRadiusAxis();
|
|
28
|
+
var angleAxis = coordSys.getAngleAxis();
|
|
29
|
+
var radius = radiusAxis.getExtent();
|
|
30
|
+
radius[0] > radius[1] && radius.reverse();
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
coordSys: {
|
|
34
|
+
type: 'polar',
|
|
35
|
+
cx: coordSys.cx,
|
|
36
|
+
cy: coordSys.cy,
|
|
37
|
+
r: radius[1],
|
|
38
|
+
r0: radius[0]
|
|
39
|
+
},
|
|
40
|
+
api: {
|
|
41
|
+
coord: zrUtil.bind(function (data) {
|
|
42
|
+
var radius = radiusAxis.dataToRadius(data[0]);
|
|
43
|
+
var angle = angleAxis.dataToAngle(data[1]);
|
|
44
|
+
var coord = coordSys.coordToPoint([radius, angle]);
|
|
45
|
+
coord.push(radius, angle * Math.PI / 180);
|
|
46
|
+
return coord;
|
|
47
|
+
}),
|
|
48
|
+
size: zrUtil.bind(dataToCoordSize, coordSys)
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = prepareCustom;
|
|
@@ -167,19 +167,19 @@
|
|
|
167
167
|
var extentSum = axisExtent[0] + axisExtent[1];
|
|
168
168
|
var isHorizontal = axis.isHorizontal();
|
|
169
169
|
|
|
170
|
-
axis.toGlobalCoord = isHorizontal
|
|
171
|
-
function (coord) {
|
|
170
|
+
axis.toGlobalCoord = isHorizontal
|
|
171
|
+
? function (coord) {
|
|
172
172
|
return coord + coordBase;
|
|
173
|
-
}
|
|
174
|
-
function (coord) {
|
|
173
|
+
}
|
|
174
|
+
: function (coord) {
|
|
175
175
|
return extentSum - coord + coordBase;
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
axis.toLocalCoord = isHorizontal
|
|
179
|
-
function (coord) {
|
|
178
|
+
axis.toLocalCoord = isHorizontal
|
|
179
|
+
? function (coord) {
|
|
180
180
|
return coord - coordBase;
|
|
181
|
-
}
|
|
182
|
-
function (coord) {
|
|
181
|
+
}
|
|
182
|
+
: function (coord) {
|
|
183
183
|
return extentSum - coord + coordBase;
|
|
184
184
|
};
|
|
185
185
|
},
|
|
@@ -267,6 +267,7 @@
|
|
|
267
267
|
pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
|
|
268
268
|
return pt;
|
|
269
269
|
}
|
|
270
|
+
|
|
270
271
|
};
|
|
271
272
|
|
|
272
273
|
module.exports = Single;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var zrUtil = require('zrender/lib/core/util');
|
|
4
4
|
var Axis = require('../Axis');
|
|
5
|
-
var axisHelper = require('../axisHelper');
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* @constructor module:echarts/coord/single/SingleAxis
|
|
@@ -72,32 +71,6 @@
|
|
|
72
71
|
|
|
73
72
|
},
|
|
74
73
|
|
|
75
|
-
/**
|
|
76
|
-
* Get interval of the axis label.
|
|
77
|
-
* @return {number}
|
|
78
|
-
*/
|
|
79
|
-
getLabelInterval: function () {
|
|
80
|
-
var labelInterval = this._labelInterval;
|
|
81
|
-
if (!labelInterval) {
|
|
82
|
-
var axisModel = this.model;
|
|
83
|
-
var labelModel = axisModel.getModel('axisLabel');
|
|
84
|
-
var interval = labelModel.get('interval');
|
|
85
|
-
if (!(this.type === 'category' && interval === 'auto')) {
|
|
86
|
-
|
|
87
|
-
labelInterval = this._labelInterval = interval === 'auto' ? 0 : interval;
|
|
88
|
-
return labelInterval;
|
|
89
|
-
}
|
|
90
|
-
labelInterval = this._labelInterval =
|
|
91
|
-
axisHelper.getAxisLabelInterval(
|
|
92
|
-
zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
|
|
93
|
-
axisModel.getFormattedLabels(),
|
|
94
|
-
labelModel.getModel('textStyle').getFont(),
|
|
95
|
-
this.isHorizontal()
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
return labelInterval;
|
|
99
|
-
},
|
|
100
|
-
|
|
101
74
|
/**
|
|
102
75
|
* @override
|
|
103
76
|
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
var zrUtil = require('zrender/lib/core/util');
|
|
4
|
+
|
|
5
|
+
function dataToCoordSize(dataSize, dataItem) {
|
|
6
|
+
// dataItem is necessary in log axis.
|
|
7
|
+
var axis = this.getAxis();
|
|
8
|
+
var val = dataItem instanceof Array ? dataItem[0] : dataItem;
|
|
9
|
+
var halfSize = (dataSize instanceof Array ? dataSize[0] : dataSize) / 2;
|
|
10
|
+
return axis.type === 'category'
|
|
11
|
+
? axis.getBandWidth()
|
|
12
|
+
: Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function prepareCustom(coordSys) {
|
|
16
|
+
var rect = coordSys.getRect();
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
coordSys: {
|
|
20
|
+
type: 'singleAxis',
|
|
21
|
+
x: rect.x,
|
|
22
|
+
y: rect.y,
|
|
23
|
+
width: rect.width,
|
|
24
|
+
height: rect.height
|
|
25
|
+
},
|
|
26
|
+
api: {
|
|
27
|
+
coord: zrUtil.bind(coordSys.dataToPoint, coordSys),
|
|
28
|
+
size: zrUtil.bind(dataToCoordSize, coordSys)
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = prepareCustom;
|
package/lib/data/DataDiffer.js
CHANGED
|
@@ -105,7 +105,8 @@
|
|
|
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/lib/data/Graph.js
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
var zrUtil = require('zrender/lib/core/util');
|
|
11
11
|
|
|
12
|
+
// id may be function name of Object, add a prefix to avoid this problem.
|
|
13
|
+
function generateNodeKey (id) {
|
|
14
|
+
return '_EC_' + id;
|
|
15
|
+
}
|
|
12
16
|
/**
|
|
13
17
|
* @alias module:echarts/data/Graph
|
|
14
18
|
* @constructor
|
|
@@ -82,7 +86,7 @@
|
|
|
82
86
|
|
|
83
87
|
var nodesMap = this._nodesMap;
|
|
84
88
|
|
|
85
|
-
if (nodesMap[id]) {
|
|
89
|
+
if (nodesMap[generateNodeKey(id)]) {
|
|
86
90
|
return;
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -91,7 +95,7 @@
|
|
|
91
95
|
|
|
92
96
|
this.nodes.push(node);
|
|
93
97
|
|
|
94
|
-
nodesMap[id] = node;
|
|
98
|
+
nodesMap[generateNodeKey(id)] = node;
|
|
95
99
|
return node;
|
|
96
100
|
};
|
|
97
101
|
|
|
@@ -110,7 +114,7 @@
|
|
|
110
114
|
* @return {module:echarts/data/Graph.Node}
|
|
111
115
|
*/
|
|
112
116
|
graphProto.getNodeById = function (id) {
|
|
113
|
-
return this._nodesMap[id];
|
|
117
|
+
return this._nodesMap[generateNodeKey(id)];
|
|
114
118
|
};
|
|
115
119
|
|
|
116
120
|
/**
|
|
@@ -133,10 +137,10 @@
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
if (!(n1 instanceof Node)) {
|
|
136
|
-
n1 = nodesMap[n1];
|
|
140
|
+
n1 = nodesMap[generateNodeKey(n1)];
|
|
137
141
|
}
|
|
138
142
|
if (!(n2 instanceof Node)) {
|
|
139
|
-
n2 = nodesMap[n2];
|
|
143
|
+
n2 = nodesMap[generateNodeKey(n2)];
|
|
140
144
|
}
|
|
141
145
|
if (!n1 || !n2) {
|
|
142
146
|
return;
|
|
@@ -243,7 +247,7 @@
|
|
|
243
247
|
cb, startNode, direction, context
|
|
244
248
|
) {
|
|
245
249
|
if (!(startNode instanceof Node)) {
|
|
246
|
-
startNode = this._nodesMap[startNode];
|
|
250
|
+
startNode = this._nodesMap[generateNodeKey(startNode)];
|
|
247
251
|
}
|
|
248
252
|
if (!startNode) {
|
|
249
253
|
return;
|
|
@@ -270,7 +274,7 @@
|
|
|
270
274
|
var otherNode = e.node1 === currentNode
|
|
271
275
|
? e.node2 : e.node1;
|
|
272
276
|
if (!otherNode.__visited) {
|
|
273
|
-
if (cb.call(
|
|
277
|
+
if (cb.call(context, otherNode, currentNode)) {
|
|
274
278
|
// Stop traversing
|
|
275
279
|
return;
|
|
276
280
|
}
|
package/lib/data/List.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
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 @@
|
|
|
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 (!
|
|
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 @@
|
|
|
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
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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];
|