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,287 @@
|
|
|
1
|
+
define(function (require) {
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var zrUtil = require('zrender/core/util');
|
|
6
|
+
var parsePercent = require('../util/number').parsePercent;
|
|
7
|
+
|
|
8
|
+
function getSeriesStackId(seriesModel) {
|
|
9
|
+
return seriesModel.get('stack')
|
|
10
|
+
|| '__ec_stack_' + seriesModel.seriesIndex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getAxisKey(axis) {
|
|
14
|
+
return axis.dim;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} seriesType
|
|
19
|
+
* @param {module:echarts/model/Global} ecModel
|
|
20
|
+
* @param {module:echarts/ExtensionAPI} api
|
|
21
|
+
*/
|
|
22
|
+
function barLayoutPolar(seriesType, ecModel, api) {
|
|
23
|
+
|
|
24
|
+
var width = api.getWidth();
|
|
25
|
+
var height = api.getHeight();
|
|
26
|
+
|
|
27
|
+
var lastStackCoords = {};
|
|
28
|
+
var lastStackCoordsOrigin = {};
|
|
29
|
+
|
|
30
|
+
var barWidthAndOffset = calRadialBar(
|
|
31
|
+
zrUtil.filter(
|
|
32
|
+
ecModel.getSeriesByType(seriesType),
|
|
33
|
+
function (seriesModel) {
|
|
34
|
+
return !ecModel.isSeriesFiltered(seriesModel)
|
|
35
|
+
&& seriesModel.coordinateSystem
|
|
36
|
+
&& seriesModel.coordinateSystem.type === 'polar';
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
42
|
+
// Check series coordinate, do layout for polar only
|
|
43
|
+
if (seriesModel.coordinateSystem.type !== 'polar') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var data = seriesModel.getData();
|
|
48
|
+
var polar = seriesModel.coordinateSystem;
|
|
49
|
+
var angleAxis = polar.getAngleAxis();
|
|
50
|
+
var baseAxis = polar.getBaseAxis();
|
|
51
|
+
|
|
52
|
+
var stackId = getSeriesStackId(seriesModel);
|
|
53
|
+
var columnLayoutInfo
|
|
54
|
+
= barWidthAndOffset[getAxisKey(baseAxis)][stackId];
|
|
55
|
+
var columnOffset = columnLayoutInfo.offset;
|
|
56
|
+
var columnWidth = columnLayoutInfo.width;
|
|
57
|
+
var valueAxis = polar.getOtherAxis(baseAxis);
|
|
58
|
+
|
|
59
|
+
var center = seriesModel.get('center') || ['50%', '50%'];
|
|
60
|
+
var cx = parsePercent(center[0], width);
|
|
61
|
+
var cy = parsePercent(center[1], height);
|
|
62
|
+
|
|
63
|
+
var barMinHeight = seriesModel.get('barMinHeight') || 0;
|
|
64
|
+
var barMinAngle = seriesModel.get('barMinAngle') || 0;
|
|
65
|
+
|
|
66
|
+
var valueAxisStart = valueAxis.getExtent()[0];
|
|
67
|
+
var valueMax = valueAxis.model.get('max');
|
|
68
|
+
var valueMin = valueAxis.model.get('min');
|
|
69
|
+
|
|
70
|
+
var coords = polar.dataToPoints(data);
|
|
71
|
+
lastStackCoords[stackId] = lastStackCoords[stackId] || [];
|
|
72
|
+
lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
|
|
73
|
+
|
|
74
|
+
data.each(valueAxis.dim, function (value, idx) {
|
|
75
|
+
if (isNaN(value)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!lastStackCoords[stackId][idx]) {
|
|
80
|
+
lastStackCoords[stackId][idx] = {
|
|
81
|
+
p: valueAxisStart, // Positive stack
|
|
82
|
+
n: valueAxisStart // Negative stack
|
|
83
|
+
};
|
|
84
|
+
lastStackCoordsOrigin[stackId][idx] = {
|
|
85
|
+
p: valueAxisStart, // Positive stack
|
|
86
|
+
n: valueAxisStart // Negative stack
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var sign = value >= 0 ? 'p' : 'n';
|
|
90
|
+
var coord = polar.pointToCoord(coords[idx]);
|
|
91
|
+
|
|
92
|
+
var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
|
|
93
|
+
var r0;
|
|
94
|
+
var r;
|
|
95
|
+
var startAngle;
|
|
96
|
+
var endAngle;
|
|
97
|
+
|
|
98
|
+
if (valueAxis.dim === 'radius') {
|
|
99
|
+
// radial sector
|
|
100
|
+
r0 = lastCoordOrigin;
|
|
101
|
+
r = coord[0];
|
|
102
|
+
startAngle = (-coord[1] + columnOffset) * Math.PI / 180;
|
|
103
|
+
endAngle = startAngle + columnWidth * Math.PI / 180;
|
|
104
|
+
|
|
105
|
+
if (Math.abs(r) < barMinHeight) {
|
|
106
|
+
r = r0 + (r < 0 ? -1 : 1) * barMinHeight;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
lastStackCoordsOrigin[stackId][idx][sign] = r;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// tangential sector
|
|
113
|
+
r0 = coord[0] + columnOffset;
|
|
114
|
+
r = r0 + columnWidth;
|
|
115
|
+
|
|
116
|
+
// clamp data if min or max is defined for valueAxis
|
|
117
|
+
if (valueMax != null) {
|
|
118
|
+
value = Math.min(value, valueMax);
|
|
119
|
+
}
|
|
120
|
+
if (valueMin != null) {
|
|
121
|
+
value = Math.max(value, valueMin);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var angle = angleAxis.dataToAngle(value);
|
|
125
|
+
if (Math.abs(angle - lastCoordOrigin) < barMinAngle) {
|
|
126
|
+
angle = lastCoordOrigin - (value < 0 ? -1 : 1)
|
|
127
|
+
* barMinAngle;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
startAngle = -lastCoordOrigin * Math.PI / 180;
|
|
131
|
+
endAngle = -angle * Math.PI / 180;
|
|
132
|
+
|
|
133
|
+
// if the previous stack is at the end of the ring,
|
|
134
|
+
// add a round to differentiate it from origin
|
|
135
|
+
var extent = angleAxis.getExtent();
|
|
136
|
+
var stackCoord = angle;
|
|
137
|
+
if (stackCoord === extent[0] && value > 0) {
|
|
138
|
+
stackCoord = extent[1];
|
|
139
|
+
}
|
|
140
|
+
else if (stackCoord === extent[1] && value < 0) {
|
|
141
|
+
stackCoord = extent[0];
|
|
142
|
+
}
|
|
143
|
+
lastStackCoordsOrigin[stackId][idx][sign] = stackCoord;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
data.setItemLayout(idx, {
|
|
147
|
+
cx: cx,
|
|
148
|
+
cy: cy,
|
|
149
|
+
r0: r0,
|
|
150
|
+
r: r,
|
|
151
|
+
startAngle: startAngle,
|
|
152
|
+
endAngle: endAngle
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
}, true);
|
|
156
|
+
|
|
157
|
+
}, this);
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Calculate bar width and offset for radial bar charts
|
|
163
|
+
*/
|
|
164
|
+
function calRadialBar(barSeries, api) {
|
|
165
|
+
// Columns info on each category axis. Key is polar name
|
|
166
|
+
var columnsMap = {};
|
|
167
|
+
|
|
168
|
+
zrUtil.each(barSeries, function (seriesModel, idx) {
|
|
169
|
+
var data = seriesModel.getData();
|
|
170
|
+
var polar = seriesModel.coordinateSystem;
|
|
171
|
+
|
|
172
|
+
var baseAxis = polar.getBaseAxis();
|
|
173
|
+
|
|
174
|
+
var axisExtent = baseAxis.getExtent();
|
|
175
|
+
var bandWidth = baseAxis.type === 'category'
|
|
176
|
+
? baseAxis.getBandWidth()
|
|
177
|
+
: (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
|
|
178
|
+
|
|
179
|
+
var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
|
|
180
|
+
bandWidth: bandWidth,
|
|
181
|
+
remainedWidth: bandWidth,
|
|
182
|
+
autoWidthCount: 0,
|
|
183
|
+
categoryGap: '20%',
|
|
184
|
+
gap: '30%',
|
|
185
|
+
stacks: {}
|
|
186
|
+
};
|
|
187
|
+
var stacks = columnsOnAxis.stacks;
|
|
188
|
+
columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
|
|
189
|
+
|
|
190
|
+
var stackId = getSeriesStackId(seriesModel);
|
|
191
|
+
|
|
192
|
+
if (!stacks[stackId]) {
|
|
193
|
+
columnsOnAxis.autoWidthCount++;
|
|
194
|
+
}
|
|
195
|
+
stacks[stackId] = stacks[stackId] || {
|
|
196
|
+
width: 0,
|
|
197
|
+
maxWidth: 0
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
var barWidth = parsePercent(
|
|
201
|
+
seriesModel.get('barWidth'),
|
|
202
|
+
bandWidth
|
|
203
|
+
);
|
|
204
|
+
var barMaxWidth = parsePercent(
|
|
205
|
+
seriesModel.get('barMaxWidth'),
|
|
206
|
+
bandWidth
|
|
207
|
+
);
|
|
208
|
+
var barGap = seriesModel.get('barGap');
|
|
209
|
+
var barCategoryGap = seriesModel.get('barCategoryGap');
|
|
210
|
+
|
|
211
|
+
if (barWidth && !stacks[stackId].width) {
|
|
212
|
+
barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
|
|
213
|
+
stacks[stackId].width = barWidth;
|
|
214
|
+
columnsOnAxis.remainedWidth -= barWidth;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
|
|
218
|
+
(barGap != null) && (columnsOnAxis.gap = barGap);
|
|
219
|
+
(barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
var result = {};
|
|
224
|
+
|
|
225
|
+
zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
|
|
226
|
+
|
|
227
|
+
result[coordSysName] = {};
|
|
228
|
+
|
|
229
|
+
var stacks = columnsOnAxis.stacks;
|
|
230
|
+
var bandWidth = columnsOnAxis.bandWidth;
|
|
231
|
+
var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
|
|
232
|
+
var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
|
|
233
|
+
|
|
234
|
+
var remainedWidth = columnsOnAxis.remainedWidth;
|
|
235
|
+
var autoWidthCount = columnsOnAxis.autoWidthCount;
|
|
236
|
+
var autoWidth = (remainedWidth - categoryGap)
|
|
237
|
+
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
|
|
238
|
+
autoWidth = Math.max(autoWidth, 0);
|
|
239
|
+
|
|
240
|
+
// Find if any auto calculated bar exceeded maxBarWidth
|
|
241
|
+
zrUtil.each(stacks, function (column, stack) {
|
|
242
|
+
var maxWidth = column.maxWidth;
|
|
243
|
+
if (maxWidth && maxWidth < autoWidth) {
|
|
244
|
+
maxWidth = Math.min(maxWidth, remainedWidth);
|
|
245
|
+
if (column.width) {
|
|
246
|
+
maxWidth = Math.min(maxWidth, column.width);
|
|
247
|
+
}
|
|
248
|
+
remainedWidth -= maxWidth;
|
|
249
|
+
column.width = maxWidth;
|
|
250
|
+
autoWidthCount--;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Recalculate width again
|
|
255
|
+
autoWidth = (remainedWidth - categoryGap)
|
|
256
|
+
/ (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
|
|
257
|
+
autoWidth = Math.max(autoWidth, 0);
|
|
258
|
+
|
|
259
|
+
var widthSum = 0;
|
|
260
|
+
var lastColumn;
|
|
261
|
+
zrUtil.each(stacks, function (column, idx) {
|
|
262
|
+
if (!column.width) {
|
|
263
|
+
column.width = autoWidth;
|
|
264
|
+
}
|
|
265
|
+
lastColumn = column;
|
|
266
|
+
widthSum += column.width * (1 + barGapPercent);
|
|
267
|
+
});
|
|
268
|
+
if (lastColumn) {
|
|
269
|
+
widthSum -= lastColumn.width * barGapPercent;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
var offset = -widthSum / 2;
|
|
273
|
+
zrUtil.each(stacks, function (column, stackId) {
|
|
274
|
+
result[coordSysName][stackId] = result[coordSysName][stackId] || {
|
|
275
|
+
offset: offset,
|
|
276
|
+
width: column.width
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
offset += column.width * (1 + barGapPercent);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return barLayoutPolar;
|
|
287
|
+
});
|
package/src/layout/points.js
CHANGED
|
@@ -5,23 +5,29 @@ define(function (require) {
|
|
|
5
5
|
var data = seriesModel.getData();
|
|
6
6
|
var coordSys = seriesModel.coordinateSystem;
|
|
7
7
|
|
|
8
|
-
if (coordSys) {
|
|
9
|
-
|
|
8
|
+
if (!coordSys) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var dims = [];
|
|
13
|
+
var coordDims = coordSys.dimensions;
|
|
14
|
+
for (var i = 0; i < coordDims.length; i++) {
|
|
15
|
+
dims.push(seriesModel.coordDimToDataDim(coordSys.dimensions[i])[0]);
|
|
16
|
+
}
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
if (dims.length === 1) {
|
|
19
|
+
data.each(dims[0], function (x, idx) {
|
|
20
|
+
// Also {Array.<number>}, not undefined to avoid if...else... statement
|
|
21
|
+
data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else if (dims.length === 2) {
|
|
25
|
+
data.each(dims, function (x, y, idx) {
|
|
26
|
+
// Also {Array.<number>}, not undefined to avoid if...else... statement
|
|
27
|
+
data.setItemLayout(
|
|
28
|
+
idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y])
|
|
29
|
+
);
|
|
30
|
+
}, true);
|
|
25
31
|
}
|
|
26
32
|
});
|
|
27
33
|
};
|
package/src/model/Global.js
CHANGED
|
@@ -63,7 +63,7 @@ define(function (require) {
|
|
|
63
63
|
this._optionManager = optionManager;
|
|
64
64
|
},
|
|
65
65
|
|
|
66
|
-
setOption: function (option, optionPreprocessorFuncs
|
|
66
|
+
setOption: function (option, optionPreprocessorFuncs) {
|
|
67
67
|
zrUtil.assert(
|
|
68
68
|
!(OPTION_INNER_KEY in option),
|
|
69
69
|
'please use chart.getOption()'
|
|
@@ -71,7 +71,7 @@ define(function (require) {
|
|
|
71
71
|
|
|
72
72
|
this._optionManager.setOption(option, optionPreprocessorFuncs);
|
|
73
73
|
|
|
74
|
-
this.resetOption(null
|
|
74
|
+
this.resetOption(null);
|
|
75
75
|
},
|
|
76
76
|
|
|
77
77
|
/**
|
|
@@ -81,7 +81,7 @@ define(function (require) {
|
|
|
81
81
|
* 'media': only reset media query option
|
|
82
82
|
* @return {boolean} Whether option changed.
|
|
83
83
|
*/
|
|
84
|
-
resetOption: function (type
|
|
84
|
+
resetOption: function (type) {
|
|
85
85
|
var optionChanged = false;
|
|
86
86
|
var optionManager = this._optionManager;
|
|
87
87
|
|
|
@@ -92,11 +92,7 @@ define(function (require) {
|
|
|
92
92
|
initBase.call(this, baseOption);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
|
|
96
|
-
// go through update process, data should not be restored.
|
|
97
|
-
// Otherwise grphic els mounted on data will be eliminated
|
|
98
|
-
// and downplay will not work.
|
|
99
|
-
!onlyGraphic && this.restoreData();
|
|
95
|
+
this.restoreData();
|
|
100
96
|
this.mergeOption(baseOption);
|
|
101
97
|
}
|
|
102
98
|
optionChanged = true;
|
|
@@ -158,7 +154,7 @@ define(function (require) {
|
|
|
158
154
|
var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
|
|
159
155
|
|
|
160
156
|
var mapResult = modelUtil.mappingToExists(
|
|
161
|
-
componentsMap
|
|
157
|
+
componentsMap.get(mainType), newCptOptionList
|
|
162
158
|
);
|
|
163
159
|
|
|
164
160
|
modelUtil.makeIdAndName(mapResult);
|
|
@@ -177,7 +173,7 @@ define(function (require) {
|
|
|
177
173
|
);
|
|
178
174
|
|
|
179
175
|
option[mainType] = [];
|
|
180
|
-
componentsMap
|
|
176
|
+
componentsMap.set(mainType, []);
|
|
181
177
|
|
|
182
178
|
each(mapResult, function (resultItem, index) {
|
|
183
179
|
var componentModel = resultItem.exist;
|
|
@@ -227,13 +223,13 @@ define(function (require) {
|
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
225
|
|
|
230
|
-
componentsMap
|
|
226
|
+
componentsMap.get(mainType)[index] = componentModel;
|
|
231
227
|
option[mainType][index] = componentModel.option;
|
|
232
228
|
}, this);
|
|
233
229
|
|
|
234
230
|
// Backup series for filtering.
|
|
235
231
|
if (mainType === 'series') {
|
|
236
|
-
this._seriesIndices = createSeriesIndices(componentsMap.series);
|
|
232
|
+
this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
235
|
},
|
|
@@ -277,7 +273,7 @@ define(function (require) {
|
|
|
277
273
|
* @return {module:echarts/model/Component}
|
|
278
274
|
*/
|
|
279
275
|
getComponent: function (mainType, idx) {
|
|
280
|
-
var list = this._componentsMap
|
|
276
|
+
var list = this._componentsMap.get(mainType);
|
|
281
277
|
if (list) {
|
|
282
278
|
return list[idx || 0];
|
|
283
279
|
}
|
|
@@ -303,7 +299,7 @@ define(function (require) {
|
|
|
303
299
|
var id = condition.id;
|
|
304
300
|
var name = condition.name;
|
|
305
301
|
|
|
306
|
-
var cpts = this._componentsMap
|
|
302
|
+
var cpts = this._componentsMap.get(mainType);
|
|
307
303
|
|
|
308
304
|
if (!cpts || !cpts.length) {
|
|
309
305
|
return [];
|
|
@@ -378,7 +374,7 @@ define(function (require) {
|
|
|
378
374
|
var queryCond = getQueryCond(query);
|
|
379
375
|
var result = queryCond
|
|
380
376
|
? this.queryComponents(queryCond)
|
|
381
|
-
: this._componentsMap
|
|
377
|
+
: this._componentsMap.get(mainType);
|
|
382
378
|
|
|
383
379
|
return doFilter(filterBySubType(result, condition));
|
|
384
380
|
|
|
@@ -437,14 +433,14 @@ define(function (require) {
|
|
|
437
433
|
if (typeof mainType === 'function') {
|
|
438
434
|
context = cb;
|
|
439
435
|
cb = mainType;
|
|
440
|
-
each(
|
|
436
|
+
componentsMap.each(function (components, componentType) {
|
|
441
437
|
each(components, function (component, index) {
|
|
442
438
|
cb.call(context, componentType, component, index);
|
|
443
439
|
});
|
|
444
440
|
});
|
|
445
441
|
}
|
|
446
442
|
else if (zrUtil.isString(mainType)) {
|
|
447
|
-
each(componentsMap
|
|
443
|
+
each(componentsMap.get(mainType), cb, context);
|
|
448
444
|
}
|
|
449
445
|
else if (isObject(mainType)) {
|
|
450
446
|
var queryResult = this.findComponents(mainType);
|
|
@@ -457,7 +453,7 @@ define(function (require) {
|
|
|
457
453
|
* @return {Array.<module:echarts/model/Series>}
|
|
458
454
|
*/
|
|
459
455
|
getSeriesByName: function (name) {
|
|
460
|
-
var series = this._componentsMap.series;
|
|
456
|
+
var series = this._componentsMap.get('series');
|
|
461
457
|
return filter(series, function (oneSeries) {
|
|
462
458
|
return oneSeries.name === name;
|
|
463
459
|
});
|
|
@@ -468,7 +464,7 @@ define(function (require) {
|
|
|
468
464
|
* @return {module:echarts/model/Series}
|
|
469
465
|
*/
|
|
470
466
|
getSeriesByIndex: function (seriesIndex) {
|
|
471
|
-
return this._componentsMap.series[seriesIndex];
|
|
467
|
+
return this._componentsMap.get('series')[seriesIndex];
|
|
472
468
|
},
|
|
473
469
|
|
|
474
470
|
/**
|
|
@@ -476,7 +472,7 @@ define(function (require) {
|
|
|
476
472
|
* @return {Array.<module:echarts/model/Series>}
|
|
477
473
|
*/
|
|
478
474
|
getSeriesByType: function (subType) {
|
|
479
|
-
var series = this._componentsMap.series;
|
|
475
|
+
var series = this._componentsMap.get('series');
|
|
480
476
|
return filter(series, function (oneSeries) {
|
|
481
477
|
return oneSeries.subType === subType;
|
|
482
478
|
});
|
|
@@ -486,7 +482,7 @@ define(function (require) {
|
|
|
486
482
|
* @return {Array.<module:echarts/model/Series>}
|
|
487
483
|
*/
|
|
488
484
|
getSeries: function () {
|
|
489
|
-
return this._componentsMap.series.slice();
|
|
485
|
+
return this._componentsMap.get('series').slice();
|
|
490
486
|
},
|
|
491
487
|
|
|
492
488
|
/**
|
|
@@ -499,7 +495,7 @@ define(function (require) {
|
|
|
499
495
|
eachSeries: function (cb, context) {
|
|
500
496
|
assertSeriesInitialized(this);
|
|
501
497
|
each(this._seriesIndices, function (rawSeriesIndex) {
|
|
502
|
-
var series = this._componentsMap.series[rawSeriesIndex];
|
|
498
|
+
var series = this._componentsMap.get('series')[rawSeriesIndex];
|
|
503
499
|
cb.call(context, series, rawSeriesIndex);
|
|
504
500
|
}, this);
|
|
505
501
|
},
|
|
@@ -511,7 +507,7 @@ define(function (require) {
|
|
|
511
507
|
* @param {*} context
|
|
512
508
|
*/
|
|
513
509
|
eachRawSeries: function (cb, context) {
|
|
514
|
-
each(this._componentsMap.series, cb, context);
|
|
510
|
+
each(this._componentsMap.get('series'), cb, context);
|
|
515
511
|
},
|
|
516
512
|
|
|
517
513
|
/**
|
|
@@ -525,7 +521,7 @@ define(function (require) {
|
|
|
525
521
|
eachSeriesByType: function (subType, cb, context) {
|
|
526
522
|
assertSeriesInitialized(this);
|
|
527
523
|
each(this._seriesIndices, function (rawSeriesIndex) {
|
|
528
|
-
var series = this._componentsMap.series[rawSeriesIndex];
|
|
524
|
+
var series = this._componentsMap.get('series')[rawSeriesIndex];
|
|
529
525
|
if (series.subType === subType) {
|
|
530
526
|
cb.call(context, series, rawSeriesIndex);
|
|
531
527
|
}
|
|
@@ -551,6 +547,13 @@ define(function (require) {
|
|
|
551
547
|
return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
|
|
552
548
|
},
|
|
553
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @return {Array.<number>}
|
|
552
|
+
*/
|
|
553
|
+
getCurrentSeriesIndices: function () {
|
|
554
|
+
return (this._seriesIndices || []).slice();
|
|
555
|
+
},
|
|
556
|
+
|
|
554
557
|
/**
|
|
555
558
|
* @param {Function} cb
|
|
556
559
|
* @param {*} context
|
|
@@ -558,7 +561,7 @@ define(function (require) {
|
|
|
558
561
|
filterSeries: function (cb, context) {
|
|
559
562
|
assertSeriesInitialized(this);
|
|
560
563
|
var filteredSeries = filter(
|
|
561
|
-
this._componentsMap.series, cb, context
|
|
564
|
+
this._componentsMap.get('series'), cb, context
|
|
562
565
|
);
|
|
563
566
|
this._seriesIndices = createSeriesIndices(filteredSeries);
|
|
564
567
|
},
|
|
@@ -566,10 +569,10 @@ define(function (require) {
|
|
|
566
569
|
restoreData: function () {
|
|
567
570
|
var componentsMap = this._componentsMap;
|
|
568
571
|
|
|
569
|
-
this._seriesIndices = createSeriesIndices(componentsMap.series);
|
|
572
|
+
this._seriesIndices = createSeriesIndices(componentsMap.get('series'));
|
|
570
573
|
|
|
571
574
|
var componentTypes = [];
|
|
572
|
-
each(
|
|
575
|
+
componentsMap.each(function (components, componentType) {
|
|
573
576
|
componentTypes.push(componentType);
|
|
574
577
|
});
|
|
575
578
|
|
|
@@ -577,7 +580,7 @@ define(function (require) {
|
|
|
577
580
|
componentTypes,
|
|
578
581
|
ComponentModel.getAllClassMainTypes(),
|
|
579
582
|
function (componentType, dependencies) {
|
|
580
|
-
each(componentsMap
|
|
583
|
+
each(componentsMap.get(componentType), function (component) {
|
|
581
584
|
component.restoreData();
|
|
582
585
|
});
|
|
583
586
|
}
|
|
@@ -621,7 +624,7 @@ define(function (require) {
|
|
|
621
624
|
* @type {Object.<string, Array.<module:echarts/model/Model>>}
|
|
622
625
|
* @private
|
|
623
626
|
*/
|
|
624
|
-
this._componentsMap = {series: []};
|
|
627
|
+
this._componentsMap = zrUtil.createHashMap({series: []});
|
|
625
628
|
|
|
626
629
|
/**
|
|
627
630
|
* Mapping between filtered series list and raw series list.
|
|
@@ -651,7 +654,7 @@ define(function (require) {
|
|
|
651
654
|
|
|
652
655
|
var ret = {};
|
|
653
656
|
each(types, function (type) {
|
|
654
|
-
ret[type] = (componentsMap
|
|
657
|
+
ret[type] = (componentsMap.get(type) || []).slice();
|
|
655
658
|
});
|
|
656
659
|
|
|
657
660
|
return ret;
|
|
@@ -702,7 +705,7 @@ define(function (require) {
|
|
|
702
705
|
// which make sure that their initialization is after series.
|
|
703
706
|
if (__DEV__) {
|
|
704
707
|
if (!ecModel._seriesIndices) {
|
|
705
|
-
throw new Error('
|
|
708
|
+
throw new Error('Option should contains series.');
|
|
706
709
|
}
|
|
707
710
|
}
|
|
708
711
|
}
|