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/lib/chart/map/MapView.js
CHANGED
|
@@ -44,6 +44,9 @@ var MapDraw = require("../../component/helper/MapDraw");
|
|
|
44
44
|
* specific language governing permissions and limitations
|
|
45
45
|
* under the License.
|
|
46
46
|
*/
|
|
47
|
+
var HIGH_DOWN_PROP = '__seriesMapHighDown';
|
|
48
|
+
var RECORD_VERSION_PROP = '__seriesMapCallKey';
|
|
49
|
+
|
|
47
50
|
var _default = echarts.extendChartView({
|
|
48
51
|
type: 'map',
|
|
49
52
|
render: function (mapModel, ecModel, api, payload) {
|
|
@@ -90,12 +93,12 @@ var _default = echarts.extendChartView({
|
|
|
90
93
|
_renderSymbols: function (mapModel, ecModel, api) {
|
|
91
94
|
var originalData = mapModel.originalData;
|
|
92
95
|
var group = this.group;
|
|
93
|
-
originalData.each(originalData.mapDimension('value'), function (value,
|
|
96
|
+
originalData.each(originalData.mapDimension('value'), function (value, originalDataIndex) {
|
|
94
97
|
if (isNaN(value)) {
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
var layout = originalData.getItemLayout(
|
|
101
|
+
var layout = originalData.getItemLayout(originalDataIndex);
|
|
99
102
|
|
|
100
103
|
if (!layout || !layout.point) {
|
|
101
104
|
// Not exists in map
|
|
@@ -120,50 +123,57 @@ var _default = echarts.extendChartView({
|
|
|
120
123
|
},
|
|
121
124
|
silent: true,
|
|
122
125
|
// Do not overlap the first series, on which labels are displayed.
|
|
123
|
-
z2: !offset ?
|
|
124
|
-
}); //
|
|
126
|
+
z2: 8 + (!offset ? graphic.Z2_EMPHASIS_LIFT + 1 : 0)
|
|
127
|
+
}); // Only the series that has the first value on the same region is in charge of rendering the label.
|
|
128
|
+
// But consider the case:
|
|
129
|
+
// series: [
|
|
130
|
+
// {id: 'X', type: 'map', map: 'm', {data: [{name: 'A', value: 11}, {name: 'B', {value: 22}]},
|
|
131
|
+
// {id: 'Y', type: 'map', map: 'm', {data: [{name: 'A', value: 21}, {name: 'C', {value: 33}]}
|
|
132
|
+
// ]
|
|
133
|
+
// The offset `0` of item `A` is at series `X`, but of item `C` is at series `Y`.
|
|
134
|
+
// For backward compatibility, we follow the rule that render label `A` by the
|
|
135
|
+
// settings on series `X` but render label `C` by the settings on series `Y`.
|
|
125
136
|
|
|
126
137
|
if (!offset) {
|
|
127
138
|
var fullData = mapModel.mainSeries.getData();
|
|
128
|
-
var name = originalData.getName(
|
|
139
|
+
var name = originalData.getName(originalDataIndex);
|
|
129
140
|
var fullIndex = fullData.indexOfName(name);
|
|
130
|
-
var itemModel = originalData.getItemModel(
|
|
141
|
+
var itemModel = originalData.getItemModel(originalDataIndex);
|
|
131
142
|
var labelModel = itemModel.getModel('label');
|
|
132
143
|
var hoverLabelModel = itemModel.getModel('emphasis.label');
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
onNormal();
|
|
144
|
+
var regionGroup = fullData.getItemGraphicEl(fullIndex); // `getFormattedLabel` needs to use `getData` inside. Here
|
|
145
|
+
// `mapModel.getData()` is shallow cloned from `mainSeries.getData()`.
|
|
146
|
+
// FIXME
|
|
147
|
+
// If this is not the `mainSeries`, the item model (like label formatter)
|
|
148
|
+
// set on original data item will never get. But it has been working
|
|
149
|
+
// like that from the begining, and this scenario is rarely encountered.
|
|
150
|
+
// So it won't be fixed until have to.
|
|
151
|
+
|
|
152
|
+
var normalText = zrUtil.retrieve2(mapModel.getFormattedLabel(fullIndex, 'normal'), name);
|
|
153
|
+
var emphasisText = zrUtil.retrieve2(mapModel.getFormattedLabel(fullIndex, 'emphasis'), normalText);
|
|
154
|
+
var highDownRecord = regionGroup[HIGH_DOWN_PROP];
|
|
155
|
+
var recordVersion = Math.random(); // Prevent from register listeners duplicatedly when roaming.
|
|
156
|
+
|
|
157
|
+
if (!highDownRecord) {
|
|
158
|
+
highDownRecord = regionGroup[HIGH_DOWN_PROP] = {};
|
|
159
|
+
var onEmphasis = zrUtil.curry(onRegionHighDown, true);
|
|
160
|
+
var onNormal = zrUtil.curry(onRegionHighDown, false);
|
|
161
|
+
regionGroup.on('mouseover', onEmphasis).on('mouseout', onNormal).on('emphasis', onEmphasis).on('normal', onNormal);
|
|
162
|
+
} // Prevent removed regions effect current grapics.
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
regionGroup[RECORD_VERSION_PROP] = recordVersion;
|
|
166
|
+
zrUtil.extend(highDownRecord, {
|
|
167
|
+
recordVersion: recordVersion,
|
|
168
|
+
circle: circle,
|
|
169
|
+
labelModel: labelModel,
|
|
170
|
+
hoverLabelModel: hoverLabelModel,
|
|
171
|
+
emphasisText: emphasisText,
|
|
172
|
+
normalText: normalText
|
|
173
|
+
}); // FIXME
|
|
174
|
+
// Consider set option when emphasis.
|
|
175
|
+
|
|
176
|
+
enterRegionHighDown(highDownRecord, false);
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
group.add(circle);
|
|
@@ -171,4 +181,47 @@ var _default = echarts.extendChartView({
|
|
|
171
181
|
}
|
|
172
182
|
});
|
|
173
183
|
|
|
184
|
+
function onRegionHighDown(toHighOrDown) {
|
|
185
|
+
var highDownRecord = this[HIGH_DOWN_PROP];
|
|
186
|
+
|
|
187
|
+
if (highDownRecord && highDownRecord.recordVersion === this[RECORD_VERSION_PROP]) {
|
|
188
|
+
enterRegionHighDown(highDownRecord, toHighOrDown);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function enterRegionHighDown(highDownRecord, toHighOrDown) {
|
|
193
|
+
var circle = highDownRecord.circle;
|
|
194
|
+
var labelModel = highDownRecord.labelModel;
|
|
195
|
+
var hoverLabelModel = highDownRecord.hoverLabelModel;
|
|
196
|
+
var emphasisText = highDownRecord.emphasisText;
|
|
197
|
+
var normalText = highDownRecord.normalText;
|
|
198
|
+
|
|
199
|
+
if (toHighOrDown) {
|
|
200
|
+
circle.style.extendFrom(graphic.setTextStyle({}, hoverLabelModel, {
|
|
201
|
+
text: hoverLabelModel.get('show') ? emphasisText : null
|
|
202
|
+
}, {
|
|
203
|
+
isRectText: true,
|
|
204
|
+
useInsideStyle: false
|
|
205
|
+
}, true)); // Make label upper than others if overlaps.
|
|
206
|
+
|
|
207
|
+
circle.__mapOriginalZ2 = circle.z2;
|
|
208
|
+
circle.z2 += graphic.Z2_EMPHASIS_LIFT;
|
|
209
|
+
} else {
|
|
210
|
+
graphic.setTextStyle(circle.style, labelModel, {
|
|
211
|
+
text: labelModel.get('show') ? normalText : null,
|
|
212
|
+
textPosition: labelModel.getShallow('position') || 'bottom'
|
|
213
|
+
}, {
|
|
214
|
+
isRectText: true,
|
|
215
|
+
useInsideStyle: false
|
|
216
|
+
}); // Trigger normalize style like padding.
|
|
217
|
+
|
|
218
|
+
circle.dirty(false);
|
|
219
|
+
|
|
220
|
+
if (circle.__mapOriginalZ2 != null) {
|
|
221
|
+
circle.z2 = circle.__mapOriginalZ2;
|
|
222
|
+
circle.__mapOriginalZ2 = null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
174
227
|
module.exports = _default;
|
|
@@ -42,7 +42,7 @@ var textContain = require("zrender/lib/contain/text");
|
|
|
42
42
|
function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
43
43
|
list.sort(function (a, b) {
|
|
44
44
|
return a.y - b.y;
|
|
45
|
-
});
|
|
45
|
+
});
|
|
46
46
|
|
|
47
47
|
function shiftDown(start, end, delta, dir) {
|
|
48
48
|
for (var j = start; j < end; j++) {
|
|
@@ -55,8 +55,7 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
shiftUp(end - 1, delta / 2);
|
|
58
|
-
}
|
|
59
|
-
|
|
58
|
+
}
|
|
60
59
|
|
|
61
60
|
function shiftUp(end, delta) {
|
|
62
61
|
for (var j = end; j >= 0; j--) {
|
|
@@ -69,31 +68,26 @@ function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
function changeX(list, isDownList, cx, cy, r, dir) {
|
|
72
|
-
var lastDeltaX = dir > 0 ? isDownList //
|
|
73
|
-
? Number.MAX_VALUE //
|
|
74
|
-
: 0 //
|
|
75
|
-
: isDownList //
|
|
76
|
-
? Number.MAX_VALUE //
|
|
77
|
-
: 0; //
|
|
71
|
+
var lastDeltaX = dir > 0 ? isDownList // right-side
|
|
72
|
+
? Number.MAX_VALUE // down
|
|
73
|
+
: 0 // up
|
|
74
|
+
: isDownList // left-side
|
|
75
|
+
? Number.MAX_VALUE // down
|
|
76
|
+
: 0; // up
|
|
78
77
|
|
|
79
78
|
for (var i = 0, l = list.length; i < l; i++) {
|
|
80
|
-
// Not change x for center label
|
|
81
|
-
if (list[i].position === 'center') {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
79
|
var deltaY = Math.abs(list[i].y - cy);
|
|
86
80
|
var length = list[i].len;
|
|
87
81
|
var length2 = list[i].len2;
|
|
88
82
|
var deltaX = deltaY < r + length ? Math.sqrt((r + length + length2) * (r + length + length2) - deltaY * deltaY) : Math.abs(list[i].x - cx);
|
|
89
83
|
|
|
90
84
|
if (isDownList && deltaX >= lastDeltaX) {
|
|
91
|
-
//
|
|
85
|
+
// right-down, left-down
|
|
92
86
|
deltaX = lastDeltaX - 10;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
if (!isDownList && deltaX <= lastDeltaX) {
|
|
96
|
-
//
|
|
90
|
+
// right-up, left-up
|
|
97
91
|
deltaX = lastDeltaX + 10;
|
|
98
92
|
}
|
|
99
93
|
|
|
@@ -139,6 +133,10 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
139
133
|
var rightList = [];
|
|
140
134
|
|
|
141
135
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
136
|
+
if (isPositionCenter(labelLayoutList[i])) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
142
140
|
if (labelLayoutList[i].x < cx) {
|
|
143
141
|
leftList.push(labelLayoutList[i]);
|
|
144
142
|
} else {
|
|
@@ -150,6 +148,10 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
150
148
|
adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
|
|
151
149
|
|
|
152
150
|
for (var i = 0; i < labelLayoutList.length; i++) {
|
|
151
|
+
if (isPositionCenter(labelLayoutList[i])) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
|
|
153
155
|
var linePoints = labelLayoutList[i].linePoints;
|
|
154
156
|
|
|
155
157
|
if (linePoints) {
|
|
@@ -167,6 +169,11 @@ function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
|
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
function isPositionCenter(layout) {
|
|
173
|
+
// Not change x for center label
|
|
174
|
+
return layout.position === 'center';
|
|
175
|
+
}
|
|
176
|
+
|
|
170
177
|
function _default(seriesModel, r, viewWidth, viewHeight) {
|
|
171
178
|
var data = seriesModel.getData();
|
|
172
179
|
var labelLayoutList = [];
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
var layout = require("../../util/layout");
|
|
22
22
|
|
|
23
|
-
var nest = require("../../util/nest");
|
|
24
|
-
|
|
25
23
|
var zrUtil = require("zrender/lib/core/util");
|
|
26
24
|
|
|
25
|
+
var _model = require("../../util/model");
|
|
26
|
+
|
|
27
|
+
var groupData = _model.groupData;
|
|
28
|
+
|
|
27
29
|
var _config = require("../../config");
|
|
28
30
|
|
|
29
31
|
var __DEV__ = _config.__DEV__;
|
|
@@ -256,11 +258,7 @@ function scaleNodeBreadths(nodes, kx, orient) {
|
|
|
256
258
|
|
|
257
259
|
|
|
258
260
|
function computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, orient) {
|
|
259
|
-
var nodesByBreadth =
|
|
260
|
-
return a - b;
|
|
261
|
-
}).entries(nodes).map(function (d) {
|
|
262
|
-
return d.values;
|
|
263
|
-
});
|
|
261
|
+
var nodesByBreadth = prepareNodesByBreadth(nodes, orient);
|
|
264
262
|
initializeNodeDepth(nodes, nodesByBreadth, edges, height, width, nodeGap, orient);
|
|
265
263
|
resolveCollisions(nodesByBreadth, nodeGap, height, width, orient);
|
|
266
264
|
|
|
@@ -275,16 +273,19 @@ function computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, ori
|
|
|
275
273
|
}
|
|
276
274
|
}
|
|
277
275
|
|
|
278
|
-
function
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
function prepareNodesByBreadth(nodes, orient) {
|
|
277
|
+
var nodesByBreadth = [];
|
|
278
|
+
var keyAttr = orient === 'vertical' ? 'y' : 'x';
|
|
279
|
+
var groupResult = groupData(nodes, function (node) {
|
|
280
|
+
return node.getLayout()[keyAttr];
|
|
281
|
+
});
|
|
282
|
+
groupResult.keys.sort(function (a, b) {
|
|
283
|
+
return a - b;
|
|
284
|
+
});
|
|
285
|
+
zrUtil.each(groupResult.keys, function (key) {
|
|
286
|
+
nodesByBreadth.push(groupResult.buckets.get(key));
|
|
287
|
+
});
|
|
288
|
+
return nodesByBreadth;
|
|
288
289
|
}
|
|
289
290
|
/**
|
|
290
291
|
* Compute the original y-position for each node
|
|
@@ -90,15 +90,14 @@ SunburstPieceProto.updateData = function (firstCreate, node, state, seriesModel,
|
|
|
90
90
|
var sector = this.childAt(0);
|
|
91
91
|
sector.dataIndex = node.dataIndex;
|
|
92
92
|
var itemModel = node.getModel();
|
|
93
|
-
var layout = node.getLayout();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
console.log(node.getLayout());
|
|
97
|
-
}
|
|
93
|
+
var layout = node.getLayout(); // if (!layout) {
|
|
94
|
+
// console.log(node.getLayout());
|
|
95
|
+
// }
|
|
98
96
|
|
|
99
97
|
var sectorShape = zrUtil.extend({}, layout);
|
|
100
98
|
sectorShape.label = null;
|
|
101
99
|
var visualColor = getNodeColor(node, seriesModel, ecModel);
|
|
100
|
+
fillDefaultColor(node, seriesModel, visualColor);
|
|
102
101
|
var normalStyle = itemModel.getModel('itemStyle').getItemStyle();
|
|
103
102
|
var style;
|
|
104
103
|
|
|
@@ -381,6 +380,12 @@ function isNodeHighlighted(node, activeNode, policy) {
|
|
|
381
380
|
} else {
|
|
382
381
|
return node === activeNode || node.isDescendantOf(activeNode);
|
|
383
382
|
}
|
|
383
|
+
} // Fix tooltip callback function params.color incorrect when pick a default color
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
function fillDefaultColor(node, seriesModel, color) {
|
|
387
|
+
var data = seriesModel.getData();
|
|
388
|
+
data.setItemVisual(node.dataIndex, 'color', color);
|
|
384
389
|
}
|
|
385
390
|
|
|
386
391
|
module.exports = _default;
|
|
@@ -30,12 +30,14 @@ var List = require("../../data/List");
|
|
|
30
30
|
|
|
31
31
|
var zrUtil = require("zrender/lib/core/util");
|
|
32
32
|
|
|
33
|
+
var _model = require("../../util/model");
|
|
34
|
+
|
|
35
|
+
var groupData = _model.groupData;
|
|
36
|
+
|
|
33
37
|
var _format = require("../../util/format");
|
|
34
38
|
|
|
35
39
|
var encodeHTML = _format.encodeHTML;
|
|
36
40
|
|
|
37
|
-
var nest = require("../../util/nest");
|
|
38
|
-
|
|
39
41
|
/*
|
|
40
42
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
41
43
|
* or more contributor license agreements. See the NOTICE file
|
|
@@ -93,15 +95,15 @@ var ThemeRiverSeries = SeriesModel.extend({
|
|
|
93
95
|
fixData: function (data) {
|
|
94
96
|
var rawDataLength = data.length; // grouped data by name
|
|
95
97
|
|
|
96
|
-
var
|
|
97
|
-
return
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
name:
|
|
103
|
-
dataList:
|
|
104
|
-
};
|
|
98
|
+
var groupResult = groupData(data, function (item) {
|
|
99
|
+
return item[2];
|
|
100
|
+
});
|
|
101
|
+
var layData = [];
|
|
102
|
+
groupResult.buckets.each(function (items, key) {
|
|
103
|
+
layData.push({
|
|
104
|
+
name: key,
|
|
105
|
+
dataList: items
|
|
106
|
+
});
|
|
105
107
|
});
|
|
106
108
|
var layerNum = layData.length;
|
|
107
109
|
var largestLayer = -1;
|
|
@@ -218,28 +220,23 @@ var ThemeRiverSeries = SeriesModel.extend({
|
|
|
218
220
|
|
|
219
221
|
for (var i = 0; i < lenCount; ++i) {
|
|
220
222
|
indexArr[i] = i;
|
|
221
|
-
}
|
|
223
|
+
}
|
|
222
224
|
|
|
225
|
+
var timeDim = data.mapDimension('single'); // data group by name
|
|
223
226
|
|
|
224
|
-
var
|
|
227
|
+
var groupResult = groupData(indexArr, function (index) {
|
|
225
228
|
return data.get('name', index);
|
|
226
|
-
}).entries(indexArr);
|
|
227
|
-
var layerSeries = zrUtil.map(dataByName, function (d) {
|
|
228
|
-
return {
|
|
229
|
-
name: d.key,
|
|
230
|
-
indices: d.values
|
|
231
|
-
};
|
|
232
229
|
});
|
|
233
|
-
var
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
230
|
+
var layerSeries = [];
|
|
231
|
+
groupResult.buckets.each(function (items, key) {
|
|
232
|
+
items.sort(function (index1, index2) {
|
|
233
|
+
return data.get(timeDim, index1) - data.get(timeDim, index2);
|
|
234
|
+
});
|
|
235
|
+
layerSeries.push({
|
|
236
|
+
name: key,
|
|
237
|
+
indices: items
|
|
238
|
+
});
|
|
239
|
+
});
|
|
243
240
|
return layerSeries;
|
|
244
241
|
},
|
|
245
242
|
|
|
@@ -40,21 +40,25 @@ var layout = require("../../util/layout");
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
/*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* A third-party license is embeded for some of the code in this file:
|
|
44
|
+
* The tree layoutHelper implementation was originally copied from
|
|
45
|
+
* "d3.js"(https://github.com/d3/d3-hierarchy) with
|
|
46
|
+
* some modifications made for this project.
|
|
47
|
+
* (see more details in the comment of the specific method below.)
|
|
48
|
+
* The use of the source code of this file is also subject to the terms
|
|
49
|
+
* and consitions of the licence of "d3.js" (BSD-3Clause, see
|
|
50
|
+
* </licenses/LICENSE-d3>).
|
|
47
51
|
*/
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* @file The layout algorithm of node-link tree diagrams. Here we using Reingold-Tilford algorithm to drawing
|
|
51
55
|
* the tree.
|
|
52
|
-
* @see https://github.com/d3/d3-hierarchy
|
|
53
56
|
*/
|
|
54
57
|
|
|
55
58
|
/**
|
|
56
|
-
* Initialize all computational message for following algorithm
|
|
57
|
-
*
|
|
59
|
+
* Initialize all computational message for following algorithm.
|
|
60
|
+
*
|
|
61
|
+
* @param {module:echarts/data/Tree~TreeNode} root The virtual root of the tree.
|
|
58
62
|
*/
|
|
59
63
|
function init(root) {
|
|
60
64
|
root.hierNode = {
|
|
@@ -96,10 +100,16 @@ function init(root) {
|
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
103
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
104
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
105
|
+
* with some modifications made for this program.
|
|
106
|
+
* See the license statement at the head of this file.
|
|
107
|
+
*
|
|
99
108
|
* Computes a preliminary x coordinate for node. Before that, this function is
|
|
100
109
|
* applied recursively to the children of node, as well as the function
|
|
101
110
|
* apportion(). After spacing out the children by calling executeShifts(), the
|
|
102
111
|
* node is placed to the midpoint of its outermost children.
|
|
112
|
+
*
|
|
103
113
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
104
114
|
* @param {Function} separation
|
|
105
115
|
*/
|
|
@@ -127,7 +137,13 @@ function firstWalk(node, separation) {
|
|
|
127
137
|
node.parentNode.hierNode.defaultAncestor = apportion(node, subtreeW, node.parentNode.hierNode.defaultAncestor || siblings[0], separation);
|
|
128
138
|
}
|
|
129
139
|
/**
|
|
140
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
141
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
142
|
+
* with some modifications made for this program.
|
|
143
|
+
* See the license statement at the head of this file.
|
|
144
|
+
*
|
|
130
145
|
* Computes all real x-coordinates by summing up the modifiers recursively.
|
|
146
|
+
*
|
|
131
147
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
132
148
|
*/
|
|
133
149
|
|
|
@@ -144,7 +160,8 @@ function separation(cb) {
|
|
|
144
160
|
return arguments.length ? cb : defaultSeparation;
|
|
145
161
|
}
|
|
146
162
|
/**
|
|
147
|
-
* Transform the common coordinate to radial coordinate
|
|
163
|
+
* Transform the common coordinate to radial coordinate.
|
|
164
|
+
*
|
|
148
165
|
* @param {number} x
|
|
149
166
|
* @param {number} y
|
|
150
167
|
* @return {Object}
|
|
@@ -159,7 +176,8 @@ function radialCoordinate(x, y) {
|
|
|
159
176
|
return radialCoor;
|
|
160
177
|
}
|
|
161
178
|
/**
|
|
162
|
-
* Get the layout position of the whole view
|
|
179
|
+
* Get the layout position of the whole view.
|
|
180
|
+
*
|
|
163
181
|
* @param {module:echarts/model/Series} seriesModel the model object of sankey series
|
|
164
182
|
* @param {module:echarts/ExtensionAPI} api provide the API list that the developer can call
|
|
165
183
|
* @return {module:zrender/core/BoundingRect} size of rect to draw the sankey view
|
|
@@ -175,6 +193,12 @@ function getViewRect(seriesModel, api) {
|
|
|
175
193
|
/**
|
|
176
194
|
* All other shifts, applied to the smaller subtrees between w- and w+, are
|
|
177
195
|
* performed by this function.
|
|
196
|
+
*
|
|
197
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
198
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
199
|
+
* with some modifications made for this program.
|
|
200
|
+
* See the license statement at the head of this file.
|
|
201
|
+
*
|
|
178
202
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
179
203
|
*/
|
|
180
204
|
|
|
@@ -194,6 +218,11 @@ function executeShifts(node) {
|
|
|
194
218
|
}
|
|
195
219
|
}
|
|
196
220
|
/**
|
|
221
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
222
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
223
|
+
* with some modifications made for this program.
|
|
224
|
+
* See the license statement at the head of this file.
|
|
225
|
+
*
|
|
197
226
|
* The core of the algorithm. Here, a new subtree is combined with the
|
|
198
227
|
* previous subtrees. Threads are used to traverse the inside and outside
|
|
199
228
|
* contours of the left and right subtree up to the highest common level.
|
|
@@ -201,6 +230,7 @@ function executeShifts(node) {
|
|
|
201
230
|
* one of the greatest uncommon ancestors using the function nextAncestor()
|
|
202
231
|
* and call moveSubtree() to shift the subtree and prepare the shifts of
|
|
203
232
|
* smaller subtrees. Finally, we add a new thread (if necessary).
|
|
233
|
+
*
|
|
204
234
|
* @param {module:echarts/data/Tree~TreeNode} subtreeV
|
|
205
235
|
* @param {module:echarts/data/Tree~TreeNode} subtreeW
|
|
206
236
|
* @param {module:echarts/data/Tree~TreeNode} ancestor
|
|
@@ -256,6 +286,7 @@ function apportion(subtreeV, subtreeW, ancestor, separation) {
|
|
|
256
286
|
* This function is used to traverse the right contour of a subtree.
|
|
257
287
|
* It returns the rightmost child of node or the thread of node. The function
|
|
258
288
|
* returns null if and only if node is on the highest depth of its subtree.
|
|
289
|
+
*
|
|
259
290
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
260
291
|
* @return {module:echarts/data/Tree~TreeNode}
|
|
261
292
|
*/
|
|
@@ -269,6 +300,7 @@ function nextRight(node) {
|
|
|
269
300
|
* This function is used to traverse the left contour of a subtree (or a subforest).
|
|
270
301
|
* It returns the leftmost child of node or the thread of node. The function
|
|
271
302
|
* returns null if and only if node is on the highest depth of its subtree.
|
|
303
|
+
*
|
|
272
304
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
273
305
|
* @return {module:echarts/data/Tree~TreeNode}
|
|
274
306
|
*/
|
|
@@ -281,6 +313,7 @@ function nextLeft(node) {
|
|
|
281
313
|
/**
|
|
282
314
|
* If nodeInLeft’s ancestor is a sibling of node, returns nodeInLeft’s ancestor.
|
|
283
315
|
* Otherwise, returns the specified ancestor.
|
|
316
|
+
*
|
|
284
317
|
* @param {module:echarts/data/Tree~TreeNode} nodeInLeft
|
|
285
318
|
* @param {module:echarts/data/Tree~TreeNode} node
|
|
286
319
|
* @param {module:echarts/data/Tree~TreeNode} ancestor
|
|
@@ -292,7 +325,14 @@ function nextAncestor(nodeInLeft, node, ancestor) {
|
|
|
292
325
|
return nodeInLeft.hierNode.ancestor.parentNode === node.parentNode ? nodeInLeft.hierNode.ancestor : ancestor;
|
|
293
326
|
}
|
|
294
327
|
/**
|
|
295
|
-
*
|
|
328
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
329
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
330
|
+
* with some modifications made for this program.
|
|
331
|
+
* See the license statement at the head of this file.
|
|
332
|
+
*
|
|
333
|
+
* Shifts the current subtree rooted at wr.
|
|
334
|
+
* This is done by increasing prelim(w+) and modifier(w+) by shift.
|
|
335
|
+
*
|
|
296
336
|
* @param {module:echarts/data/Tree~TreeNode} wl
|
|
297
337
|
* @param {module:echarts/data/Tree~TreeNode} wr
|
|
298
338
|
* @param {number} shift [description]
|
|
@@ -307,6 +347,13 @@ function moveSubtree(wl, wr, shift) {
|
|
|
307
347
|
wr.hierNode.prelim += shift;
|
|
308
348
|
wl.hierNode.change += change;
|
|
309
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* The implementation of this function was originally copied from "d3.js"
|
|
352
|
+
* <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
|
|
353
|
+
* with some modifications made for this program.
|
|
354
|
+
* See the license statement at the head of this file.
|
|
355
|
+
*/
|
|
356
|
+
|
|
310
357
|
|
|
311
358
|
function defaultSeparation(node1, node2) {
|
|
312
359
|
return node1.parentNode === node2.parentNode ? 1 : 2;
|
|
@@ -51,11 +51,13 @@ var helper = require("../helper/treeHelper");
|
|
|
51
51
|
*/
|
|
52
52
|
|
|
53
53
|
/*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
54
|
+
* A third-party license is embeded for some of the code in this file:
|
|
55
|
+
* The treemap layout implementation was originally copied from
|
|
56
|
+
* "d3.js" with some modifications made for this project.
|
|
57
|
+
* (See more details in the comment of the method "squarify" below.)
|
|
58
|
+
* The use of the source code of this file is also subject to the terms
|
|
59
|
+
* and consitions of the license of "d3.js" (BSD-3Clause, see
|
|
60
|
+
* </licenses/LICENSE-d3>).
|
|
59
61
|
*/
|
|
60
62
|
var mathMax = Math.max;
|
|
61
63
|
var mathMin = Math.min;
|
|
@@ -144,8 +146,12 @@ var _default = {
|
|
|
144
146
|
};
|
|
145
147
|
/**
|
|
146
148
|
* Layout treemap with squarify algorithm.
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
+
* The original presentation of this algorithm
|
|
150
|
+
* was made by Mark Bruls, Kees Huizing, and Jarke J. van Wijk
|
|
151
|
+
* <https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf>.
|
|
152
|
+
* The implementation of this algorithm was originally copied from "d3.js"
|
|
153
|
+
* <https://github.com/d3/d3/blob/9cc9a875e636a1dcf36cc1e07bdf77e1ad6e2c74/src/layout/treemap.js>
|
|
154
|
+
* with some modifications made for this program.
|
|
149
155
|
* See the license statement at the head of this file.
|
|
150
156
|
*
|
|
151
157
|
* @protected
|