echarts 4.2.0-rc.2 → 4.2.1
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/KEYS +60 -0
- package/LICENSE +7 -8
- package/dist/echarts-en.common.js +1250 -717
- package/dist/echarts-en.common.min.js +1 -1
- package/dist/echarts-en.js +2284 -1763
- package/dist/echarts-en.js.map +1 -1
- package/dist/echarts-en.min.js +1 -1
- package/dist/echarts-en.simple.js +1001 -560
- package/dist/echarts-en.simple.min.js +1 -1
- package/dist/echarts.common.js +1250 -717
- package/dist/echarts.common.min.js +1 -1
- package/dist/echarts.js +2284 -1763
- package/dist/echarts.js.map +1 -1
- package/dist/echarts.min.js +1 -1
- package/dist/echarts.simple.js +1001 -560
- package/dist/echarts.simple.min.js +1 -1
- package/dist/extension/dataTool.js +32 -33
- package/dist/extension/dataTool.js.map +1 -1
- package/lib/chart/graph/GraphView.js +17 -9
- package/lib/chart/graph/forceHelper.js +15 -20
- package/lib/chart/helper/Line.js +5 -1
- package/lib/chart/map/MapSeries.js +32 -26
- package/lib/chart/map/MapView.js +93 -40
- package/lib/chart/pie/labelLayout.js +23 -16
- package/lib/chart/sankey/sankeyLayout.js +18 -17
- package/lib/chart/sunburst/SunburstPiece.js +10 -5
- package/lib/chart/themeRiver/ThemeRiverSeries.js +26 -29
- package/lib/chart/tree/layoutHelper.js +57 -10
- package/lib/chart/treemap/treemapLayout.js +13 -7
- package/lib/component/axis/AxisBuilder.js +11 -2
- package/lib/component/helper/MapDraw.js +4 -0
- package/lib/component/helper/RoamController.js +3 -3
- package/lib/component/legend/LegendView.js +19 -1
- package/lib/component/legend/ScrollableLegendView.js +105 -70
- package/lib/coord/axisHelper.js +24 -1
- package/lib/coord/axisTickLabelBuilder.js +7 -12
- package/lib/coord/geo/Geo.js +1 -1
- package/lib/data/List.js +111 -36
- package/lib/echarts.js +13 -4
- package/lib/model/Model.js +1 -1
- package/lib/model/mixin/textStyle.js +1 -1
- package/lib/scale/Time.js +14 -4
- package/lib/util/format.js +30 -1
- package/lib/util/graphic.js +114 -27
- package/lib/util/model.js +27 -1
- package/lib/util/number.js +12 -33
- package/lib/visual/visualSolution.js +1 -1
- package/package.json +3 -4
- package/src/chart/graph/GraphView.js +15 -10
- package/src/chart/graph/forceHelper.js +17 -24
- package/src/chart/helper/Line.js +5 -1
- package/src/chart/map/MapSeries.js +28 -31
- package/src/chart/map/MapView.js +96 -38
- package/src/chart/pie/labelLayout.js +19 -14
- package/src/chart/sankey/sankeyLayout.js +17 -19
- package/src/chart/sunburst/SunburstPiece.js +11 -3
- package/src/chart/themeRiver/ThemeRiverSeries.js +18 -33
- package/src/chart/tree/layoutHelper.js +56 -10
- package/src/chart/treemap/treemapLayout.js +13 -7
- package/src/component/axis/AxisBuilder.js +7 -1
- package/src/component/helper/MapDraw.js +5 -1
- package/src/component/helper/RoamController.js +3 -4
- package/src/component/legend/LegendView.js +20 -1
- package/src/component/legend/ScrollableLegendView.js +119 -85
- package/src/coord/axisHelper.js +19 -0
- package/src/coord/axisTickLabelBuilder.js +10 -13
- package/src/coord/geo/Geo.js +1 -1
- package/src/data/List.js +107 -28
- package/src/echarts.js +11 -5
- package/src/model/Model.js +1 -1
- package/src/model/mixin/textStyle.js +1 -0
- package/src/scale/Time.js +14 -4
- package/src/util/format.js +39 -1
- package/src/util/graphic.js +110 -28
- package/src/util/model.js +25 -0
- package/src/util/number.js +12 -33
- package/src/visual/visualSolution.js +1 -1
- package/extension/dataTool/quantile.js +0 -82
- package/lib/component/tooltip/TooltipContentManager.js +0 -126
- package/lib/util/nest.js +0 -148
- package/src/component/tooltip/TooltipContentManager.js +0 -120
- package/src/util/nest.js +0 -127
package/src/chart/helper/Line.js
CHANGED
|
@@ -218,7 +218,11 @@ lineProto._createLine = function (lineData, idx, seriesScope) {
|
|
|
218
218
|
this.add(line);
|
|
219
219
|
|
|
220
220
|
var label = new graphic.Text({
|
|
221
|
-
name: 'label'
|
|
221
|
+
name: 'label',
|
|
222
|
+
// FIXME
|
|
223
|
+
// Temporary solution for `focusNodeAdjacency`.
|
|
224
|
+
// line label do not use the opacity of lineStyle.
|
|
225
|
+
lineLabelOriginalOpacity: 1
|
|
222
226
|
});
|
|
223
227
|
this.add(label);
|
|
224
228
|
|
|
@@ -23,7 +23,7 @@ import SeriesModel from '../../model/Series';
|
|
|
23
23
|
import {encodeHTML, addCommas} from '../../util/format';
|
|
24
24
|
import dataSelectableMixin from '../../component/helper/selectableMixin';
|
|
25
25
|
import {retrieveRawAttr} from '../../data/helper/dataProvider';
|
|
26
|
-
import
|
|
26
|
+
import geoSourceManager from '../../coord/geo/geoSourceManager';
|
|
27
27
|
|
|
28
28
|
var MapSeries = SeriesModel.extend({
|
|
29
29
|
|
|
@@ -45,43 +45,40 @@ var MapSeries = SeriesModel.extend({
|
|
|
45
45
|
*/
|
|
46
46
|
seriesGroup: [],
|
|
47
47
|
|
|
48
|
-
init: function (option) {
|
|
49
|
-
|
|
50
|
-
// this._fillOption(option, this.getMapType());
|
|
51
|
-
// this.option = option;
|
|
52
|
-
|
|
53
|
-
MapSeries.superApply(this, 'init', arguments);
|
|
54
|
-
|
|
55
|
-
this.updateSelectedMap(this._createSelectableList());
|
|
56
|
-
},
|
|
57
|
-
|
|
58
48
|
getInitialData: function (option) {
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
mergeOption: function (newOption) {
|
|
63
|
-
// this._fillOption(newOption, this.getMapType());
|
|
64
|
-
|
|
65
|
-
MapSeries.superApply(this, 'mergeOption', arguments);
|
|
66
|
-
|
|
67
|
-
this.updateSelectedMap(this._createSelectableList());
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
_createSelectableList: function () {
|
|
71
|
-
var data = this.getRawData();
|
|
49
|
+
var data = createListSimply(this, ['value']);
|
|
72
50
|
var valueDim = data.mapDimension('value');
|
|
73
|
-
var
|
|
51
|
+
var dataNameMap = zrUtil.createHashMap();
|
|
52
|
+
var selectTargetList = [];
|
|
53
|
+
var toAppendNames = [];
|
|
54
|
+
|
|
74
55
|
for (var i = 0, len = data.count(); i < len; i++) {
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
var name = data.getName(i);
|
|
57
|
+
dataNameMap.set(name, true);
|
|
58
|
+
selectTargetList.push({
|
|
59
|
+
name: name,
|
|
77
60
|
value: data.get(valueDim, i),
|
|
78
61
|
selected: retrieveRawAttr(data, i, 'selected')
|
|
79
62
|
});
|
|
80
63
|
}
|
|
81
64
|
|
|
82
|
-
|
|
65
|
+
var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap);
|
|
66
|
+
zrUtil.each(geoSource.regions, function (region) {
|
|
67
|
+
var name = region.name;
|
|
68
|
+
if (!dataNameMap.get(name)) {
|
|
69
|
+
selectTargetList.push({name: name});
|
|
70
|
+
toAppendNames.push(name);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
this.updateSelectedMap(selectTargetList);
|
|
83
75
|
|
|
84
|
-
|
|
76
|
+
// Complete data with missing regions. The consequent processes (like visual
|
|
77
|
+
// map and render) can not be performed without a "full data". For example,
|
|
78
|
+
// find `dataIndex` by name.
|
|
79
|
+
data.appendValues([], toAppendNames);
|
|
80
|
+
|
|
81
|
+
return data;
|
|
85
82
|
},
|
|
86
83
|
|
|
87
84
|
/**
|
|
@@ -99,14 +96,14 @@ var MapSeries = SeriesModel.extend({
|
|
|
99
96
|
return (this.getHostGeoModel() || this).option.map;
|
|
100
97
|
},
|
|
101
98
|
|
|
102
|
-
_fillOption: function (option, mapName) {
|
|
99
|
+
// _fillOption: function (option, mapName) {
|
|
103
100
|
// Shallow clone
|
|
104
101
|
// option = zrUtil.extend({}, option);
|
|
105
102
|
|
|
106
103
|
// option.data = geoCreator.getFilledRegions(option.data, mapName, option.nameMap);
|
|
107
104
|
|
|
108
105
|
// return option;
|
|
109
|
-
},
|
|
106
|
+
// },
|
|
110
107
|
|
|
111
108
|
getRawValue: function (dataIndex) {
|
|
112
109
|
// Use value stored in data instead because it is calculated from multiple series
|
package/src/chart/map/MapView.js
CHANGED
|
@@ -22,6 +22,9 @@ import * as zrUtil from 'zrender/src/core/util';
|
|
|
22
22
|
import * as graphic from '../../util/graphic';
|
|
23
23
|
import MapDraw from '../../component/helper/MapDraw';
|
|
24
24
|
|
|
25
|
+
var HIGH_DOWN_PROP = '__seriesMapHighDown';
|
|
26
|
+
var RECORD_VERSION_PROP = '__seriesMapCallKey';
|
|
27
|
+
|
|
25
28
|
export default echarts.extendChartView({
|
|
26
29
|
|
|
27
30
|
type: 'map',
|
|
@@ -85,12 +88,12 @@ export default echarts.extendChartView({
|
|
|
85
88
|
var originalData = mapModel.originalData;
|
|
86
89
|
var group = this.group;
|
|
87
90
|
|
|
88
|
-
originalData.each(originalData.mapDimension('value'), function (value,
|
|
91
|
+
originalData.each(originalData.mapDimension('value'), function (value, originalDataIndex) {
|
|
89
92
|
if (isNaN(value)) {
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
var layout = originalData.getItemLayout(
|
|
96
|
+
var layout = originalData.getItemLayout(originalDataIndex);
|
|
94
97
|
|
|
95
98
|
if (!layout || !layout.point) {
|
|
96
99
|
// Not exists in map
|
|
@@ -116,62 +119,117 @@ export default echarts.extendChartView({
|
|
|
116
119
|
},
|
|
117
120
|
silent: true,
|
|
118
121
|
// Do not overlap the first series, on which labels are displayed.
|
|
119
|
-
z2: !offset ?
|
|
122
|
+
z2: 8 + (!offset ? graphic.Z2_EMPHASIS_LIFT + 1 : 0)
|
|
120
123
|
});
|
|
121
124
|
|
|
122
|
-
//
|
|
125
|
+
// Only the series that has the first value on the same region is in charge of rendering the label.
|
|
126
|
+
// But consider the case:
|
|
127
|
+
// series: [
|
|
128
|
+
// {id: 'X', type: 'map', map: 'm', {data: [{name: 'A', value: 11}, {name: 'B', {value: 22}]},
|
|
129
|
+
// {id: 'Y', type: 'map', map: 'm', {data: [{name: 'A', value: 21}, {name: 'C', {value: 33}]}
|
|
130
|
+
// ]
|
|
131
|
+
// The offset `0` of item `A` is at series `X`, but of item `C` is at series `Y`.
|
|
132
|
+
// For backward compatibility, we follow the rule that render label `A` by the
|
|
133
|
+
// settings on series `X` but render label `C` by the settings on series `Y`.
|
|
123
134
|
if (!offset) {
|
|
135
|
+
|
|
124
136
|
var fullData = mapModel.mainSeries.getData();
|
|
125
|
-
var name = originalData.getName(
|
|
137
|
+
var name = originalData.getName(originalDataIndex);
|
|
126
138
|
|
|
127
139
|
var fullIndex = fullData.indexOfName(name);
|
|
128
140
|
|
|
129
|
-
var itemModel = originalData.getItemModel(
|
|
141
|
+
var itemModel = originalData.getItemModel(originalDataIndex);
|
|
130
142
|
var labelModel = itemModel.getModel('label');
|
|
131
143
|
var hoverLabelModel = itemModel.getModel('emphasis.label');
|
|
132
144
|
|
|
133
|
-
var
|
|
145
|
+
var regionGroup = fullData.getItemGraphicEl(fullIndex);
|
|
134
146
|
|
|
147
|
+
// `getFormattedLabel` needs to use `getData` inside. Here
|
|
148
|
+
// `mapModel.getData()` is shallow cloned from `mainSeries.getData()`.
|
|
149
|
+
// FIXME
|
|
150
|
+
// If this is not the `mainSeries`, the item model (like label formatter)
|
|
151
|
+
// set on original data item will never get. But it has been working
|
|
152
|
+
// like that from the begining, and this scenario is rarely encountered.
|
|
153
|
+
// So it won't be fixed until have to.
|
|
135
154
|
var normalText = zrUtil.retrieve2(
|
|
136
|
-
mapModel.getFormattedLabel(
|
|
155
|
+
mapModel.getFormattedLabel(fullIndex, 'normal'),
|
|
137
156
|
name
|
|
138
157
|
);
|
|
139
158
|
var emphasisText = zrUtil.retrieve2(
|
|
140
|
-
mapModel.getFormattedLabel(
|
|
159
|
+
mapModel.getFormattedLabel(fullIndex, 'emphasis'),
|
|
141
160
|
normalText
|
|
142
161
|
);
|
|
143
162
|
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
var highDownRecord = regionGroup[HIGH_DOWN_PROP];
|
|
164
|
+
var recordVersion = Math.random();
|
|
165
|
+
|
|
166
|
+
// Prevent from register listeners duplicatedly when roaming.
|
|
167
|
+
if (!highDownRecord) {
|
|
168
|
+
highDownRecord = regionGroup[HIGH_DOWN_PROP] = {};
|
|
169
|
+
var onEmphasis = zrUtil.curry(onRegionHighDown, true);
|
|
170
|
+
var onNormal = zrUtil.curry(onRegionHighDown, false);
|
|
171
|
+
regionGroup.on('mouseover', onEmphasis)
|
|
172
|
+
.on('mouseout', onNormal)
|
|
173
|
+
.on('emphasis', onEmphasis)
|
|
174
|
+
.on('normal', onNormal);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Prevent removed regions effect current grapics.
|
|
178
|
+
regionGroup[RECORD_VERSION_PROP] = recordVersion;
|
|
179
|
+
zrUtil.extend(highDownRecord, {
|
|
180
|
+
recordVersion: recordVersion,
|
|
181
|
+
circle: circle,
|
|
182
|
+
labelModel: labelModel,
|
|
183
|
+
hoverLabelModel: hoverLabelModel,
|
|
184
|
+
emphasisText: emphasisText,
|
|
185
|
+
normalText: normalText
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// FIXME
|
|
189
|
+
// Consider set option when emphasis.
|
|
190
|
+
enterRegionHighDown(highDownRecord, false);
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
group.add(circle);
|
|
175
194
|
});
|
|
176
195
|
}
|
|
177
|
-
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
function onRegionHighDown(toHighOrDown) {
|
|
199
|
+
var highDownRecord = this[HIGH_DOWN_PROP];
|
|
200
|
+
if (highDownRecord && highDownRecord.recordVersion === this[RECORD_VERSION_PROP]) {
|
|
201
|
+
enterRegionHighDown(highDownRecord, toHighOrDown);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function enterRegionHighDown(highDownRecord, toHighOrDown) {
|
|
206
|
+
var circle = highDownRecord.circle;
|
|
207
|
+
var labelModel = highDownRecord.labelModel;
|
|
208
|
+
var hoverLabelModel = highDownRecord.hoverLabelModel;
|
|
209
|
+
var emphasisText = highDownRecord.emphasisText;
|
|
210
|
+
var normalText = highDownRecord.normalText;
|
|
211
|
+
|
|
212
|
+
if (toHighOrDown) {
|
|
213
|
+
circle.style.extendFrom(
|
|
214
|
+
graphic.setTextStyle({}, hoverLabelModel, {
|
|
215
|
+
text: hoverLabelModel.get('show') ? emphasisText : null
|
|
216
|
+
}, {isRectText: true, useInsideStyle: false}, true)
|
|
217
|
+
);
|
|
218
|
+
// Make label upper than others if overlaps.
|
|
219
|
+
circle.__mapOriginalZ2 = circle.z2;
|
|
220
|
+
circle.z2 += graphic.Z2_EMPHASIS_LIFT;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
graphic.setTextStyle(circle.style, labelModel, {
|
|
224
|
+
text: labelModel.get('show') ? normalText : null,
|
|
225
|
+
textPosition: labelModel.getShallow('position') || 'bottom'
|
|
226
|
+
}, {isRectText: true, useInsideStyle: false});
|
|
227
|
+
// Trigger normalize style like padding.
|
|
228
|
+
circle.dirty(false);
|
|
229
|
+
|
|
230
|
+
if (circle.__mapOriginalZ2 != null) {
|
|
231
|
+
circle.z2 = circle.__mapOriginalZ2;
|
|
232
|
+
circle.__mapOriginalZ2 = null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -26,7 +26,6 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
26
26
|
return a.y - b.y;
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
// 压
|
|
30
29
|
function shiftDown(start, end, delta, dir) {
|
|
31
30
|
for (var j = start; j < end; j++) {
|
|
32
31
|
list[j].y += delta;
|
|
@@ -42,7 +41,6 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
42
41
|
shiftUp(end - 1, delta / 2);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
// 弹
|
|
46
44
|
function shiftUp(end, delta) {
|
|
47
45
|
for (var j = end; j >= 0; j--) {
|
|
48
46
|
list[j].y -= delta;
|
|
@@ -56,18 +54,14 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
56
54
|
|
|
57
55
|
function changeX(list, isDownList, cx, cy, r, dir) {
|
|
58
56
|
var lastDeltaX = dir > 0
|
|
59
|
-
? isDownList //
|
|
60
|
-
? Number.MAX_VALUE //
|
|
61
|
-
: 0 //
|
|
62
|
-
: isDownList //
|
|
63
|
-
? Number.MAX_VALUE //
|
|
64
|
-
: 0; //
|
|
57
|
+
? isDownList // right-side
|
|
58
|
+
? Number.MAX_VALUE // down
|
|
59
|
+
: 0 // up
|
|
60
|
+
: isDownList // left-side
|
|
61
|
+
? Number.MAX_VALUE // down
|
|
62
|
+
: 0; // up
|
|
65
63
|
|
|
66
64
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
67
|
-
// Not change x for center label
|
|
68
|
-
if (list[i].position === 'center') {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
65
|
var deltaY = Math.abs(list[i].y - cy);
|
|
72
66
|
var length = list[i].len;
|
|
73
67
|
var length2 = list[i].len2;
|
|
@@ -78,11 +72,11 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
78
72
|
)
|
|
79
73
|
: Math.abs(list[i].x - cx);
|
|
80
74
|
if (isDownList && deltaX >= lastDeltaX) {
|
|
81
|
-
//
|
|
75
|
+
// right-down, left-down
|
|
82
76
|
deltaX = lastDeltaX - 10;
|
|
83
77
|
}
|
|
84
78
|
if (!isDownList && deltaX <= lastDeltaX) {
|
|
85
|
-
//
|
|
79
|
+
// right-up, left-up
|
|
86
80
|
deltaX = lastDeltaX + 10;
|
|
87
81
|
}
|
|
88
82
|
|
|
@@ -122,6 +116,9 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
122
116
|
var leftList = [];
|
|
123
117
|
var rightList = [];
|
|
124
118
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
119
|
+
if (isPositionCenter(labelLayoutList[i])) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
125
122
|
if (labelLayoutList[i].x < cx) {
|
|
126
123
|
leftList.push(labelLayoutList[i]);
|
|
127
124
|
}
|
|
@@ -134,6 +131,9 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
134
131
|
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
|
|
135
132
|
|
|
136
133
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
134
|
+
if (isPositionCenter(labelLayoutList[i])) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
137
|
var linePoints = labelLayoutList[i].linePoints;
|
|
138
138
|
if (linePoints) {
|
|
139
139
|
var dist = linePoints[1][0] - linePoints[2][0];
|
|
@@ -149,6 +149,11 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
function isPositionCenter(layout) {
|
|
153
|
+
// Not change x for center label
|
|
154
|
+
return layout.position === 'center';
|
|
155
|
+
}
|
|
156
|
+
|
|
152
157
|
export default function (seriesModel, r, viewWidth, viewHeight) {
|
|
153
158
|
var data = seriesModel.getData();
|
|
154
159
|
var labelLayoutList = [];
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import * as layout from '../../util/layout';
|
|
26
|
-
import nest from '../../util/nest';
|
|
27
26
|
import * as zrUtil from 'zrender/src/core/util';
|
|
27
|
+
import {groupData} from '../../util/model';
|
|
28
28
|
import { __DEV__ } from '../../config';
|
|
29
29
|
|
|
30
30
|
export default function (ecModel, api, payload) {
|
|
@@ -230,15 +230,7 @@ function scaleNodeBreadths(nodes, kx, orient) {
|
|
|
230
230
|
* @param {number} iterations the number of iterations for the algorithm
|
|
231
231
|
*/
|
|
232
232
|
function computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, orient) {
|
|
233
|
-
var nodesByBreadth =
|
|
234
|
-
.key(getKeyFunction(orient))
|
|
235
|
-
.sortKeys(function (a, b) {
|
|
236
|
-
return a - b;
|
|
237
|
-
})
|
|
238
|
-
.entries(nodes)
|
|
239
|
-
.map(function (d) {
|
|
240
|
-
return d.values;
|
|
241
|
-
});
|
|
233
|
+
var nodesByBreadth = prepareNodesByBreadth(nodes, orient);
|
|
242
234
|
|
|
243
235
|
initializeNodeDepth(nodes, nodesByBreadth, edges, height, width, nodeGap, orient);
|
|
244
236
|
resolveCollisions(nodesByBreadth, nodeGap, height, width, orient);
|
|
@@ -254,15 +246,21 @@ function computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, ori
|
|
|
254
246
|
}
|
|
255
247
|
}
|
|
256
248
|
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
249
|
+
function prepareNodesByBreadth(nodes, orient) {
|
|
250
|
+
var nodesByBreadth = [];
|
|
251
|
+
var keyAttr = orient === 'vertical' ? 'y' : 'x';
|
|
252
|
+
|
|
253
|
+
var groupResult = groupData(nodes, function (node) {
|
|
254
|
+
return node.getLayout()[keyAttr];
|
|
255
|
+
});
|
|
256
|
+
groupResult.keys.sort(function (a, b) {
|
|
257
|
+
return a - b;
|
|
258
|
+
});
|
|
259
|
+
zrUtil.each(groupResult.keys, function (key) {
|
|
260
|
+
nodesByBreadth.push(groupResult.buckets.get(key));
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
return nodesByBreadth;
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
/**
|
|
@@ -86,14 +86,16 @@ SunburstPieceProto.updateData = function (
|
|
|
86
86
|
|
|
87
87
|
var itemModel = node.getModel();
|
|
88
88
|
var layout = node.getLayout();
|
|
89
|
-
if (!layout) {
|
|
90
|
-
|
|
91
|
-
}
|
|
89
|
+
// if (!layout) {
|
|
90
|
+
// console.log(node.getLayout());
|
|
91
|
+
// }
|
|
92
92
|
var sectorShape = zrUtil.extend({}, layout);
|
|
93
93
|
sectorShape.label = null;
|
|
94
94
|
|
|
95
95
|
var visualColor = getNodeColor(node, seriesModel, ecModel);
|
|
96
96
|
|
|
97
|
+
fillDefaultColor(node, seriesModel, visualColor);
|
|
98
|
+
|
|
97
99
|
var normalStyle = itemModel.getModel('itemStyle').getItemStyle();
|
|
98
100
|
var style;
|
|
99
101
|
if (state === 'normal') {
|
|
@@ -411,3 +413,9 @@ function isNodeHighlighted(node, activeNode, policy) {
|
|
|
411
413
|
return node === activeNode || node.isDescendantOf(activeNode);
|
|
412
414
|
}
|
|
413
415
|
}
|
|
416
|
+
|
|
417
|
+
// Fix tooltip callback function params.color incorrect when pick a default color
|
|
418
|
+
function fillDefaultColor(node, seriesModel, color) {
|
|
419
|
+
var data = seriesModel.getData();
|
|
420
|
+
data.setItemVisual(node.dataIndex, 'color', color);
|
|
421
|
+
}
|
|
@@ -27,8 +27,8 @@ import createDimensions from '../../data/helper/createDimensions';
|
|
|
27
27
|
import {getDimensionTypeByAxis} from '../../data/helper/dimensionHelper';
|
|
28
28
|
import List from '../../data/List';
|
|
29
29
|
import * as zrUtil from 'zrender/src/core/util';
|
|
30
|
+
import {groupData} from '../../util/model';
|
|
30
31
|
import {encodeHTML} from '../../util/format';
|
|
31
|
-
import nest from '../../util/nest';
|
|
32
32
|
|
|
33
33
|
var DATA_NAME_INDEX = 2;
|
|
34
34
|
|
|
@@ -69,18 +69,12 @@ var ThemeRiverSeries = SeriesModel.extend({
|
|
|
69
69
|
var rawDataLength = data.length;
|
|
70
70
|
|
|
71
71
|
// grouped data by name
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// data group in each layer
|
|
79
|
-
var layData = zrUtil.map(dataByName, function (d) {
|
|
80
|
-
return {
|
|
81
|
-
name: d.key,
|
|
82
|
-
dataList: d.values
|
|
83
|
-
};
|
|
72
|
+
var groupResult = groupData(data, function (item) {
|
|
73
|
+
return item[2];
|
|
74
|
+
});
|
|
75
|
+
var layData = [];
|
|
76
|
+
groupResult.buckets.each(function (items, key) {
|
|
77
|
+
layData.push({name: key, dataList: items});
|
|
84
78
|
});
|
|
85
79
|
|
|
86
80
|
var layerNum = layData.length;
|
|
@@ -201,29 +195,20 @@ var ThemeRiverSeries = SeriesModel.extend({
|
|
|
201
195
|
for (var i = 0; i < lenCount; ++i) {
|
|
202
196
|
indexArr[i] = i;
|
|
203
197
|
}
|
|
204
|
-
// data group by name
|
|
205
|
-
var dataByName = nest()
|
|
206
|
-
.key(function (index) {
|
|
207
|
-
return data.get('name', index);
|
|
208
|
-
})
|
|
209
|
-
.entries(indexArr);
|
|
210
|
-
|
|
211
|
-
var layerSeries = zrUtil.map(dataByName, function (d) {
|
|
212
|
-
return {
|
|
213
|
-
name: d.key,
|
|
214
|
-
indices: d.values
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
198
|
|
|
218
199
|
var timeDim = data.mapDimension('single');
|
|
219
200
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
201
|
+
// data group by name
|
|
202
|
+
var groupResult = groupData(indexArr, function (index) {
|
|
203
|
+
return data.get('name', index);
|
|
204
|
+
});
|
|
205
|
+
var layerSeries = [];
|
|
206
|
+
groupResult.buckets.each(function (items, key) {
|
|
207
|
+
items.sort(function (index1, index2) {
|
|
208
|
+
return data.get(timeDim, index1) - data.get(timeDim, index2);
|
|
209
|
+
});
|
|
210
|
+
layerSeries.push({name: key, indices: items});
|
|
211
|
+
});
|
|
227
212
|
|
|
228
213
|
return layerSeries;
|
|
229
214
|
},
|