echarts 3.6.1 → 3.7.2
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/README.md +1 -0
- package/dist/echarts-en.js +77756 -0
- package/dist/echarts-en.min.js +38 -0
- package/dist/echarts.common-en.js +50169 -0
- package/dist/echarts.common-en.min.js +30 -0
- package/dist/echarts.common.js +5799 -3093
- package/dist/echarts.common.min.js +14 -13
- package/dist/echarts.js +7628 -4679
- package/dist/echarts.min.js +22 -22
- package/dist/echarts.simple-en.js +34988 -0
- package/dist/echarts.simple-en.min.js +27 -0
- package/dist/echarts.simple.js +4472 -2493
- package/dist/echarts.simple.min.js +11 -9
- package/dist/extension/bmap.js +50 -11
- package/dist/extension/bmap.min.js +1 -1
- package/dist/extension/dataTool.js +10 -10
- package/extension/bmap/BMapCoordSys.js +40 -1
- package/index.blank.js +4 -0
- package/index.common.js +1 -1
- package/index.js +1 -1
- package/lib/action/createDataSelectAction.js +6 -2
- package/lib/chart/bar/BarView.js +6 -3
- package/lib/chart/bar/BaseBarSeries.js +4 -3
- package/lib/chart/bar/PictorialBarSeries.js +1 -1
- package/lib/chart/bar/PictorialBarView.js +29 -7
- package/lib/chart/bar/helper.js +14 -31
- package/lib/chart/candlestick/candlestickLayout.js +49 -6
- package/lib/chart/chord/chordCircularLayout.js +2 -2
- package/lib/chart/custom.js +135 -21
- package/lib/chart/funnel/FunnelSeries.js +0 -1
- package/lib/chart/funnel/FunnelView.js +15 -22
- package/lib/chart/funnel/funnelLayout.js +1 -1
- package/lib/chart/gauge/GaugeSeries.js +7 -12
- package/lib/chart/gauge/GaugeView.js +32 -53
- package/lib/chart/graph/GraphSeries.js +2 -1
- package/lib/chart/graph/GraphView.js +39 -45
- package/lib/chart/graph/forceHelper.js +5 -0
- package/lib/chart/graph/forceLayout.js +1 -1
- package/lib/chart/heatmap/HeatmapLayer.js +7 -0
- package/lib/chart/heatmap/HeatmapView.js +10 -9
- package/lib/chart/helper/EffectSymbol.js +3 -3
- package/lib/chart/helper/LargeSymbolDraw.js +6 -1
- package/lib/chart/helper/Line.js +40 -22
- package/lib/chart/helper/Symbol.js +20 -7
- package/lib/chart/helper/SymbolDraw.js +2 -1
- package/lib/chart/helper/labelHelper.js +0 -17
- package/lib/chart/helper/whiskerBoxCommon.js +11 -3
- package/lib/chart/line/LineSeries.js +1 -0
- package/lib/chart/line/LineView.js +14 -2
- package/lib/chart/line/poly.js +5 -0
- package/lib/chart/lines/LinesView.js +22 -7
- package/lib/chart/map/MapSeries.js +3 -7
- package/lib/chart/map/MapView.js +29 -18
- package/lib/chart/pie/PieSeries.js +20 -6
- package/lib/chart/pie/PieView.js +20 -23
- package/lib/chart/pie/labelLayout.js +3 -3
- package/lib/chart/radar/RadarView.js +16 -20
- package/lib/chart/sankey/SankeySeries.js +2 -4
- package/lib/chart/sankey/SankeyView.js +13 -29
- package/lib/chart/sankey/sankeyLayout.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +2 -4
- package/lib/chart/themeRiver/ThemeRiverView.js +2 -5
- package/lib/chart/themeRiver/themeRiverLayout.js +1 -1
- package/lib/chart/treemap/Breadcrumb.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +28 -8
- package/lib/chart/treemap/TreemapView.js +88 -77
- package/lib/chart/treemap/treemapLayout.js +29 -13
- package/lib/component/axis/AngleAxisView.js +13 -19
- package/lib/component/axis/AxisBuilder.js +260 -186
- package/lib/component/axis/CartesianAxisView.js +15 -3
- package/lib/component/axis/ParallelAxisView.js +1 -1
- package/lib/component/axis/RadiusAxisView.js +1 -1
- package/lib/component/axis/SingleAxisView.js +8 -2
- package/lib/component/axis/cartesianAxisHelper.js +11 -15
- package/lib/component/axisPointer/AxisPointerModel.js +1 -3
- package/lib/component/axisPointer/BaseAxisPointer.js +15 -38
- package/lib/component/axisPointer/axisTrigger.js +36 -20
- package/lib/component/axisPointer/modelHelper.js +3 -4
- package/lib/component/axisPointer/viewHelper.js +4 -6
- package/lib/component/axisPointer.js +1 -14
- package/lib/component/calendar/CalendarView.js +22 -39
- package/lib/component/dataZoom/AxisProxy.js +3 -2
- package/lib/component/dataZoom/DataZoomModel.js +16 -4
- package/lib/component/dataZoom/InsideZoomView.js +5 -3
- package/lib/component/dataZoom/SliderZoomView.js +21 -32
- package/lib/component/dataZoom/roams.js +33 -9
- package/lib/component/dataZoom/typeDefaulter.js +1 -1
- package/lib/component/graphic.js +17 -5
- package/lib/component/helper/BrushTargetManager.js +1 -1
- package/lib/component/helper/MapDraw.js +26 -22
- package/lib/component/helper/RoamController.js +12 -11
- package/lib/component/helper/listComponent.js +27 -24
- package/lib/component/helper/selectableMixin.js +40 -15
- package/lib/component/legend/LegendModel.js +11 -3
- package/lib/component/legend/LegendView.js +151 -70
- package/lib/component/legend/ScrollableLegendModel.js +75 -0
- package/lib/component/legend/ScrollableLegendView.js +367 -0
- package/lib/component/legend/legendAction.js +1 -0
- package/lib/component/legend/scrollableLegendAction.js +24 -0
- package/lib/component/legend.js +8 -3
- package/lib/component/legendScroll.js +11 -0
- package/lib/component/marker/MarkAreaView.js +12 -26
- package/lib/component/marker/MarkLineView.js +5 -5
- package/lib/component/marker/MarkPointView.js +4 -4
- package/lib/component/marker/MarkerModel.js +1 -4
- package/lib/component/marker/markerHelper.js +1 -0
- package/lib/component/radar/RadarView.js +6 -3
- package/lib/component/timeline/SliderTimelineModel.js +4 -6
- package/lib/component/timeline/SliderTimelineView.js +14 -16
- package/lib/component/timeline/TimelineAxis.js +1 -1
- package/lib/component/timeline/TimelineModel.js +1 -3
- package/lib/component/title.js +9 -10
- package/lib/component/toolbox/ToolboxModel.js +2 -0
- package/lib/component/toolbox/ToolboxView.js +15 -27
- package/lib/component/toolbox/feature/Brush.js +3 -8
- package/lib/component/toolbox/feature/DataView.js +5 -5
- package/lib/component/toolbox/feature/DataZoom.js +3 -4
- package/lib/component/toolbox/feature/MagicType.js +3 -6
- package/lib/component/toolbox/feature/Restore.js +2 -1
- package/lib/component/toolbox/feature/SaveAsImage.js +23 -9
- package/lib/component/tooltip/TooltipContent.js +4 -4
- package/lib/component/tooltip/TooltipView.js +29 -6
- package/lib/component/visualMap/ContinuousModel.js +2 -2
- package/lib/component/visualMap/ContinuousView.js +12 -8
- package/lib/component/visualMap/PiecewiseModel.js +1 -2
- package/lib/component/visualMap/PiecewiseView.js +2 -2
- package/lib/component/visualMap/VisualMapModel.js +18 -12
- package/lib/coord/Axis.js +1 -1
- package/lib/coord/axisDefault.js +3 -3
- package/lib/coord/axisHelper.js +18 -1
- package/lib/coord/axisModelCommonMixin.js +12 -2
- package/lib/coord/calendar/Calendar.js +65 -21
- package/lib/coord/calendar/CalendarModel.js +6 -12
- package/lib/coord/cartesian/Cartesian2D.js +0 -14
- package/lib/coord/cartesian/Grid.js +47 -28
- package/lib/coord/geo/Geo.js +2 -18
- package/lib/coord/geo/GeoModel.js +6 -13
- package/lib/coord/geo/fix/diaoyuIsland.js +30 -0
- package/lib/coord/geo/geoCreator.js +6 -1
- package/lib/coord/polar/Polar.js +0 -13
- package/lib/coord/radar/Radar.js +1 -1
- package/lib/coord/radar/RadarModel.js +6 -2
- package/lib/data/DataDiffer.js +14 -7
- package/lib/data/Graph.js +3 -0
- package/lib/data/List.js +1 -1
- package/lib/data/Tree.js +2 -2
- package/lib/data/helper/completeDimensions.js +2 -11
- package/lib/echarts.js +33 -10
- package/lib/lang/cn.js +4 -0
- package/lib/lang/default.js +42 -0
- package/lib/lang/en.js +42 -0
- package/lib/lang.js +42 -0
- package/lib/langEN.js +42 -0
- package/lib/layout/barGrid.js +11 -3
- package/lib/layout/barPolar.js +9 -2
- package/lib/model/Model.js +2 -1
- package/lib/model/Series.js +14 -6
- package/lib/model/mixin/textStyle.js +11 -9
- package/lib/preprocessor/backwardCompat.js +5 -4
- package/lib/preprocessor/helper/compatStyle.js +157 -45
- package/lib/scale/Interval.js +10 -4
- package/lib/scale/Time.js +14 -6
- package/lib/scale/helper.js +15 -2
- package/lib/util/format.js +4 -24
- package/lib/util/graphic.js +412 -21
- package/lib/util/layout.js +28 -16
- package/lib/util/model.js +26 -11
- package/lib/util/number.js +106 -21
- package/lib/visual/VisualMapping.js +4 -4
- package/package.json +3 -3
- package/rollup.config.js +49 -0
- package/src/action/createDataSelectAction.js +6 -2
- package/src/chart/bar/BarView.js +6 -3
- package/src/chart/bar/BaseBarSeries.js +4 -3
- package/src/chart/bar/PictorialBarSeries.js +1 -1
- package/src/chart/bar/PictorialBarView.js +29 -7
- package/src/chart/bar/helper.js +13 -30
- package/src/chart/candlestick/candlestickLayout.js +49 -6
- package/src/chart/chord/chordCircularLayout.js +2 -2
- package/src/chart/custom.js +135 -21
- package/src/chart/funnel/FunnelSeries.js +0 -1
- package/src/chart/funnel/FunnelView.js +15 -22
- package/src/chart/funnel/funnelLayout.js +1 -1
- package/src/chart/gauge/GaugeSeries.js +7 -12
- package/src/chart/gauge/GaugeView.js +32 -53
- package/src/chart/graph/GraphSeries.js +2 -1
- package/src/chart/graph/GraphView.js +39 -45
- package/src/chart/graph/forceHelper.js +5 -0
- package/src/chart/graph/forceLayout.js +1 -1
- package/src/chart/heatmap/HeatmapLayer.js +7 -0
- package/src/chart/heatmap/HeatmapView.js +10 -9
- package/src/chart/helper/EffectSymbol.js +3 -3
- package/src/chart/helper/LargeSymbolDraw.js +6 -1
- package/src/chart/helper/Line.js +40 -22
- package/src/chart/helper/Symbol.js +20 -7
- package/src/chart/helper/SymbolDraw.js +2 -1
- package/src/chart/helper/labelHelper.js +0 -17
- package/src/chart/helper/whiskerBoxCommon.js +11 -4
- package/src/chart/line/LineSeries.js +1 -0
- package/src/chart/line/LineView.js +14 -2
- package/src/chart/line/poly.js +5 -0
- package/src/chart/lines/LinesView.js +22 -7
- package/src/chart/map/MapSeries.js +3 -7
- package/src/chart/map/MapView.js +29 -18
- package/src/chart/pie/PieSeries.js +20 -6
- package/src/chart/pie/PieView.js +20 -23
- package/src/chart/pie/labelLayout.js +3 -3
- package/src/chart/radar/RadarView.js +16 -20
- package/src/chart/sankey/SankeySeries.js +2 -4
- package/src/chart/sankey/SankeyView.js +13 -29
- package/src/chart/sankey/sankeyLayout.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +2 -4
- package/src/chart/themeRiver/ThemeRiverView.js +2 -5
- package/src/chart/themeRiver/themeRiverLayout.js +1 -1
- package/src/chart/treemap/Breadcrumb.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +28 -8
- package/src/chart/treemap/TreemapView.js +88 -77
- package/src/chart/treemap/treemapLayout.js +29 -13
- package/src/component/axis/AngleAxisView.js +13 -19
- package/src/component/axis/AxisBuilder.js +260 -186
- package/src/component/axis/CartesianAxisView.js +15 -3
- package/src/component/axis/ParallelAxisView.js +1 -1
- package/src/component/axis/RadiusAxisView.js +1 -1
- package/src/component/axis/SingleAxisView.js +8 -2
- package/src/component/axis/cartesianAxisHelper.js +11 -15
- package/src/component/axisPointer/AxisPointerModel.js +1 -3
- package/src/component/axisPointer/BaseAxisPointer.js +15 -38
- package/src/component/axisPointer/axisTrigger.js +36 -20
- package/src/component/axisPointer/modelHelper.js +3 -4
- package/src/component/axisPointer/viewHelper.js +4 -6
- package/src/component/axisPointer.js +1 -14
- package/src/component/calendar/CalendarView.js +22 -39
- package/src/component/dataZoom/AxisProxy.js +3 -2
- package/src/component/dataZoom/DataZoomModel.js +16 -4
- package/src/component/dataZoom/InsideZoomView.js +5 -3
- package/src/component/dataZoom/SliderZoomView.js +21 -32
- package/src/component/dataZoom/roams.js +33 -9
- package/src/component/dataZoom/typeDefaulter.js +1 -1
- package/src/component/graphic.js +17 -5
- package/src/component/helper/BrushTargetManager.js +1 -1
- package/src/component/helper/MapDraw.js +26 -22
- package/src/component/helper/RoamController.js +12 -11
- package/src/component/helper/listComponent.js +27 -24
- package/src/component/helper/selectableMixin.js +40 -15
- package/src/component/legend/LegendModel.js +11 -3
- package/src/component/legend/LegendView.js +151 -70
- package/src/component/legend/ScrollableLegendModel.js +76 -0
- package/src/component/legend/ScrollableLegendView.js +368 -0
- package/src/component/legend/legendAction.js +1 -0
- package/src/component/legend/scrollableLegendAction.js +25 -0
- package/src/component/legend.js +8 -3
- package/src/component/legendScroll.js +12 -0
- package/src/component/marker/MarkAreaView.js +12 -26
- package/src/component/marker/MarkLineView.js +5 -5
- package/src/component/marker/MarkPointView.js +4 -4
- package/src/component/marker/MarkerModel.js +1 -4
- package/src/component/marker/markerHelper.js +1 -0
- package/src/component/radar/RadarView.js +6 -3
- package/src/component/timeline/SliderTimelineModel.js +4 -6
- package/src/component/timeline/SliderTimelineView.js +14 -16
- package/src/component/timeline/TimelineAxis.js +1 -1
- package/src/component/timeline/TimelineModel.js +1 -3
- package/src/component/title.js +9 -10
- package/src/component/toolbox/ToolboxModel.js +2 -0
- package/src/component/toolbox/ToolboxView.js +15 -27
- package/src/component/toolbox/feature/Brush.js +3 -8
- package/src/component/toolbox/feature/DataView.js +5 -5
- package/src/component/toolbox/feature/DataZoom.js +3 -4
- package/src/component/toolbox/feature/MagicType.js +3 -6
- package/src/component/toolbox/feature/Restore.js +2 -1
- package/src/component/toolbox/feature/SaveAsImage.js +23 -10
- package/src/component/tooltip/TooltipContent.js +4 -4
- package/src/component/tooltip/TooltipView.js +29 -7
- package/src/component/visualMap/ContinuousModel.js +2 -2
- package/src/component/visualMap/ContinuousView.js +12 -8
- package/src/component/visualMap/PiecewiseModel.js +1 -2
- package/src/component/visualMap/PiecewiseView.js +2 -2
- package/src/component/visualMap/VisualMapModel.js +18 -12
- package/src/coord/Axis.js +1 -1
- package/src/coord/axisDefault.js +3 -3
- package/src/coord/axisHelper.js +18 -1
- package/src/coord/axisModelCommonMixin.js +12 -2
- package/src/coord/calendar/Calendar.js +65 -21
- package/src/coord/calendar/CalendarModel.js +6 -12
- package/src/coord/cartesian/Cartesian2D.js +0 -14
- package/src/coord/cartesian/Grid.js +47 -28
- package/src/coord/geo/Geo.js +2 -18
- package/src/coord/geo/GeoModel.js +6 -13
- package/src/coord/geo/fix/diaoyuIsland.js +30 -0
- package/src/coord/geo/geoCreator.js +6 -1
- package/src/coord/polar/Polar.js +0 -13
- package/src/coord/radar/Radar.js +1 -1
- package/src/coord/radar/RadarModel.js +6 -2
- package/src/data/DataDiffer.js +14 -7
- package/src/data/Graph.js +3 -0
- package/src/data/List.js +1 -1
- package/src/data/Tree.js +2 -2
- package/src/data/helper/completeDimensions.js +2 -11
- package/src/echarts.js +33 -10
- package/src/lang.js +43 -0
- package/src/langEN.js +43 -0
- package/src/layout/barGrid.js +11 -3
- package/src/layout/barPolar.js +9 -2
- package/src/model/Model.js +2 -1
- package/src/model/Series.js +14 -6
- package/src/model/mixin/textStyle.js +11 -9
- package/src/preprocessor/backwardCompat.js +5 -4
- package/src/preprocessor/helper/compatStyle.js +157 -45
- package/src/scale/Interval.js +10 -4
- package/src/scale/Time.js +14 -6
- package/src/scale/helper.js +15 -2
- package/src/util/format.js +4 -24
- package/src/util/graphic.js +412 -21
- package/src/util/layout.js +28 -16
- package/src/util/model.js +26 -11
- package/src/util/number.js +106 -21
- package/src/visual/VisualMapping.js +4 -4
- package/webpack.config.js +21 -7
- package/.npmignore +0 -10
package/src/coord/axisHelper.js
CHANGED
|
@@ -79,9 +79,22 @@ define(function (require) {
|
|
|
79
79
|
if (min === 'dataMin') {
|
|
80
80
|
min = originalExtent[0];
|
|
81
81
|
}
|
|
82
|
+
else if (typeof min === 'function') {
|
|
83
|
+
min = min({
|
|
84
|
+
min: originalExtent[0],
|
|
85
|
+
max: originalExtent[1]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
82
89
|
if (max === 'dataMax') {
|
|
83
90
|
max = originalExtent[1];
|
|
84
91
|
}
|
|
92
|
+
else if (typeof max === 'function') {
|
|
93
|
+
max = max({
|
|
94
|
+
min: originalExtent[0],
|
|
95
|
+
max: originalExtent[1]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
85
98
|
|
|
86
99
|
(min == null || !isFinite(min)) && (min = NaN);
|
|
87
100
|
(max == null || !isFinite(max)) && (max = NaN);
|
|
@@ -113,12 +126,16 @@ define(function (require) {
|
|
|
113
126
|
scale.base = model.get('logBase');
|
|
114
127
|
}
|
|
115
128
|
|
|
129
|
+
var scaleType = scale.type;
|
|
116
130
|
scale.setExtent(extent[0], extent[1]);
|
|
117
131
|
scale.niceExtent({
|
|
118
132
|
splitNumber: splitNumber,
|
|
119
133
|
fixMin: fixMin,
|
|
120
134
|
fixMax: fixMax,
|
|
121
|
-
minInterval:
|
|
135
|
+
minInterval: (scaleType === 'interval' || scaleType === 'time')
|
|
136
|
+
? model.get('minInterval') : null,
|
|
137
|
+
maxInterval: (scaleType === 'interval' || scaleType === 'time')
|
|
138
|
+
? model.get('maxInterval') : null
|
|
122
139
|
});
|
|
123
140
|
|
|
124
141
|
// If some one specified the min, max. And the default calculated interval
|
|
@@ -42,7 +42,12 @@ define(function (require) {
|
|
|
42
42
|
var min = (!origin && option.rangeStart != null)
|
|
43
43
|
? option.rangeStart : option.min;
|
|
44
44
|
|
|
45
|
-
if (this.axis
|
|
45
|
+
if (this.axis
|
|
46
|
+
&& min != null
|
|
47
|
+
&& min !== 'dataMin'
|
|
48
|
+
&& typeof min !== 'function'
|
|
49
|
+
&& !zrUtil.eqNaN(min)
|
|
50
|
+
) {
|
|
46
51
|
min = this.axis.scale.parse(min);
|
|
47
52
|
}
|
|
48
53
|
return min;
|
|
@@ -57,7 +62,12 @@ define(function (require) {
|
|
|
57
62
|
var max = (!origin && option.rangeEnd != null)
|
|
58
63
|
? option.rangeEnd : option.max;
|
|
59
64
|
|
|
60
|
-
if (this.axis
|
|
65
|
+
if (this.axis
|
|
66
|
+
&& max != null
|
|
67
|
+
&& max !== 'dataMax'
|
|
68
|
+
&& typeof max !== 'function'
|
|
69
|
+
&& !zrUtil.eqNaN(max)
|
|
70
|
+
) {
|
|
61
71
|
max = this.axis.scale.parse(max);
|
|
62
72
|
}
|
|
63
73
|
return max;
|
|
@@ -7,7 +7,7 @@ define(function (require) {
|
|
|
7
7
|
var zrUtil = require('zrender/core/util');
|
|
8
8
|
|
|
9
9
|
// (24*60*60*1000)
|
|
10
|
-
var
|
|
10
|
+
var PROXIMATE_ONE_DAY = 86400000;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Calendar
|
|
@@ -76,7 +76,16 @@ define(function (require) {
|
|
|
76
76
|
* get date info
|
|
77
77
|
*
|
|
78
78
|
* @param {string|number} date date
|
|
79
|
-
* @return {Object}
|
|
79
|
+
* @return {Object}
|
|
80
|
+
* {
|
|
81
|
+
* y: string, local full year, eg., '1940',
|
|
82
|
+
* m: string, local month, from '01' ot '12',
|
|
83
|
+
* d: string, local date, from '01' to '31' (if exists),
|
|
84
|
+
* day: It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
|
|
85
|
+
* time: timestamp,
|
|
86
|
+
* formatedDate: string, yyyy-MM-dd,
|
|
87
|
+
* date: original date object.
|
|
88
|
+
* }
|
|
80
89
|
*/
|
|
81
90
|
getDateInfo: function (date) {
|
|
82
91
|
|
|
@@ -111,9 +120,10 @@ define(function (require) {
|
|
|
111
120
|
return this.getDateInfo(date);
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
date = new Date(this.getDateInfo(date).time);
|
|
124
|
+
date.setDate(date.getDate() + n);
|
|
115
125
|
|
|
116
|
-
return this.getDateInfo(
|
|
126
|
+
return this.getDateInfo(date);
|
|
117
127
|
},
|
|
118
128
|
|
|
119
129
|
update: function (ecModel, api) {
|
|
@@ -179,18 +189,18 @@ define(function (require) {
|
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
var week = dayInfo.day;
|
|
182
|
-
var nthWeek = this._getRangeInfo([range.start.time, date]).
|
|
192
|
+
var nthWeek = this._getRangeInfo([range.start.time, date]).nthWeek;
|
|
183
193
|
|
|
184
194
|
if (this._orient === 'vertical') {
|
|
185
195
|
return [
|
|
186
196
|
this._rect.x + week * this._sw + this._sw / 2,
|
|
187
|
-
this._rect.y +
|
|
197
|
+
this._rect.y + nthWeek * this._sh + this._sh / 2
|
|
188
198
|
];
|
|
189
199
|
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
return [
|
|
193
|
-
this._rect.x +
|
|
203
|
+
this._rect.x + nthWeek * this._sw + this._sw / 2,
|
|
194
204
|
this._rect.y + week * this._sh + this._sh / 2
|
|
195
205
|
];
|
|
196
206
|
|
|
@@ -256,7 +266,7 @@ define(function (require) {
|
|
|
256
266
|
/**
|
|
257
267
|
* Convert a (x, y) point to time date
|
|
258
268
|
*
|
|
259
|
-
* @param {
|
|
269
|
+
* @param {Array} point point
|
|
260
270
|
* @return {Object} date
|
|
261
271
|
*/
|
|
262
272
|
pointToDate: function (point) {
|
|
@@ -328,25 +338,60 @@ define(function (require) {
|
|
|
328
338
|
*
|
|
329
339
|
* @private
|
|
330
340
|
* @param {Array} range range ['2017-01-01', '2017-07-08']
|
|
341
|
+
* If range[0] > range[1], they will not be reversed.
|
|
331
342
|
* @return {Object} obj
|
|
332
343
|
*/
|
|
333
344
|
_getRangeInfo: function (range) {
|
|
345
|
+
range = [
|
|
346
|
+
this.getDateInfo(range[0]),
|
|
347
|
+
this.getDateInfo(range[1])
|
|
348
|
+
];
|
|
349
|
+
|
|
350
|
+
var reversed;
|
|
351
|
+
if (range[0].time > range[1].time) {
|
|
352
|
+
reversed = true;
|
|
353
|
+
range.reverse();
|
|
354
|
+
}
|
|
334
355
|
|
|
335
|
-
var
|
|
336
|
-
|
|
356
|
+
var allDay = Math.floor(range[1].time / PROXIMATE_ONE_DAY)
|
|
357
|
+
- Math.floor(range[0].time / PROXIMATE_ONE_DAY) + 1;
|
|
358
|
+
|
|
359
|
+
// Consider case:
|
|
360
|
+
// Firstly set system timezone as "Time Zone: America/Toronto",
|
|
361
|
+
// ```
|
|
362
|
+
// var first = new Date(1478412000000 - 3600 * 1000 * 2.5);
|
|
363
|
+
// var second = new Date(1478412000000);
|
|
364
|
+
// var allDays = Math.floor(second / ONE_DAY) - Math.floor(first / ONE_DAY) + 1;
|
|
365
|
+
// ```
|
|
366
|
+
// will get wrong result because of DST. So we should fix it.
|
|
367
|
+
var date = new Date(range[0].time);
|
|
368
|
+
var startDateNum = date.getDate();
|
|
369
|
+
var endDateNum = range[1].date.getDate();
|
|
370
|
+
date.setDate(startDateNum + allDay - 1);
|
|
371
|
+
// The bias can not over a month, so just compare date.
|
|
372
|
+
if (date.getDate() !== endDateNum) {
|
|
373
|
+
var sign = date.getTime() - range[1].time > 0 ? 1 : -1;
|
|
374
|
+
while (date.getDate() !== endDateNum && (date.getTime() - range[1].time) * sign > 0) {
|
|
375
|
+
allDay -= sign;
|
|
376
|
+
date.setDate(startDateNum + allDay - 1);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
337
379
|
|
|
338
|
-
var
|
|
380
|
+
var weeks = Math.floor((allDay + range[0].day + 6) / 7);
|
|
381
|
+
var nthWeek = reversed ? -weeks + 1: weeks - 1;
|
|
339
382
|
|
|
340
|
-
|
|
383
|
+
reversed && range.reverse();
|
|
341
384
|
|
|
342
385
|
return {
|
|
343
|
-
range: [
|
|
344
|
-
start:
|
|
345
|
-
end:
|
|
386
|
+
range: [range[0].formatedDate, range[1].formatedDate],
|
|
387
|
+
start: range[0],
|
|
388
|
+
end: range[1],
|
|
346
389
|
allDay: allDay,
|
|
347
390
|
weeks: weeks,
|
|
348
|
-
|
|
349
|
-
|
|
391
|
+
// From 0.
|
|
392
|
+
nthWeek: nthWeek,
|
|
393
|
+
fweek: range[0].day,
|
|
394
|
+
lweek: range[1].day
|
|
350
395
|
};
|
|
351
396
|
},
|
|
352
397
|
|
|
@@ -370,11 +415,10 @@ define(function (require) {
|
|
|
370
415
|
}
|
|
371
416
|
|
|
372
417
|
var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
|
|
418
|
+
var date = new Date(rangeInfo.start.time);
|
|
419
|
+
date.setDate(rangeInfo.start.d + nthDay);
|
|
373
420
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return this.getDateInfo(time);
|
|
377
|
-
|
|
421
|
+
return this.getDateInfo(date);
|
|
378
422
|
}
|
|
379
423
|
};
|
|
380
424
|
|
|
@@ -56,9 +56,7 @@ define(function (require) {
|
|
|
56
56
|
position: 'start',
|
|
57
57
|
margin: '50%', // 50% of cellSize
|
|
58
58
|
nameMap: 'en',
|
|
59
|
-
|
|
60
|
-
color: '#000'
|
|
61
|
-
}
|
|
59
|
+
color: '#000'
|
|
62
60
|
},
|
|
63
61
|
|
|
64
62
|
// month text style
|
|
@@ -75,9 +73,7 @@ define(function (require) {
|
|
|
75
73
|
// cn en []
|
|
76
74
|
nameMap: 'en',
|
|
77
75
|
formatter: null,
|
|
78
|
-
|
|
79
|
-
color: '#000'
|
|
80
|
-
}
|
|
76
|
+
color: '#000'
|
|
81
77
|
},
|
|
82
78
|
|
|
83
79
|
// year text style
|
|
@@ -88,12 +84,10 @@ define(function (require) {
|
|
|
88
84
|
position: null,
|
|
89
85
|
margin: 30,
|
|
90
86
|
formatter: null,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
fontSize: 20
|
|
96
|
-
}
|
|
87
|
+
color: '#ccc',
|
|
88
|
+
fontFamily: 'sans-serif',
|
|
89
|
+
fontWeight: 'bolder',
|
|
90
|
+
fontSize: 20
|
|
97
91
|
}
|
|
98
92
|
},
|
|
99
93
|
|
|
@@ -55,20 +55,6 @@ define(function(require) {
|
|
|
55
55
|
&& this.getAxis('y').containData(data[1]);
|
|
56
56
|
},
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Convert series data to an array of points
|
|
60
|
-
* @param {module:echarts/data/List} data
|
|
61
|
-
* @param {boolean} stack
|
|
62
|
-
* @return {Array}
|
|
63
|
-
* Return array of points. For example:
|
|
64
|
-
* `[[10, 10], [20, 20], [30, 30]]`
|
|
65
|
-
*/
|
|
66
|
-
dataToPoints: function (data, stack) {
|
|
67
|
-
return data.mapArray(['x', 'y'], function (x, y) {
|
|
68
|
-
return this.dataToPoint([x, y]);
|
|
69
|
-
}, stack, this);
|
|
70
|
-
},
|
|
71
|
-
|
|
72
58
|
/**
|
|
73
59
|
* @param {Array.<number>} data
|
|
74
60
|
* @param {boolean} [clamp=false]
|
|
@@ -31,7 +31,7 @@ define(function(require, factory) {
|
|
|
31
31
|
function getLabelUnionRect(axis) {
|
|
32
32
|
var axisModel = axis.model;
|
|
33
33
|
var labels = axisModel.getFormattedLabels();
|
|
34
|
-
var
|
|
34
|
+
var axisLabelModel = axisModel.getModel('axisLabel');
|
|
35
35
|
var rect;
|
|
36
36
|
var step = 1;
|
|
37
37
|
var labelCount = labels.length;
|
|
@@ -41,7 +41,7 @@ define(function(require, factory) {
|
|
|
41
41
|
}
|
|
42
42
|
for (var i = 0; i < labelCount; i += step) {
|
|
43
43
|
if (!axis.isLabelIgnored(i)) {
|
|
44
|
-
var singleRect =
|
|
44
|
+
var singleRect = axisLabelModel.getTextRect(labels[i]);
|
|
45
45
|
// FIXME consider label rotate
|
|
46
46
|
rect ? rect.union(singleRect) : (rect = singleRect);
|
|
47
47
|
}
|
|
@@ -95,40 +95,17 @@ define(function(require, factory) {
|
|
|
95
95
|
|
|
96
96
|
this._updateScale(ecModel, this.model);
|
|
97
97
|
|
|
98
|
-
function ifAxisCanNotOnZero(otherAxisDim) {
|
|
99
|
-
var axes = axesMap[otherAxisDim];
|
|
100
|
-
for (var idx in axes) {
|
|
101
|
-
if (axes.hasOwnProperty(idx)) {
|
|
102
|
-
var axis = axes[idx];
|
|
103
|
-
if (axis && (
|
|
104
|
-
axis.type === 'category' || axis.type === 'time' || !ifAxisCrossZero(axis)
|
|
105
|
-
)) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
98
|
each(axesMap.x, function (xAxis) {
|
|
114
99
|
niceScaleExtent(xAxis.scale, xAxis.model);
|
|
115
100
|
});
|
|
116
101
|
each(axesMap.y, function (yAxis) {
|
|
117
102
|
niceScaleExtent(yAxis.scale, yAxis.model);
|
|
118
103
|
});
|
|
119
|
-
// Fix configuration
|
|
120
104
|
each(axesMap.x, function (xAxis) {
|
|
121
|
-
|
|
122
|
-
// 1. When any other axis is a category axis
|
|
123
|
-
// 2. When any other axis not across 0 point
|
|
124
|
-
if (ifAxisCanNotOnZero('y')) {
|
|
125
|
-
xAxis.onZero = false;
|
|
126
|
-
}
|
|
105
|
+
fixAxisOnZero(axesMap, 'y', xAxis);
|
|
127
106
|
});
|
|
128
107
|
each(axesMap.y, function (yAxis) {
|
|
129
|
-
|
|
130
|
-
yAxis.onZero = false;
|
|
131
|
-
}
|
|
108
|
+
fixAxisOnZero(axesMap, 'x', yAxis);
|
|
132
109
|
});
|
|
133
110
|
|
|
134
111
|
// Resize again if containLabel is enabled
|
|
@@ -136,6 +113,47 @@ define(function(require, factory) {
|
|
|
136
113
|
this.resize(this.model, api);
|
|
137
114
|
};
|
|
138
115
|
|
|
116
|
+
function fixAxisOnZero(axesMap, otherAxisDim, axis) {
|
|
117
|
+
// onZero can not be enabled in these two situations:
|
|
118
|
+
// 1. When any other axis is a category axis.
|
|
119
|
+
// 2. When no axis is cross 0 point.
|
|
120
|
+
var axes = axesMap[otherAxisDim];
|
|
121
|
+
|
|
122
|
+
if (!axis.onZero) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var onZeroAxisIndex = axis.onZeroAxisIndex;
|
|
127
|
+
|
|
128
|
+
// If target axis is specified.
|
|
129
|
+
if (onZeroAxisIndex != null) {
|
|
130
|
+
var otherAxis = axes[onZeroAxisIndex];
|
|
131
|
+
if (otherAxis && canNotOnZeroToAxis(otherAxis)) {
|
|
132
|
+
axis.onZero = false;
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (var idx in axes) {
|
|
138
|
+
if (axes.hasOwnProperty(idx)) {
|
|
139
|
+
var otherAxis = axes[idx];
|
|
140
|
+
if (otherAxis && !canNotOnZeroToAxis(otherAxis)) {
|
|
141
|
+
onZeroAxisIndex = +idx;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (onZeroAxisIndex == null) {
|
|
148
|
+
axis.onZero = false;
|
|
149
|
+
}
|
|
150
|
+
axis.onZeroAxisIndex = onZeroAxisIndex;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function canNotOnZeroToAxis(axis) {
|
|
154
|
+
return axis.type === 'category' || axis.type === 'time' || !ifAxisCrossZero(axis);
|
|
155
|
+
}
|
|
156
|
+
|
|
139
157
|
/**
|
|
140
158
|
* Resize the grid
|
|
141
159
|
* @param {module:echarts/coord/cartesian/GridModel} gridModel
|
|
@@ -190,7 +208,7 @@ define(function(require, factory) {
|
|
|
190
208
|
|
|
191
209
|
/**
|
|
192
210
|
* @param {string} axisType
|
|
193
|
-
* @param {
|
|
211
|
+
* @param {number} [axisIndex]
|
|
194
212
|
*/
|
|
195
213
|
gridProto.getAxis = function (axisType, axisIndex) {
|
|
196
214
|
var axesMapOnDim = this._axesMap[axisType];
|
|
@@ -417,6 +435,7 @@ define(function(require, factory) {
|
|
|
417
435
|
axis.inverse = axisModel.get('inverse');
|
|
418
436
|
|
|
419
437
|
axis.onZero = axisModel.get('axisLine.onZero');
|
|
438
|
+
axis.onZeroAxisIndex = axisModel.get('axisLine.onZeroAxisIndex');
|
|
420
439
|
|
|
421
440
|
// Inject axis into axisModel
|
|
422
441
|
axisModel.axis = axis;
|
package/src/coord/geo/Geo.js
CHANGED
|
@@ -13,7 +13,8 @@ define(function (require) {
|
|
|
13
13
|
var geoFixFuncs = [
|
|
14
14
|
require('./fix/nanhai'),
|
|
15
15
|
require('./fix/textCoord'),
|
|
16
|
-
require('./fix/geoCoord')
|
|
16
|
+
require('./fix/geoCoord'),
|
|
17
|
+
require('./fix/diaoyuIsland')
|
|
17
18
|
];
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -191,23 +192,6 @@ define(function (require) {
|
|
|
191
192
|
return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
|
|
192
193
|
},
|
|
193
194
|
|
|
194
|
-
/**
|
|
195
|
-
* Convert series data to a list of points
|
|
196
|
-
* @param {module:echarts/data/List} data
|
|
197
|
-
* @param {boolean} stack
|
|
198
|
-
* @return {Array}
|
|
199
|
-
* Return list of points. For example:
|
|
200
|
-
* `[[10, 10], [20, 20], [30, 30]]`
|
|
201
|
-
*/
|
|
202
|
-
dataToPoints: function (data) {
|
|
203
|
-
var item = [];
|
|
204
|
-
return data.mapArray(['lng', 'lat'], function (lon, lat) {
|
|
205
|
-
item[0] = lon;
|
|
206
|
-
item[1] = lat;
|
|
207
|
-
return this.dataToPoint(item);
|
|
208
|
-
}, this);
|
|
209
|
-
},
|
|
210
|
-
|
|
211
195
|
/**
|
|
212
196
|
* @param {string|Array.<number>} data
|
|
213
197
|
* @return {Array.<number>}
|
|
@@ -24,17 +24,15 @@ define(function (require) {
|
|
|
24
24
|
init: function (option) {
|
|
25
25
|
ComponentModel.prototype.init.apply(this, arguments);
|
|
26
26
|
|
|
27
|
-
// Default label emphasis `
|
|
28
|
-
modelUtil.defaultEmphasis(
|
|
29
|
-
option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
|
|
30
|
-
);
|
|
27
|
+
// Default label emphasis `show`
|
|
28
|
+
modelUtil.defaultEmphasis(option.label, ['show']);
|
|
31
29
|
},
|
|
32
30
|
|
|
33
31
|
optionUpdated: function () {
|
|
34
32
|
var option = this.option;
|
|
35
33
|
var self = this;
|
|
36
34
|
|
|
37
|
-
option.regions = geoCreator.getFilledRegions(option.regions, option.map);
|
|
35
|
+
option.regions = geoCreator.getFilledRegions(option.regions, option.map, option.nameMap);
|
|
38
36
|
|
|
39
37
|
this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
|
|
40
38
|
if (regionOpt.name) {
|
|
@@ -96,15 +94,11 @@ define(function (require) {
|
|
|
96
94
|
label: {
|
|
97
95
|
normal: {
|
|
98
96
|
show: false,
|
|
99
|
-
|
|
100
|
-
color: '#000'
|
|
101
|
-
}
|
|
97
|
+
color: '#000'
|
|
102
98
|
},
|
|
103
99
|
emphasis: {
|
|
104
100
|
show: true,
|
|
105
|
-
|
|
106
|
-
color: 'rgb(100,0,0)'
|
|
107
|
-
}
|
|
101
|
+
color: 'rgb(100,0,0)'
|
|
108
102
|
}
|
|
109
103
|
},
|
|
110
104
|
|
|
@@ -149,8 +143,7 @@ define(function (require) {
|
|
|
149
143
|
return formatter(params);
|
|
150
144
|
}
|
|
151
145
|
else if (typeof formatter === 'string') {
|
|
152
|
-
|
|
153
|
-
return formatter.replace('{a}', serName != null ? serName : '');
|
|
146
|
+
return formatter.replace('{a}', name != null ? name : '');
|
|
154
147
|
}
|
|
155
148
|
},
|
|
156
149
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Fix for 钓鱼岛
|
|
2
|
+
define(function (require) {
|
|
3
|
+
|
|
4
|
+
// var Region = require('../Region');
|
|
5
|
+
// var zrUtil = require('zrender/core/util');
|
|
6
|
+
|
|
7
|
+
// var geoCoord = [126, 25];
|
|
8
|
+
|
|
9
|
+
var points = [
|
|
10
|
+
[
|
|
11
|
+
[123.45165252685547, 25.73527164402261],
|
|
12
|
+
[123.49731445312499, 25.73527164402261],
|
|
13
|
+
[123.49731445312499, 25.750734064600884],
|
|
14
|
+
[123.45165252685547, 25.750734064600884],
|
|
15
|
+
[123.45165252685547, 25.73527164402261]
|
|
16
|
+
]
|
|
17
|
+
];
|
|
18
|
+
return function (geo) {
|
|
19
|
+
if (geo.map === 'china') {
|
|
20
|
+
for (var i = 0, len = geo.regions.length; i < len; ++i) {
|
|
21
|
+
if (geo.regions[i].name === '台湾') {
|
|
22
|
+
geo.regions[i].geometries.push({
|
|
23
|
+
type: 'polygon',
|
|
24
|
+
exterior: points[0]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
});
|
|
@@ -245,11 +245,13 @@ define(function (require) {
|
|
|
245
245
|
* Fill given regions array
|
|
246
246
|
* @param {Array.<Object>} originRegionArr
|
|
247
247
|
* @param {string} mapName
|
|
248
|
+
* @param {Object} [nameMap]
|
|
248
249
|
* @return {Array}
|
|
249
250
|
*/
|
|
250
|
-
getFilledRegions: function (originRegionArr, mapName) {
|
|
251
|
+
getFilledRegions: function (originRegionArr, mapName, nameMap) {
|
|
251
252
|
// Not use the original
|
|
252
253
|
var regionsArr = (originRegionArr || []).slice();
|
|
254
|
+
nameMap = nameMap || {};
|
|
253
255
|
|
|
254
256
|
var map = geoCreator.getMap(mapName);
|
|
255
257
|
var geoJson = map && map.geoJson;
|
|
@@ -269,6 +271,9 @@ define(function (require) {
|
|
|
269
271
|
for (var i = 0; i < features.length; i++) {
|
|
270
272
|
var name = features[i].properties.name;
|
|
271
273
|
if (!dataNameMap.get(name)) {
|
|
274
|
+
if (nameMap.hasOwnProperty(name)) {
|
|
275
|
+
name = nameMap[name];
|
|
276
|
+
}
|
|
272
277
|
regionsArr.push({
|
|
273
278
|
name: name
|
|
274
279
|
});
|
package/src/coord/polar/Polar.js
CHANGED
|
@@ -164,19 +164,6 @@ define(function(require) {
|
|
|
164
164
|
};
|
|
165
165
|
},
|
|
166
166
|
|
|
167
|
-
/**
|
|
168
|
-
* Convert series data to a list of (x, y) points
|
|
169
|
-
* @param {module:echarts/data/List} data
|
|
170
|
-
* @return {Array}
|
|
171
|
-
* Return list of coordinates. For example:
|
|
172
|
-
* `[[10, 10], [20, 20], [30, 30]]`
|
|
173
|
-
*/
|
|
174
|
-
dataToPoints: function (data) {
|
|
175
|
-
return data.mapArray(this.dimensions, function (radius, angle) {
|
|
176
|
-
return this.dataToPoint([radius, angle]);
|
|
177
|
-
}, true, this);
|
|
178
|
-
},
|
|
179
|
-
|
|
180
167
|
/**
|
|
181
168
|
* Convert a single data item to (x, y) point.
|
|
182
169
|
* Parameter data is an array which the first element is radius and the second is angle
|
package/src/coord/radar/Radar.js
CHANGED
|
@@ -162,7 +162,7 @@ define(function (require) {
|
|
|
162
162
|
|
|
163
163
|
if (fixedMin != null && fixedMax != null) {
|
|
164
164
|
// User set min, max, divide to get new interval
|
|
165
|
-
|
|
165
|
+
scale.setExtent(+fixedMin, +fixedMax);
|
|
166
166
|
scale.setInterval(
|
|
167
167
|
(fixedMax - fixedMin) / splitNumber
|
|
168
168
|
);
|
|
@@ -25,7 +25,7 @@ define(function (require) {
|
|
|
25
25
|
var axisLine = this.get('axisLine');
|
|
26
26
|
var axisTick = this.get('axisTick');
|
|
27
27
|
var axisLabel = this.get('axisLabel');
|
|
28
|
-
var nameTextStyle = this.get('name
|
|
28
|
+
var nameTextStyle = this.get('name');
|
|
29
29
|
var showName = this.get('name.show');
|
|
30
30
|
var nameFormatter = this.get('name.formatter');
|
|
31
31
|
var nameGap = this.get('nameGap');
|
|
@@ -39,6 +39,10 @@ define(function (require) {
|
|
|
39
39
|
else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
|
|
40
40
|
indicatorOpt.max = 0;
|
|
41
41
|
}
|
|
42
|
+
var iNameTextStyle = nameTextStyle;
|
|
43
|
+
if(indicatorOpt.color != null) {
|
|
44
|
+
iNameTextStyle = zrUtil.defaults({color: indicatorOpt.color}, nameTextStyle);
|
|
45
|
+
}
|
|
42
46
|
// Use same configuration
|
|
43
47
|
indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
|
|
44
48
|
boundaryGap: boundaryGap,
|
|
@@ -52,7 +56,7 @@ define(function (require) {
|
|
|
52
56
|
nameLocation: 'end',
|
|
53
57
|
nameGap: nameGap,
|
|
54
58
|
// min: 0,
|
|
55
|
-
nameTextStyle:
|
|
59
|
+
nameTextStyle: iNameTextStyle,
|
|
56
60
|
triggerEvent: triggerEvent
|
|
57
61
|
}, false);
|
|
58
62
|
if (!showName) {
|
package/src/data/DataDiffer.js
CHANGED
|
@@ -5,12 +5,21 @@ define(function(require) {
|
|
|
5
5
|
return item;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @param {Array} oldArr
|
|
10
|
+
* @param {Array} newArr
|
|
11
|
+
* @param {Function} oldKeyGetter
|
|
12
|
+
* @param {Function} newKeyGetter
|
|
13
|
+
* @param {Object} [context] Can be visited by this.context in callback.
|
|
14
|
+
*/
|
|
15
|
+
function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter, context) {
|
|
9
16
|
this._old = oldArr;
|
|
10
17
|
this._new = newArr;
|
|
11
18
|
|
|
12
19
|
this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
|
|
13
20
|
this._newKeyGetter = newKeyGetter || defaultKeyGetter;
|
|
21
|
+
|
|
22
|
+
this.context = context;
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
DataDiffer.prototype = {
|
|
@@ -44,8 +53,6 @@ define(function(require) {
|
|
|
44
53
|
execute: function () {
|
|
45
54
|
var oldArr = this._old;
|
|
46
55
|
var newArr = this._new;
|
|
47
|
-
var oldKeyGetter = this._oldKeyGetter;
|
|
48
|
-
var newKeyGetter = this._newKeyGetter;
|
|
49
56
|
|
|
50
57
|
var oldDataIndexMap = {};
|
|
51
58
|
var newDataIndexMap = {};
|
|
@@ -53,8 +60,8 @@ define(function(require) {
|
|
|
53
60
|
var newDataKeyArr = [];
|
|
54
61
|
var i;
|
|
55
62
|
|
|
56
|
-
initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr,
|
|
57
|
-
initIndexMap(newArr, newDataIndexMap, newDataKeyArr,
|
|
63
|
+
initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter', this);
|
|
64
|
+
initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter', this);
|
|
58
65
|
|
|
59
66
|
// Travel by inverted order to make sure order consistency
|
|
60
67
|
// when duplicate keys exists (consider newDataIndex.pop() below).
|
|
@@ -103,10 +110,10 @@ define(function(require) {
|
|
|
103
110
|
}
|
|
104
111
|
};
|
|
105
112
|
|
|
106
|
-
function initIndexMap(arr, map, keyArr,
|
|
113
|
+
function initIndexMap(arr, map, keyArr, keyGetterName, dataDiffer) {
|
|
107
114
|
for (var i = 0; i < arr.length; i++) {
|
|
108
115
|
// Add prefix to avoid conflict with Object.prototype.
|
|
109
|
-
var key = '_ec_' +
|
|
116
|
+
var key = '_ec_' + dataDiffer[keyGetterName](arr[i], i);
|
|
110
117
|
var existence = map[key];
|
|
111
118
|
if (existence == null) {
|
|
112
119
|
keyArr.push(key);
|