echarts 4.5.0-rc.2 → 4.8.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/.github/pull_request_template.md +66 -0
- package/.github/workflows/nodejs.yml +12 -2
- package/CONTRIBUTING.md +16 -160
- package/NOTICE +1 -1
- package/README.md +2 -2
- package/dist/echarts-en.common.js +2808 -1188
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +3559 -1437
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +2453 -1002
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +2782 -1188
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +3533 -1437
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +2427 -1002
- package/dist/echarts.simple.min.js +1 -1
- package/dist/extension/bmap.js +336 -2
- package/dist/extension/bmap.js.map +1 -1
- package/dist/extension/bmap.min.js +1 -1
- package/extension/bmap/BMapView.js +6 -2
- package/extension-src/bmap/BMapView.js +3 -2
- package/lib/chart/bar/BarSeries.js +14 -1
- package/lib/chart/bar/BarView.js +161 -16
- package/lib/chart/bar/BaseBarSeries.js +3 -1
- package/lib/chart/candlestick/candlestickVisual.js +1 -1
- package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
- package/lib/chart/funnel/FunnelSeries.js +13 -5
- package/lib/chart/gauge/GaugeSeries.js +0 -2
- package/lib/chart/graph/GraphSeries.js +11 -5
- package/lib/chart/graph/GraphView.js +30 -12
- package/lib/chart/heatmap/HeatmapView.js +4 -4
- package/lib/chart/helper/EffectLine.js +23 -1
- package/lib/chart/helper/EffectSymbol.js +2 -1
- package/lib/chart/helper/Line.js +94 -33
- package/lib/chart/helper/LineDraw.js +5 -1
- package/lib/chart/helper/Symbol.js +1 -2
- package/lib/chart/helper/createClipPathFromCoordSys.js +4 -1
- package/lib/chart/helper/createListFromArray.js +14 -8
- package/lib/chart/helper/createRenderPlanner.js +6 -3
- package/lib/chart/helper/whiskerBoxCommon.js +22 -16
- package/lib/chart/line/LineSeries.js +3 -1
- package/lib/chart/line/LineView.js +41 -2
- package/lib/chart/map/MapSeries.js +11 -3
- package/lib/chart/pie/PieSeries.js +27 -6
- package/lib/chart/pie/PieView.js +22 -15
- package/lib/chart/pie/labelLayout.js +102 -19
- package/lib/chart/pie/pieLayout.js +19 -7
- package/lib/chart/radar/RadarSeries.js +23 -3
- package/lib/chart/sankey/SankeySeries.js +13 -1
- package/lib/chart/sankey/SankeyView.js +70 -32
- package/lib/chart/sankey/sankeyLayout.js +22 -3
- package/lib/chart/scatter/ScatterSeries.js +3 -1
- package/lib/chart/sunburst/SunburstPiece.js +1 -0
- package/lib/chart/sunburst/SunburstSeries.js +12 -7
- package/lib/chart/sunburst/SunburstView.js +5 -1
- package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
- package/lib/chart/tree/TreeSeries.js +20 -3
- package/lib/chart/tree/TreeView.js +151 -25
- package/lib/chart/treemap/TreemapSeries.js +15 -3
- package/lib/chart/treemap/TreemapView.js +80 -38
- package/lib/component/axis/AngleAxisView.js +64 -7
- package/lib/component/axis/AxisBuilder.js +62 -24
- package/lib/component/axis/CartesianAxisView.js +52 -85
- package/lib/component/axis/RadiusAxisView.js +36 -4
- package/lib/component/axis/SingleAxisView.js +21 -6
- package/lib/component/axis/axisSplitHelper.js +132 -0
- package/lib/component/brush/BrushView.js +11 -1
- package/lib/component/brush/visualEncoding.js +13 -2
- package/lib/component/dataZoom/SliderZoomView.js +4 -10
- package/lib/component/helper/BrushController.js +33 -43
- package/lib/component/helper/MapDraw.js +30 -4
- package/lib/component/legend/LegendModel.js +3 -3
- package/lib/component/legend/LegendView.js +17 -13
- package/lib/component/legend/ScrollableLegendView.js +18 -18
- package/lib/component/marker/MarkLineModel.js +2 -1
- package/lib/component/marker/markerHelper.js +7 -4
- package/lib/component/title.js +6 -2
- package/lib/component/toolbox/ToolboxView.js +5 -1
- package/lib/component/toolbox/feature/MagicType.js +20 -14
- package/lib/component/toolbox/feature/SaveAsImage.js +2 -1
- package/lib/component/tooltip/TooltipContent.js +60 -23
- package/lib/component/tooltip/TooltipView.js +7 -8
- package/lib/component/visualMap/PiecewiseModel.js +3 -6
- package/lib/coord/Axis.js +30 -2
- package/lib/coord/View.js +9 -0
- package/lib/coord/axisDefault.js +21 -2
- package/lib/coord/axisHelper.js +22 -16
- package/lib/coord/calendar/Calendar.js +8 -4
- package/lib/coord/geo/geoJSONLoader.js +3 -2
- package/lib/coord/geo/geoSourceManager.js +3 -2
- package/lib/coord/geo/parseGeoJson.js +3 -2
- package/lib/coord/radar/Radar.js +5 -5
- package/lib/data/DataDimensionInfo.js +157 -0
- package/lib/data/List.js +25 -19
- package/lib/data/Tree.js +9 -19
- package/lib/data/helper/completeDimensions.js +43 -32
- package/lib/data/helper/createDimensions.js +2 -0
- package/lib/data/helper/sourceHelper.js +214 -114
- package/lib/echarts.js +57 -34
- package/lib/langEN.js +26 -0
- package/lib/layout/barGrid.js +19 -13
- package/lib/layout/barPolar.js +0 -5
- package/lib/loading/default.js +43 -27
- package/lib/model/Series.js +4 -4
- package/lib/model/referHelper.js +40 -12
- package/lib/scale/Interval.js +87 -2
- package/lib/scale/Log.js +9 -2
- package/lib/scale/helper.js +1 -43
- package/lib/stream/Scheduler.js +9 -1
- package/lib/theme/dark.js +3 -0
- package/lib/util/format.js +19 -2
- package/lib/util/graphic.js +14 -12
- package/lib/visual/LegendVisualProvider.js +75 -0
- package/lib/visual/dataColor.js +2 -12
- package/lib/visual/seriesColor.js +15 -7
- package/lib/visual/symbol.js +12 -2
- package/map/js/china.js +1 -1
- package/map/js/province/chongqing.js +1 -1
- package/map/js/province/gansu.js +2 -2
- package/map/js/province/tianjin.js +1 -28
- package/map/json/china.json +1 -1
- package/map/json/province/chongqing.json +1 -1
- package/map/json/province/tianjin.json +1 -1
- package/package.json +11 -6
- package/src/chart/bar/BarSeries.js +15 -1
- package/src/chart/bar/BarView.js +162 -15
- package/src/chart/bar/BaseBarSeries.js +1 -1
- package/src/chart/candlestick/candlestickVisual.js +1 -1
- package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
- package/src/chart/funnel/FunnelSeries.js +10 -4
- package/src/chart/gauge/GaugeSeries.js +0 -1
- package/src/chart/graph/GraphSeries.js +10 -4
- package/src/chart/graph/GraphView.js +28 -10
- package/src/chart/heatmap/HeatmapView.js +4 -4
- package/src/chart/helper/EffectLine.js +23 -1
- package/src/chart/helper/EffectSymbol.js +2 -1
- package/src/chart/helper/Line.js +84 -26
- package/src/chart/helper/LineDraw.js +5 -1
- package/src/chart/helper/Symbol.js +2 -2
- package/src/chart/helper/createClipPathFromCoordSys.js +4 -0
- package/src/chart/helper/createListFromArray.js +13 -8
- package/src/chart/helper/createRenderPlanner.js +5 -2
- package/src/chart/helper/whiskerBoxCommon.js +21 -16
- package/src/chart/line/LineSeries.js +1 -1
- package/src/chart/line/LineView.js +45 -1
- package/src/chart/map/MapSeries.js +8 -3
- package/src/chart/pie/PieSeries.js +26 -5
- package/src/chart/pie/PieView.js +20 -15
- package/src/chart/pie/labelLayout.js +114 -22
- package/src/chart/pie/pieLayout.js +20 -7
- package/src/chart/radar/RadarSeries.js +27 -3
- package/src/chart/sankey/SankeySeries.js +12 -1
- package/src/chart/sankey/SankeyView.js +75 -30
- package/src/chart/sankey/sankeyLayout.js +25 -5
- package/src/chart/scatter/ScatterSeries.js +1 -1
- package/src/chart/sunburst/SunburstPiece.js +2 -0
- package/src/chart/sunburst/SunburstSeries.js +12 -7
- package/src/chart/sunburst/SunburstView.js +2 -1
- package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
- package/src/chart/tree/TreeSeries.js +19 -6
- package/src/chart/tree/TreeView.js +155 -22
- package/src/chart/treemap/TreemapSeries.js +15 -5
- package/src/chart/treemap/TreemapView.js +77 -41
- package/src/component/axis/AngleAxisView.js +75 -7
- package/src/component/axis/AxisBuilder.js +77 -32
- package/src/component/axis/CartesianAxisView.js +47 -83
- package/src/component/axis/RadiusAxisView.js +37 -4
- package/src/component/axis/SingleAxisView.js +21 -4
- package/src/component/axis/axisSplitHelper.js +114 -0
- package/src/component/brush/BrushView.js +8 -1
- package/src/component/brush/visualEncoding.js +6 -3
- package/src/component/dataZoom/SliderZoomView.js +4 -9
- package/src/component/helper/BrushController.js +40 -47
- package/src/component/helper/MapDraw.js +27 -4
- package/src/component/legend/LegendModel.js +3 -3
- package/src/component/legend/LegendView.js +18 -12
- package/src/component/legend/ScrollableLegendView.js +18 -16
- package/src/component/marker/MarkLineModel.js +2 -1
- package/src/component/marker/markerHelper.js +8 -5
- package/src/component/title.js +3 -2
- package/src/component/toolbox/ToolboxView.js +5 -0
- package/src/component/toolbox/feature/MagicType.js +19 -13
- package/src/component/toolbox/feature/SaveAsImage.js +2 -1
- package/src/component/tooltip/TooltipContent.js +59 -22
- package/src/component/tooltip/TooltipView.js +10 -8
- package/src/component/visualMap/PiecewiseModel.js +5 -9
- package/src/coord/Axis.js +29 -2
- package/src/coord/View.js +10 -1
- package/src/coord/axisDefault.js +25 -1
- package/src/coord/axisHelper.js +26 -19
- package/src/coord/calendar/Calendar.js +12 -5
- package/src/coord/geo/geoJSONLoader.js +3 -2
- package/src/coord/geo/geoSourceManager.js +3 -2
- package/src/coord/geo/parseGeoJson.js +3 -2
- package/src/coord/radar/Radar.js +6 -8
- package/src/data/DataDimensionInfo.js +135 -0
- package/src/data/List.js +29 -16
- package/src/data/Tree.js +12 -17
- package/src/data/helper/completeDimensions.js +49 -30
- package/src/data/helper/createDimensions.js +2 -0
- package/src/data/helper/sourceHelper.js +216 -124
- package/src/echarts.js +60 -36
- package/src/langEN.js +26 -0
- package/src/layout/barGrid.js +22 -10
- package/src/layout/barPolar.js +0 -4
- package/src/loading/default.js +46 -34
- package/src/model/Series.js +4 -4
- package/src/model/referHelper.js +34 -11
- package/src/scale/Interval.js +84 -4
- package/src/scale/Log.js +9 -2
- package/src/scale/helper.js +1 -39
- package/src/stream/Scheduler.js +8 -0
- package/src/theme/dark.js +3 -0
- package/src/util/format.js +17 -1
- package/src/util/graphic.js +13 -11
- package/src/visual/LegendVisualProvider.js +55 -0
- package/src/visual/dataColor.js +0 -13
- package/src/visual/seriesColor.js +13 -7
- package/src/visual/symbol.js +11 -2
- package/theme/azul.js +163 -0
- package/theme/bee-inspired.js +178 -0
- package/theme/blue.js +178 -0
- package/theme/caravan.js +178 -0
- package/theme/carp.js +163 -0
- package/theme/cool.js +180 -0
- package/theme/dark-blue.js +168 -0
- package/theme/dark-bold.js +168 -0
- package/theme/dark-digerati.js +168 -0
- package/theme/dark-fresh-cut.js +168 -0
- package/theme/dark-mushroom.js +168 -0
- package/theme/dark.js +69 -62
- package/theme/eduardo.js +178 -0
- package/theme/forest.js +163 -0
- package/theme/fresh-cut.js +163 -0
- package/theme/fruit.js +178 -0
- package/theme/gray.js +220 -0
- package/theme/green.js +222 -0
- package/theme/helianthus.js +263 -0
- package/theme/infographic.js +72 -57
- package/theme/inspired.js +163 -0
- package/theme/jazz.js +163 -0
- package/theme/london.js +163 -0
- package/theme/macarons.js +80 -57
- package/theme/macarons2.js +251 -0
- package/theme/mint.js +155 -0
- package/theme/red-velvet.js +163 -0
- package/theme/red.js +225 -0
- package/theme/roma.js +55 -22
- package/theme/royal.js +163 -0
- package/theme/sakura.js +140 -0
- package/theme/shine.js +52 -45
- package/theme/tech-blue.js +180 -0
- package/theme/vintage.js +37 -23
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
* or more contributor license agreements. See the NOTICE file
|
|
5
|
+
* distributed with this work for additional information
|
|
6
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
* to you under the Apache License, Version 2.0 (the
|
|
8
|
+
* "License"); you may not use this file except in compliance
|
|
9
|
+
* with the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var zrUtil = require("zrender/lib/core/util");
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
25
|
+
* or more contributor license agreements. See the NOTICE file
|
|
26
|
+
* distributed with this work for additional information
|
|
27
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
28
|
+
* to you under the Apache License, Version 2.0 (the
|
|
29
|
+
* "License"); you may not use this file except in compliance
|
|
30
|
+
* with the License. You may obtain a copy of the License at
|
|
31
|
+
*
|
|
32
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing,
|
|
35
|
+
* software distributed under the License is distributed on an
|
|
36
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
37
|
+
* KIND, either express or implied. See the License for the
|
|
38
|
+
* specific language governing permissions and limitations
|
|
39
|
+
* under the License.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @class
|
|
44
|
+
* @param {Object|DataDimensionInfo} [opt] All of the fields will be shallow copied.
|
|
45
|
+
*/
|
|
46
|
+
function DataDimensionInfo(opt) {
|
|
47
|
+
if (opt != null) {
|
|
48
|
+
zrUtil.extend(this, opt);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Dimension name.
|
|
52
|
+
* Mandatory.
|
|
53
|
+
* @type {string}
|
|
54
|
+
*/
|
|
55
|
+
// this.name;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The origin name in dimsDef, see source helper.
|
|
59
|
+
* If displayName given, the tooltip will displayed vertically.
|
|
60
|
+
* Optional.
|
|
61
|
+
* @type {string}
|
|
62
|
+
*/
|
|
63
|
+
// this.displayName;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Which coordSys dimension this dimension mapped to.
|
|
67
|
+
* A `coordDim` can be a "coordSysDim" that the coordSys required
|
|
68
|
+
* (for example, an item in `coordSysDims` of `model/referHelper#CoordSysInfo`),
|
|
69
|
+
* or an generated "extra coord name" if does not mapped to any "coordSysDim"
|
|
70
|
+
* (That is determined by whether `isExtraCoord` is `true`).
|
|
71
|
+
* Mandatory.
|
|
72
|
+
* @type {string}
|
|
73
|
+
*/
|
|
74
|
+
// this.coordDim;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The index of this dimension in `series.encode[coordDim]`.
|
|
78
|
+
* Mandatory.
|
|
79
|
+
* @type {number}
|
|
80
|
+
*/
|
|
81
|
+
// this.coordDimIndex;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Dimension type. The enumerable values are the key of
|
|
85
|
+
* `dataCtors` of `data/List`.
|
|
86
|
+
* Optional.
|
|
87
|
+
* @type {string}
|
|
88
|
+
*/
|
|
89
|
+
// this.type;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* This index of this dimension info in `data/List#_dimensionInfos`.
|
|
93
|
+
* Mandatory after added to `data/List`.
|
|
94
|
+
* @type {number}
|
|
95
|
+
*/
|
|
96
|
+
// this.index;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The format of `otherDims` is:
|
|
100
|
+
* ```js
|
|
101
|
+
* {
|
|
102
|
+
* tooltip: number optional,
|
|
103
|
+
* label: number optional,
|
|
104
|
+
* itemName: number optional,
|
|
105
|
+
* seriesName: number optional,
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* A `series.encode` can specified these fields:
|
|
110
|
+
* ```js
|
|
111
|
+
* encode: {
|
|
112
|
+
* // "3, 1, 5" is the index of data dimension.
|
|
113
|
+
* tooltip: [3, 1, 5],
|
|
114
|
+
* label: [0, 3],
|
|
115
|
+
* ...
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
* `otherDims` is the parse result of the `series.encode` above, like:
|
|
119
|
+
* ```js
|
|
120
|
+
* // Suppose the index of this data dimension is `3`.
|
|
121
|
+
* this.otherDims = {
|
|
122
|
+
* // `3` is at the index `0` of the `encode.tooltip`
|
|
123
|
+
* tooltip: 0,
|
|
124
|
+
* // `3` is at the index `1` of the `encode.tooltip`
|
|
125
|
+
* label: 1
|
|
126
|
+
* };
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* This prop should never be `null`/`undefined` after initialized.
|
|
130
|
+
* @type {Object}
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
this.otherDims = {};
|
|
135
|
+
/**
|
|
136
|
+
* Be `true` if this dimension is not mapped to any "coordSysDim" that the
|
|
137
|
+
* "coordSys" required.
|
|
138
|
+
* Mandatory.
|
|
139
|
+
* @type {boolean}
|
|
140
|
+
*/
|
|
141
|
+
// this.isExtraCoord;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @type {module:data/OrdinalMeta}
|
|
145
|
+
*/
|
|
146
|
+
// this.ordinalMeta;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether to create inverted indices.
|
|
150
|
+
* @type {boolean}
|
|
151
|
+
*/
|
|
152
|
+
// this.createInvertedIndices;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
;
|
|
156
|
+
var _default = DataDimensionInfo;
|
|
157
|
+
module.exports = _default;
|
package/lib/data/List.js
CHANGED
|
@@ -39,6 +39,8 @@ var _dimensionHelper = require("./helper/dimensionHelper");
|
|
|
39
39
|
|
|
40
40
|
var summarizeDimensions = _dimensionHelper.summarizeDimensions;
|
|
41
41
|
|
|
42
|
+
var DataDimensionInfo = require("./DataDimensionInfo");
|
|
43
|
+
|
|
42
44
|
/*
|
|
43
45
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
44
46
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -114,13 +116,9 @@ function transferProperties(target, source) {
|
|
|
114
116
|
* @constructor
|
|
115
117
|
* @alias module:echarts/data/List
|
|
116
118
|
*
|
|
117
|
-
* @param {Array.<string|Object>} dimensions
|
|
119
|
+
* @param {Array.<string|Object|module:data/DataDimensionInfo>} dimensions
|
|
118
120
|
* For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
|
|
119
121
|
* Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
|
|
120
|
-
* Spetial fields: {
|
|
121
|
-
* ordinalMeta: <module:echarts/data/OrdinalMeta>
|
|
122
|
-
* createInvertedIndices: <boolean>
|
|
123
|
-
* }
|
|
124
122
|
* @param {module:echarts/model/Model} hostModel
|
|
125
123
|
*/
|
|
126
124
|
|
|
@@ -136,9 +134,11 @@ var List = function (dimensions, hostModel) {
|
|
|
136
134
|
var dimensionInfo = dimensions[i];
|
|
137
135
|
|
|
138
136
|
if (zrUtil.isString(dimensionInfo)) {
|
|
139
|
-
dimensionInfo = {
|
|
137
|
+
dimensionInfo = new DataDimensionInfo({
|
|
140
138
|
name: dimensionInfo
|
|
141
|
-
};
|
|
139
|
+
});
|
|
140
|
+
} else if (!(dimensionInfo instanceof DataDimensionInfo)) {
|
|
141
|
+
dimensionInfo = new DataDimensionInfo(dimensionInfo);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
var dimensionName = dimensionInfo.name;
|
|
@@ -1182,7 +1182,8 @@ listProto.indexOfRawIndex = function (rawIndex) {
|
|
|
1182
1182
|
* @param {string} dim
|
|
1183
1183
|
* @param {number} value
|
|
1184
1184
|
* @param {number} [maxDistance=Infinity]
|
|
1185
|
-
* @return {Array.<number>}
|
|
1185
|
+
* @return {Array.<number>} If and only if multiple indices has
|
|
1186
|
+
* the same value, they are put to the result.
|
|
1186
1187
|
*/
|
|
1187
1188
|
|
|
1188
1189
|
|
|
@@ -1199,29 +1200,34 @@ listProto.indicesOfNearest = function (dim, value, maxDistance) {
|
|
|
1199
1200
|
maxDistance = Infinity;
|
|
1200
1201
|
}
|
|
1201
1202
|
|
|
1202
|
-
var minDist =
|
|
1203
|
+
var minDist = Infinity;
|
|
1203
1204
|
var minDiff = -1;
|
|
1205
|
+
var nearestIndicesLen = 0; // Check the test case of `test/ut/spec/data/List.js`.
|
|
1204
1206
|
|
|
1205
1207
|
for (var i = 0, len = this.count(); i < len; i++) {
|
|
1206
|
-
var diff = value - this.get(dim, i
|
|
1207
|
-
/*, stack */
|
|
1208
|
-
);
|
|
1208
|
+
var diff = value - this.get(dim, i);
|
|
1209
1209
|
var dist = Math.abs(diff);
|
|
1210
1210
|
|
|
1211
|
-
if (
|
|
1212
|
-
//
|
|
1213
|
-
//
|
|
1214
|
-
//
|
|
1215
|
-
|
|
1211
|
+
if (dist <= maxDistance) {
|
|
1212
|
+
// When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,
|
|
1213
|
+
// we'd better not push both of them to `nearestIndices`, otherwise it is easy to
|
|
1214
|
+
// get more than one item in `nearestIndices` (more specifically, in `tooltip`).
|
|
1215
|
+
// So we chose the one that `diff >= 0` in this csae.
|
|
1216
|
+
// But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them
|
|
1217
|
+
// should be push to `nearestIndices`.
|
|
1218
|
+
if (dist < minDist || dist === minDist && diff >= 0 && minDiff < 0) {
|
|
1216
1219
|
minDist = dist;
|
|
1217
1220
|
minDiff = diff;
|
|
1218
|
-
|
|
1221
|
+
nearestIndicesLen = 0;
|
|
1219
1222
|
}
|
|
1220
1223
|
|
|
1221
|
-
|
|
1224
|
+
if (diff === minDiff) {
|
|
1225
|
+
nearestIndices[nearestIndicesLen++] = i;
|
|
1226
|
+
}
|
|
1222
1227
|
}
|
|
1223
1228
|
}
|
|
1224
1229
|
|
|
1230
|
+
nearestIndices.length = nearestIndicesLen;
|
|
1225
1231
|
return nearestIndices;
|
|
1226
1232
|
};
|
|
1227
1233
|
/**
|
package/lib/data/Tree.js
CHANGED
|
@@ -281,14 +281,13 @@ TreeNode.prototype = {
|
|
|
281
281
|
|
|
282
282
|
var hostTree = this.hostTree;
|
|
283
283
|
var itemModel = hostTree.data.getItemModel(this.dataIndex);
|
|
284
|
-
var levelModel = this.getLevelModel();
|
|
285
|
-
var leavesModel;
|
|
284
|
+
var levelModel = this.getLevelModel(); // FIXME: refactor levelModel to "beforeLink", and remove levelModel here.
|
|
286
285
|
|
|
287
|
-
if (
|
|
288
|
-
|
|
286
|
+
if (levelModel) {
|
|
287
|
+
return itemModel.getModel(path, levelModel.getModel(path));
|
|
288
|
+
} else {
|
|
289
|
+
return itemModel.getModel(path);
|
|
289
290
|
}
|
|
290
|
-
|
|
291
|
-
return itemModel.getModel(path, (levelModel || leavesModel || hostTree.hostModel).getModel(path));
|
|
292
291
|
},
|
|
293
292
|
|
|
294
293
|
/**
|
|
@@ -298,13 +297,6 @@ TreeNode.prototype = {
|
|
|
298
297
|
return (this.hostTree.levelModels || [])[this.depth];
|
|
299
298
|
},
|
|
300
299
|
|
|
301
|
-
/**
|
|
302
|
-
* @return {module:echarts/model/Model}
|
|
303
|
-
*/
|
|
304
|
-
getLeavesModel: function () {
|
|
305
|
-
return this.hostTree.leavesModel;
|
|
306
|
-
},
|
|
307
|
-
|
|
308
300
|
/**
|
|
309
301
|
* @example
|
|
310
302
|
* setItemVisual('color', color);
|
|
@@ -376,10 +368,9 @@ TreeNode.prototype = {
|
|
|
376
368
|
* @alias module:echarts/data/Tree
|
|
377
369
|
* @param {module:echarts/model/Model} hostModel
|
|
378
370
|
* @param {Array.<Object>} levelOptions
|
|
379
|
-
* @param {Object} leavesOption
|
|
380
371
|
*/
|
|
381
372
|
|
|
382
|
-
function Tree(hostModel, levelOptions
|
|
373
|
+
function Tree(hostModel, levelOptions) {
|
|
383
374
|
/**
|
|
384
375
|
* @type {module:echarts/data/Tree~TreeNode}
|
|
385
376
|
* @readOnly
|
|
@@ -414,7 +405,6 @@ function Tree(hostModel, levelOptions, leavesOption) {
|
|
|
414
405
|
this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
|
|
415
406
|
return new Model(levelDefine, hostModel, hostModel.ecModel);
|
|
416
407
|
});
|
|
417
|
-
this.leavesModel = new Model(leavesOption || {}, hostModel, hostModel.ecModel);
|
|
418
408
|
}
|
|
419
409
|
|
|
420
410
|
Tree.prototype = {
|
|
@@ -503,12 +493,11 @@ Tree.prototype = {
|
|
|
503
493
|
* @param {module:echarts/model/Model} hostModel
|
|
504
494
|
* @param {Object} treeOptions
|
|
505
495
|
* @param {Array.<Object>} treeOptions.levels
|
|
506
|
-
* @param {Array.<Object>} treeOptions.leaves
|
|
507
496
|
* @return module:echarts/data/Tree
|
|
508
497
|
*/
|
|
509
498
|
|
|
510
|
-
Tree.createTree = function (dataRoot, hostModel, treeOptions) {
|
|
511
|
-
var tree = new Tree(hostModel, treeOptions
|
|
499
|
+
Tree.createTree = function (dataRoot, hostModel, treeOptions, beforeLink) {
|
|
500
|
+
var tree = new Tree(hostModel, treeOptions && treeOptions.levels);
|
|
512
501
|
var listData = [];
|
|
513
502
|
var dimMax = 1;
|
|
514
503
|
buildHierarchy(dataRoot);
|
|
@@ -538,6 +527,7 @@ Tree.createTree = function (dataRoot, hostModel, treeOptions) {
|
|
|
538
527
|
});
|
|
539
528
|
var list = new List(dimensionsInfo, hostModel);
|
|
540
529
|
list.initData(listData);
|
|
530
|
+
beforeLink && beforeLink(list);
|
|
541
531
|
linkList({
|
|
542
532
|
mainData: list,
|
|
543
533
|
struct: tree,
|
|
@@ -35,6 +35,7 @@ var normalizeToArray = _model.normalizeToArray;
|
|
|
35
35
|
var _sourceHelper = require("./sourceHelper");
|
|
36
36
|
|
|
37
37
|
var guessOrdinal = _sourceHelper.guessOrdinal;
|
|
38
|
+
var BE_ORDINAL = _sourceHelper.BE_ORDINAL;
|
|
38
39
|
|
|
39
40
|
var Source = require("../Source");
|
|
40
41
|
|
|
@@ -42,6 +43,8 @@ var _dimensionHelper = require("./dimensionHelper");
|
|
|
42
43
|
|
|
43
44
|
var OTHER_DIMENSIONS = _dimensionHelper.OTHER_DIMENSIONS;
|
|
44
45
|
|
|
46
|
+
var DataDimensionInfo = require("../DataDimensionInfo");
|
|
47
|
+
|
|
45
48
|
/*
|
|
46
49
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
47
50
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -69,8 +72,12 @@ var OTHER_DIMENSIONS = _dimensionHelper.OTHER_DIMENSIONS;
|
|
|
69
72
|
/**
|
|
70
73
|
* @see {module:echarts/test/ut/spec/data/completeDimensions}
|
|
71
74
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
75
|
+
* This method builds the relationship between:
|
|
76
|
+
* + "what the coord sys or series requires (see `sysDims`)",
|
|
77
|
+
* + "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
|
|
78
|
+
* + "what the data source provids (see `source`)".
|
|
79
|
+
*
|
|
80
|
+
* Some guess strategy will be adapted if user does not define something.
|
|
74
81
|
* If no 'value' dimension specified, the first no-named dimension will be
|
|
75
82
|
* named as 'value'.
|
|
76
83
|
*
|
|
@@ -86,32 +93,20 @@ var OTHER_DIMENSIONS = _dimensionHelper.OTHER_DIMENSIONS;
|
|
|
86
93
|
* @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
|
|
87
94
|
* For example: ['asdf', {name, type}, ...].
|
|
88
95
|
* @param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
|
|
96
|
+
* @param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
|
|
97
|
+
* If not specified, auto find the next available data dim.
|
|
98
|
+
* param source {module:data/Source}
|
|
99
|
+
* param dimCount {number}
|
|
100
|
+
* return {Object} encode Never be `null/undefined`.
|
|
89
101
|
* @param {string} [opt.generateCoord] Generate coord dim with the given name.
|
|
90
|
-
*
|
|
91
|
-
*
|
|
102
|
+
* If not specified, extra dim names will be:
|
|
103
|
+
* 'value', 'value0', 'value1', ...
|
|
92
104
|
* @param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* If `generateCoordCount` specified, the generated dim names will be:
|
|
106
|
+
* `generateCoord` + 0, `generateCoord` + 1, ...
|
|
107
|
+
* can be Infinity, indicate that use all of the remain columns.
|
|
96
108
|
* @param {number} [opt.dimCount] If not specified, guess by the first data item.
|
|
97
|
-
* @
|
|
98
|
-
* @return {Array.<Object>} [{
|
|
99
|
-
* name: string mandatory,
|
|
100
|
-
* displayName: string, the origin name in dimsDef, see source helper.
|
|
101
|
-
* If displayName given, the tooltip will displayed vertically.
|
|
102
|
-
* coordDim: string mandatory,
|
|
103
|
-
* coordDimIndex: number mandatory,
|
|
104
|
-
* type: string optional,
|
|
105
|
-
* otherDims: { never null/undefined
|
|
106
|
-
* tooltip: number optional,
|
|
107
|
-
* label: number optional,
|
|
108
|
-
* itemName: number optional,
|
|
109
|
-
* seriesName: number optional,
|
|
110
|
-
* },
|
|
111
|
-
* isExtraCoord: boolean true if coord is generated
|
|
112
|
-
* (not specified in encode and not series specified)
|
|
113
|
-
* other props ...
|
|
114
|
-
* }]
|
|
109
|
+
* @return {Array.<module:data/DataDimensionInfo>}
|
|
115
110
|
*/
|
|
116
111
|
function completeDimensions(sysDims, source, opt) {
|
|
117
112
|
if (!Source.isInstance(source)) {
|
|
@@ -121,7 +116,6 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
121
116
|
opt = opt || {};
|
|
122
117
|
sysDims = (sysDims || []).slice();
|
|
123
118
|
var dimsDef = (opt.dimsDef || []).slice();
|
|
124
|
-
var encodeDef = createHashMap(opt.encodeDef);
|
|
125
119
|
var dataDimNameMap = createHashMap();
|
|
126
120
|
var coordDimNameMap = createHashMap(); // var valueCandidate;
|
|
127
121
|
|
|
@@ -133,9 +127,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
133
127
|
name: dimsDef[i]
|
|
134
128
|
});
|
|
135
129
|
var userDimName = dimDefItem.name;
|
|
136
|
-
var resultItem = result[i] =
|
|
137
|
-
otherDims: {}
|
|
138
|
-
}; // Name will be applied later for avoiding duplication.
|
|
130
|
+
var resultItem = result[i] = new DataDimensionInfo(); // Name will be applied later for avoiding duplication.
|
|
139
131
|
|
|
140
132
|
if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
|
|
141
133
|
// Only if `series.dimensions` is defined in option
|
|
@@ -147,8 +139,15 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
147
139
|
|
|
148
140
|
dimDefItem.type != null && (resultItem.type = dimDefItem.type);
|
|
149
141
|
dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
|
|
150
|
-
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var encodeDef = opt.encodeDef;
|
|
145
|
+
|
|
146
|
+
if (!encodeDef && opt.encodeDefaulter) {
|
|
147
|
+
encodeDef = opt.encodeDefaulter(source, dimCount);
|
|
148
|
+
}
|
|
151
149
|
|
|
150
|
+
encodeDef = createHashMap(encodeDef); // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
|
|
152
151
|
|
|
153
152
|
encodeDef.each(function (dataDims, coordDim) {
|
|
154
153
|
dataDims = normalizeToArray(dataDims).slice(); // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
|
|
@@ -249,7 +248,7 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
249
248
|
var extra = generateCoord || 'value'; // Set dim `name` and other `coordDim` and other props.
|
|
250
249
|
|
|
251
250
|
for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
|
|
252
|
-
var resultItem = result[resultDimIdx] = result[resultDimIdx] ||
|
|
251
|
+
var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
|
|
253
252
|
var coordDim = resultItem.coordDim;
|
|
254
253
|
|
|
255
254
|
if (coordDim == null) {
|
|
@@ -265,7 +264,19 @@ function completeDimensions(sysDims, source, opt) {
|
|
|
265
264
|
|
|
266
265
|
resultItem.name == null && (resultItem.name = genName(resultItem.coordDim, dataDimNameMap));
|
|
267
266
|
|
|
268
|
-
if (resultItem.type == null && guessOrdinal(source, resultDimIdx, resultItem.name)
|
|
267
|
+
if (resultItem.type == null && (guessOrdinal(source, resultDimIdx, resultItem.name) === BE_ORDINAL.Must // Consider the case:
|
|
268
|
+
// {
|
|
269
|
+
// dataset: {source: [
|
|
270
|
+
// ['2001', 123],
|
|
271
|
+
// ['2002', 456],
|
|
272
|
+
// ...
|
|
273
|
+
// ['The others', 987],
|
|
274
|
+
// ]},
|
|
275
|
+
// series: {type: 'pie'}
|
|
276
|
+
// }
|
|
277
|
+
// The first colum should better be treated as a "ordinal" although it
|
|
278
|
+
// might not able to be detected as an "ordinal" by `guessOrdinal`.
|
|
279
|
+
|| resultItem.isExtraCoord && (resultItem.otherDims.itemName != null || resultItem.otherDims.seriesName != null))) {
|
|
269
280
|
resultItem.type = 'ordinal';
|
|
270
281
|
}
|
|
271
282
|
}
|
|
@@ -53,6 +53,7 @@ var completeDimensions = require("./completeDimensions");
|
|
|
53
53
|
* @param {string} [opt.generateCoordCount]
|
|
54
54
|
* @param {Array.<string|Object>} [opt.dimensionsDefine=source.dimensionsDefine] Overwrite source define.
|
|
55
55
|
* @param {Object|HashMap} [opt.encodeDefine=source.encodeDefine] Overwrite source define.
|
|
56
|
+
* @param {Function} [opt.encodeDefaulter] Make default encode if user not specified.
|
|
56
57
|
* @return {Array.<Object>} dimensionsInfo
|
|
57
58
|
*/
|
|
58
59
|
function _default(source, opt) {
|
|
@@ -61,6 +62,7 @@ function _default(source, opt) {
|
|
|
61
62
|
dimsDef: opt.dimensionsDefine || source.dimensionsDefine,
|
|
62
63
|
encodeDef: opt.encodeDefine || source.encodeDefine,
|
|
63
64
|
dimCount: opt.dimensionsCount,
|
|
65
|
+
encodeDefaulter: opt.encodeDefaulter,
|
|
64
66
|
generateCoord: opt.generateCoord,
|
|
65
67
|
generateCoordCount: opt.generateCoordCount
|
|
66
68
|
});
|