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/lib/coord/axisHelper.js
CHANGED
|
@@ -79,9 +79,22 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
var zrUtil = require('zrender/lib/core/util');
|
|
7
7
|
|
|
8
8
|
// (24*60*60*1000)
|
|
9
|
-
var
|
|
9
|
+
var PROXIMATE_ONE_DAY = 86400000;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Calendar
|
|
@@ -75,7 +75,16 @@
|
|
|
75
75
|
* get date info
|
|
76
76
|
*
|
|
77
77
|
* @param {string|number} date date
|
|
78
|
-
* @return {Object}
|
|
78
|
+
* @return {Object}
|
|
79
|
+
* {
|
|
80
|
+
* y: string, local full year, eg., '1940',
|
|
81
|
+
* m: string, local month, from '01' ot '12',
|
|
82
|
+
* d: string, local date, from '01' to '31' (if exists),
|
|
83
|
+
* day: It is not date.getDay(). It is the location of the cell in a week, from 0 to 6,
|
|
84
|
+
* time: timestamp,
|
|
85
|
+
* formatedDate: string, yyyy-MM-dd,
|
|
86
|
+
* date: original date object.
|
|
87
|
+
* }
|
|
79
88
|
*/
|
|
80
89
|
getDateInfo: function (date) {
|
|
81
90
|
|
|
@@ -110,9 +119,10 @@
|
|
|
110
119
|
return this.getDateInfo(date);
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
|
|
122
|
+
date = new Date(this.getDateInfo(date).time);
|
|
123
|
+
date.setDate(date.getDate() + n);
|
|
114
124
|
|
|
115
|
-
return this.getDateInfo(
|
|
125
|
+
return this.getDateInfo(date);
|
|
116
126
|
},
|
|
117
127
|
|
|
118
128
|
update: function (ecModel, api) {
|
|
@@ -178,18 +188,18 @@
|
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
var week = dayInfo.day;
|
|
181
|
-
var nthWeek = this._getRangeInfo([range.start.time, date]).
|
|
191
|
+
var nthWeek = this._getRangeInfo([range.start.time, date]).nthWeek;
|
|
182
192
|
|
|
183
193
|
if (this._orient === 'vertical') {
|
|
184
194
|
return [
|
|
185
195
|
this._rect.x + week * this._sw + this._sw / 2,
|
|
186
|
-
this._rect.y +
|
|
196
|
+
this._rect.y + nthWeek * this._sh + this._sh / 2
|
|
187
197
|
];
|
|
188
198
|
|
|
189
199
|
}
|
|
190
200
|
|
|
191
201
|
return [
|
|
192
|
-
this._rect.x +
|
|
202
|
+
this._rect.x + nthWeek * this._sw + this._sw / 2,
|
|
193
203
|
this._rect.y + week * this._sh + this._sh / 2
|
|
194
204
|
];
|
|
195
205
|
|
|
@@ -255,7 +265,7 @@
|
|
|
255
265
|
/**
|
|
256
266
|
* Convert a (x, y) point to time date
|
|
257
267
|
*
|
|
258
|
-
* @param {
|
|
268
|
+
* @param {Array} point point
|
|
259
269
|
* @return {Object} date
|
|
260
270
|
*/
|
|
261
271
|
pointToDate: function (point) {
|
|
@@ -327,25 +337,60 @@
|
|
|
327
337
|
*
|
|
328
338
|
* @private
|
|
329
339
|
* @param {Array} range range ['2017-01-01', '2017-07-08']
|
|
340
|
+
* If range[0] > range[1], they will not be reversed.
|
|
330
341
|
* @return {Object} obj
|
|
331
342
|
*/
|
|
332
343
|
_getRangeInfo: function (range) {
|
|
344
|
+
range = [
|
|
345
|
+
this.getDateInfo(range[0]),
|
|
346
|
+
this.getDateInfo(range[1])
|
|
347
|
+
];
|
|
348
|
+
|
|
349
|
+
var reversed;
|
|
350
|
+
if (range[0].time > range[1].time) {
|
|
351
|
+
reversed = true;
|
|
352
|
+
range.reverse();
|
|
353
|
+
}
|
|
333
354
|
|
|
334
|
-
var
|
|
335
|
-
|
|
355
|
+
var allDay = Math.floor(range[1].time / PROXIMATE_ONE_DAY)
|
|
356
|
+
- Math.floor(range[0].time / PROXIMATE_ONE_DAY) + 1;
|
|
357
|
+
|
|
358
|
+
// Consider case:
|
|
359
|
+
// Firstly set system timezone as "Time Zone: America/Toronto",
|
|
360
|
+
// ```
|
|
361
|
+
// var first = new Date(1478412000000 - 3600 * 1000 * 2.5);
|
|
362
|
+
// var second = new Date(1478412000000);
|
|
363
|
+
// var allDays = Math.floor(second / ONE_DAY) - Math.floor(first / ONE_DAY) + 1;
|
|
364
|
+
// ```
|
|
365
|
+
// will get wrong result because of DST. So we should fix it.
|
|
366
|
+
var date = new Date(range[0].time);
|
|
367
|
+
var startDateNum = date.getDate();
|
|
368
|
+
var endDateNum = range[1].date.getDate();
|
|
369
|
+
date.setDate(startDateNum + allDay - 1);
|
|
370
|
+
// The bias can not over a month, so just compare date.
|
|
371
|
+
if (date.getDate() !== endDateNum) {
|
|
372
|
+
var sign = date.getTime() - range[1].time > 0 ? 1 : -1;
|
|
373
|
+
while (date.getDate() !== endDateNum && (date.getTime() - range[1].time) * sign > 0) {
|
|
374
|
+
allDay -= sign;
|
|
375
|
+
date.setDate(startDateNum + allDay - 1);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
336
378
|
|
|
337
|
-
var
|
|
379
|
+
var weeks = Math.floor((allDay + range[0].day + 6) / 7);
|
|
380
|
+
var nthWeek = reversed ? -weeks + 1: weeks - 1;
|
|
338
381
|
|
|
339
|
-
|
|
382
|
+
reversed && range.reverse();
|
|
340
383
|
|
|
341
384
|
return {
|
|
342
|
-
range: [
|
|
343
|
-
start:
|
|
344
|
-
end:
|
|
385
|
+
range: [range[0].formatedDate, range[1].formatedDate],
|
|
386
|
+
start: range[0],
|
|
387
|
+
end: range[1],
|
|
345
388
|
allDay: allDay,
|
|
346
389
|
weeks: weeks,
|
|
347
|
-
|
|
348
|
-
|
|
390
|
+
// From 0.
|
|
391
|
+
nthWeek: nthWeek,
|
|
392
|
+
fweek: range[0].day,
|
|
393
|
+
lweek: range[1].day
|
|
349
394
|
};
|
|
350
395
|
},
|
|
351
396
|
|
|
@@ -369,11 +414,10 @@
|
|
|
369
414
|
}
|
|
370
415
|
|
|
371
416
|
var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
|
|
417
|
+
var date = new Date(rangeInfo.start.time);
|
|
418
|
+
date.setDate(rangeInfo.start.d + nthDay);
|
|
372
419
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return this.getDateInfo(time);
|
|
376
|
-
|
|
420
|
+
return this.getDateInfo(date);
|
|
377
421
|
}
|
|
378
422
|
};
|
|
379
423
|
|
|
@@ -55,9 +55,7 @@
|
|
|
55
55
|
position: 'start',
|
|
56
56
|
margin: '50%', // 50% of cellSize
|
|
57
57
|
nameMap: 'en',
|
|
58
|
-
|
|
59
|
-
color: '#000'
|
|
60
|
-
}
|
|
58
|
+
color: '#000'
|
|
61
59
|
},
|
|
62
60
|
|
|
63
61
|
// month text style
|
|
@@ -74,9 +72,7 @@
|
|
|
74
72
|
// cn en []
|
|
75
73
|
nameMap: 'en',
|
|
76
74
|
formatter: null,
|
|
77
|
-
|
|
78
|
-
color: '#000'
|
|
79
|
-
}
|
|
75
|
+
color: '#000'
|
|
80
76
|
},
|
|
81
77
|
|
|
82
78
|
// year text style
|
|
@@ -87,12 +83,10 @@
|
|
|
87
83
|
position: null,
|
|
88
84
|
margin: 30,
|
|
89
85
|
formatter: null,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
fontSize: 20
|
|
95
|
-
}
|
|
86
|
+
color: '#ccc',
|
|
87
|
+
fontFamily: 'sans-serif',
|
|
88
|
+
fontWeight: 'bolder',
|
|
89
|
+
fontSize: 20
|
|
96
90
|
}
|
|
97
91
|
},
|
|
98
92
|
|
|
@@ -54,20 +54,6 @@
|
|
|
54
54
|
&& this.getAxis('y').containData(data[1]);
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
* Convert series data to an array of points
|
|
59
|
-
* @param {module:echarts/data/List} data
|
|
60
|
-
* @param {boolean} stack
|
|
61
|
-
* @return {Array}
|
|
62
|
-
* Return array of points. For example:
|
|
63
|
-
* `[[10, 10], [20, 20], [30, 30]]`
|
|
64
|
-
*/
|
|
65
|
-
dataToPoints: function (data, stack) {
|
|
66
|
-
return data.mapArray(['x', 'y'], function (x, y) {
|
|
67
|
-
return this.dataToPoint([x, y]);
|
|
68
|
-
}, stack, this);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
57
|
/**
|
|
72
58
|
* @param {Array.<number>} data
|
|
73
59
|
* @param {boolean} [clamp=false]
|
|
@@ -31,7 +31,7 @@ var factory = exports;
|
|
|
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 @@ var factory = exports;
|
|
|
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 @@ var factory = exports;
|
|
|
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 @@ var factory = exports;
|
|
|
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 @@ var factory = exports;
|
|
|
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 @@ var factory = exports;
|
|
|
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/lib/coord/geo/Geo.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
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 @@
|
|
|
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>}
|
|
@@ -23,17 +23,15 @@
|
|
|
23
23
|
init: function (option) {
|
|
24
24
|
ComponentModel.prototype.init.apply(this, arguments);
|
|
25
25
|
|
|
26
|
-
// Default label emphasis `
|
|
27
|
-
modelUtil.defaultEmphasis(
|
|
28
|
-
option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
|
|
29
|
-
);
|
|
26
|
+
// Default label emphasis `show`
|
|
27
|
+
modelUtil.defaultEmphasis(option.label, ['show']);
|
|
30
28
|
},
|
|
31
29
|
|
|
32
30
|
optionUpdated: function () {
|
|
33
31
|
var option = this.option;
|
|
34
32
|
var self = this;
|
|
35
33
|
|
|
36
|
-
option.regions = geoCreator.getFilledRegions(option.regions, option.map);
|
|
34
|
+
option.regions = geoCreator.getFilledRegions(option.regions, option.map, option.nameMap);
|
|
37
35
|
|
|
38
36
|
this._optionModelMap = zrUtil.reduce(option.regions || [], function (optionModelMap, regionOpt) {
|
|
39
37
|
if (regionOpt.name) {
|
|
@@ -95,15 +93,11 @@
|
|
|
95
93
|
label: {
|
|
96
94
|
normal: {
|
|
97
95
|
show: false,
|
|
98
|
-
|
|
99
|
-
color: '#000'
|
|
100
|
-
}
|
|
96
|
+
color: '#000'
|
|
101
97
|
},
|
|
102
98
|
emphasis: {
|
|
103
99
|
show: true,
|
|
104
|
-
|
|
105
|
-
color: 'rgb(100,0,0)'
|
|
106
|
-
}
|
|
100
|
+
color: 'rgb(100,0,0)'
|
|
107
101
|
}
|
|
108
102
|
},
|
|
109
103
|
|
|
@@ -148,8 +142,7 @@
|
|
|
148
142
|
return formatter(params);
|
|
149
143
|
}
|
|
150
144
|
else if (typeof formatter === 'string') {
|
|
151
|
-
|
|
152
|
-
return formatter.replace('{a}', serName != null ? serName : '');
|
|
145
|
+
return formatter.replace('{a}', name != null ? name : '');
|
|
153
146
|
}
|
|
154
147
|
},
|
|
155
148
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Fix for 钓鱼岛
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// var Region = require('../Region');
|
|
5
|
+
// var zrUtil = require('zrender/lib/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
|
+
module.exports = 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 @@
|
|
|
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 @@
|
|
|
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/lib/coord/polar/Polar.js
CHANGED
|
@@ -163,19 +163,6 @@
|
|
|
163
163
|
};
|
|
164
164
|
},
|
|
165
165
|
|
|
166
|
-
/**
|
|
167
|
-
* Convert series data to a list of (x, y) points
|
|
168
|
-
* @param {module:echarts/data/List} data
|
|
169
|
-
* @return {Array}
|
|
170
|
-
* Return list of coordinates. For example:
|
|
171
|
-
* `[[10, 10], [20, 20], [30, 30]]`
|
|
172
|
-
*/
|
|
173
|
-
dataToPoints: function (data) {
|
|
174
|
-
return data.mapArray(this.dimensions, function (radius, angle) {
|
|
175
|
-
return this.dataToPoint([radius, angle]);
|
|
176
|
-
}, true, this);
|
|
177
|
-
},
|
|
178
|
-
|
|
179
166
|
/**
|
|
180
167
|
* Convert a single data item to (x, y) point.
|
|
181
168
|
* Parameter data is an array which the first element is radius and the second is angle
|
package/lib/coord/radar/Radar.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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/lib/data/DataDiffer.js
CHANGED
|
@@ -5,12 +5,21 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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);
|