echarts 3.5.4 → 3.6.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/LICENSE +21 -18
- package/dist/echarts.common.js +10072 -9330
- package/dist/echarts.common.min.js +13 -13
- package/dist/echarts.js +13084 -11412
- package/dist/echarts.min.js +22 -21
- package/dist/echarts.simple.js +9454 -8889
- package/dist/echarts.simple.min.js +9 -10
- package/index.js +1 -0
- package/lib/chart/bar/BarView.js +141 -49
- package/lib/chart/bar/BaseBarSeries.js +2 -6
- package/lib/chart/bar.js +1 -0
- package/lib/chart/boxplot/BoxplotSeries.js +1 -1
- package/lib/chart/boxplot/boxplotLayout.js +23 -7
- package/lib/chart/candlestick/CandlestickSeries.js +1 -21
- package/lib/chart/candlestick/candlestickLayout.js +23 -7
- package/lib/chart/custom.js +442 -0
- package/lib/chart/graph/categoryVisual.js +3 -2
- package/lib/chart/heatmap/HeatmapView.js +75 -73
- package/lib/chart/helper/Symbol.js +8 -31
- package/lib/chart/helper/createListFromArray.js +15 -10
- package/lib/chart/helper/labelHelper.js +48 -0
- package/lib/chart/helper/whiskerBoxCommon.js +25 -44
- package/lib/chart/map/mapDataStatistic.js +9 -8
- package/lib/chart/pie/pieLayout.js +25 -17
- package/lib/chart/radar/RadarSeries.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -3
- package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +3 -3
- package/lib/component/axisPointer/BaseAxisPointer.js +7 -6
- package/lib/component/axisPointer/axisTrigger.js +62 -51
- package/lib/component/axisPointer.js +1 -2
- package/lib/component/calendar/CalendarView.js +5 -5
- package/lib/component/dataZoom/AxisProxy.js +76 -13
- package/lib/component/dataZoom/DataZoomModel.js +21 -5
- package/lib/component/dataZoom/InsideZoomModel.js +4 -1
- package/lib/component/dataZoom/InsideZoomView.js +16 -26
- package/lib/component/dataZoom/SliderZoomView.js +63 -26
- package/lib/component/dataZoom/roams.js +8 -3
- package/lib/component/graphic.js +13 -12
- package/lib/component/helper/BrushTargetManager.js +5 -5
- package/lib/component/helper/MapDraw.js +3 -3
- package/lib/component/helper/RoamController.js +43 -20
- package/lib/component/helper/brushHelper.js +2 -13
- package/lib/component/helper/selectableMixin.js +7 -7
- package/lib/component/helper/sliderMove.js +65 -36
- package/lib/component/legend/LegendView.js +6 -6
- package/lib/component/legend/legendAction.js +1 -1
- package/lib/component/marker/MarkAreaView.js +3 -6
- package/lib/component/marker/MarkLineView.js +3 -5
- package/lib/component/marker/MarkPointView.js +3 -5
- package/lib/component/marker/MarkerView.js +10 -12
- package/lib/component/polar.js +5 -0
- package/lib/component/timeline/SliderTimelineView.js +1 -1
- package/lib/component/toolbox/feature/DataZoom.js +14 -1
- package/lib/component/tooltip/TooltipView.js +3 -3
- package/lib/component/visualMap/ContinuousView.js +6 -4
- package/lib/coord/Axis.js +34 -2
- package/lib/coord/axisDefault.js +2 -1
- package/lib/coord/axisHelper.js +6 -25
- package/lib/coord/axisModelCommonMixin.js +1 -1
- package/lib/coord/calendar/Calendar.js +14 -17
- package/lib/coord/calendar/prepareCustom.js +31 -0
- package/lib/coord/cartesian/Axis2D.js +0 -12
- package/lib/coord/cartesian/Cartesian2D.js +1 -0
- package/lib/coord/cartesian/Grid.js +5 -2
- package/lib/coord/cartesian/prepareCustom.js +36 -0
- package/lib/coord/geo/Geo.js +9 -14
- package/lib/coord/geo/GeoModel.js +5 -5
- package/lib/coord/geo/geoCreator.js +3 -3
- package/lib/coord/geo/prepareCustom.js +36 -0
- package/lib/coord/parallel/Parallel.js +12 -11
- package/lib/coord/polar/Polar.js +2 -1
- package/lib/coord/polar/prepareCustom.js +53 -0
- package/lib/coord/single/Single.js +9 -8
- package/lib/coord/single/SingleAxis.js +0 -27
- package/lib/coord/single/prepareCustom.js +33 -0
- package/lib/data/DataDiffer.js +2 -1
- package/lib/data/Graph.js +11 -7
- package/lib/data/List.js +58 -19
- package/lib/data/helper/completeDimensions.js +184 -23
- package/lib/echarts.js +38 -33
- package/lib/helper.js +1 -8
- package/lib/layout/barGrid.js +87 -18
- package/lib/layout/barPolar.js +286 -0
- package/lib/layout/points.js +22 -16
- package/lib/model/Global.js +34 -31
- package/lib/model/Series.js +41 -29
- package/lib/model/mixin/colorPalette.js +2 -1
- package/lib/model/mixin/textStyle.js +7 -13
- package/lib/scale/Interval.js +21 -14
- package/lib/scale/Log.js +5 -7
- package/lib/scale/Time.js +13 -7
- package/lib/scale/helper.js +5 -1
- package/lib/util/format.js +12 -0
- package/lib/util/graphic.js +53 -1
- package/lib/util/model.js +63 -7
- package/map/js/world.js +1 -1
- package/map/json/world.json +1 -1
- package/package.json +3 -3
- package/src/chart/bar/BarView.js +141 -49
- package/src/chart/bar/BaseBarSeries.js +2 -6
- package/src/chart/bar.js +1 -0
- package/src/chart/boxplot/BoxplotSeries.js +1 -1
- package/src/chart/boxplot/boxplotLayout.js +23 -7
- package/src/chart/candlestick/CandlestickSeries.js +1 -21
- package/src/chart/candlestick/candlestickLayout.js +23 -7
- package/src/chart/custom.js +442 -0
- package/src/chart/graph/categoryVisual.js +3 -2
- package/src/chart/heatmap/HeatmapView.js +75 -73
- package/src/chart/helper/Symbol.js +8 -31
- package/src/chart/helper/createListFromArray.js +15 -10
- package/src/chart/helper/labelHelper.js +49 -0
- package/src/chart/helper/whiskerBoxCommon.js +25 -44
- package/src/chart/map/mapDataStatistic.js +9 -8
- package/src/chart/pie/pieLayout.js +25 -17
- package/src/chart/radar/RadarSeries.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -3
- package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/src/chart/themeRiver/themeRiverVisual.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +3 -3
- package/src/component/axisPointer/BaseAxisPointer.js +7 -6
- package/src/component/axisPointer/axisTrigger.js +62 -51
- package/src/component/axisPointer.js +1 -2
- package/src/component/calendar/CalendarView.js +5 -5
- package/src/component/dataZoom/AxisProxy.js +76 -13
- package/src/component/dataZoom/DataZoomModel.js +21 -5
- package/src/component/dataZoom/InsideZoomModel.js +4 -1
- package/src/component/dataZoom/InsideZoomView.js +16 -26
- package/src/component/dataZoom/SliderZoomView.js +63 -26
- package/src/component/dataZoom/roams.js +8 -3
- package/src/component/graphic.js +13 -12
- package/src/component/helper/BrushTargetManager.js +5 -5
- package/src/component/helper/MapDraw.js +3 -3
- package/src/component/helper/RoamController.js +43 -20
- package/src/component/helper/brushHelper.js +2 -13
- package/src/component/helper/selectableMixin.js +7 -7
- package/src/component/helper/sliderMove.js +65 -36
- package/src/component/legend/LegendView.js +6 -6
- package/src/component/legend/legendAction.js +1 -1
- package/src/component/marker/MarkAreaView.js +3 -6
- package/src/component/marker/MarkLineView.js +3 -5
- package/src/component/marker/MarkPointView.js +3 -5
- package/src/component/marker/MarkerView.js +10 -12
- package/src/component/polar.js +5 -0
- package/src/component/timeline/SliderTimelineView.js +1 -1
- package/src/component/toolbox/feature/DataZoom.js +14 -1
- package/src/component/tooltip/TooltipView.js +3 -3
- package/src/component/visualMap/ContinuousView.js +6 -4
- package/src/coord/Axis.js +34 -2
- package/src/coord/axisDefault.js +2 -1
- package/src/coord/axisHelper.js +6 -25
- package/src/coord/axisModelCommonMixin.js +1 -1
- package/src/coord/calendar/Calendar.js +14 -17
- package/src/coord/calendar/prepareCustom.js +32 -0
- package/src/coord/cartesian/Axis2D.js +0 -12
- package/src/coord/cartesian/Cartesian2D.js +1 -0
- package/src/coord/cartesian/Grid.js +5 -2
- package/src/coord/cartesian/prepareCustom.js +37 -0
- package/src/coord/geo/Geo.js +9 -14
- package/src/coord/geo/GeoModel.js +5 -5
- package/src/coord/geo/geoCreator.js +3 -3
- package/src/coord/geo/prepareCustom.js +37 -0
- package/src/coord/parallel/Parallel.js +12 -11
- package/src/coord/polar/Polar.js +2 -1
- package/src/coord/polar/prepareCustom.js +54 -0
- package/src/coord/single/Single.js +9 -8
- package/src/coord/single/SingleAxis.js +0 -27
- package/src/coord/single/prepareCustom.js +34 -0
- package/src/data/DataDiffer.js +2 -1
- package/src/data/Graph.js +11 -7
- package/src/data/List.js +58 -19
- package/src/data/helper/completeDimensions.js +184 -23
- package/src/echarts.js +38 -33
- package/src/helper.js +1 -8
- package/src/layout/barGrid.js +87 -18
- package/src/layout/barPolar.js +287 -0
- package/src/layout/points.js +22 -16
- package/src/model/Global.js +34 -31
- package/src/model/Series.js +41 -29
- package/src/model/mixin/colorPalette.js +2 -1
- package/src/model/mixin/textStyle.js +7 -13
- package/src/scale/Interval.js +21 -14
- package/src/scale/Log.js +5 -7
- package/src/scale/Time.js +13 -7
- package/src/scale/helper.js +5 -1
- package/src/util/format.js +12 -0
- package/src/util/graphic.js +53 -1
- package/src/util/model.js +63 -7
- package/src/coord/cartesian/axisLabelInterval.js +0 -26
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
define(function (require) {
|
|
2
|
+
|
|
3
|
+
var echarts = require('../echarts');
|
|
4
|
+
var zrUtil = require('zrender/core/util');
|
|
5
|
+
var graphicUtil = require('../util/graphic');
|
|
6
|
+
var labelHelper = require('./helper/labelHelper');
|
|
7
|
+
var createListFromArray = require('./helper/createListFromArray');
|
|
8
|
+
var barGrid = require('../layout/barGrid');
|
|
9
|
+
|
|
10
|
+
var ITEM_STYLE_NORMAL_PATH = ['itemStyle', 'normal'];
|
|
11
|
+
var ITEM_STYLE_EMPHASIS_PATH = ['itemStyle', 'emphasis'];
|
|
12
|
+
var LABEL_NORMAL = ['label', 'normal'];
|
|
13
|
+
var LABEL_EMPHASIS = ['label', 'emphasis'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* To reduce total package size of each coordinate systems, the modules `prepareCustom`
|
|
17
|
+
* of each coordinate systems are not required by each coordinate systems directly, but
|
|
18
|
+
* required by the module `custom`.
|
|
19
|
+
*
|
|
20
|
+
* prepareInfoForCustomSeries {Function}: optional
|
|
21
|
+
* @return {Object} {coordSys: {...}, api: {
|
|
22
|
+
* coord: function (data, clamp) {}, // return point in global.
|
|
23
|
+
* size: function (dataSize, dataItem) {} // return size of each axis in coordSys.
|
|
24
|
+
* }}
|
|
25
|
+
*/
|
|
26
|
+
var prepareCustoms = {
|
|
27
|
+
cartesian2d: require('../coord/cartesian/prepareCustom'),
|
|
28
|
+
geo: require('../coord/geo/prepareCustom'),
|
|
29
|
+
singleAxis: require('../coord/single/prepareCustom'),
|
|
30
|
+
polar: require('../coord/polar/prepareCustom'),
|
|
31
|
+
calendar: require('../coord/calendar/prepareCustom')
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// ------
|
|
35
|
+
// Model
|
|
36
|
+
// ------
|
|
37
|
+
|
|
38
|
+
echarts.extendSeriesModel({
|
|
39
|
+
|
|
40
|
+
type: 'series.custom',
|
|
41
|
+
|
|
42
|
+
dependencies: ['grid', 'polar', 'geo', 'singleAxis', 'calendar'],
|
|
43
|
+
|
|
44
|
+
defaultOption: {
|
|
45
|
+
coordinateSystem: 'cartesian2d',
|
|
46
|
+
zlevel: 0,
|
|
47
|
+
z: 2,
|
|
48
|
+
legendHoverLink: true
|
|
49
|
+
|
|
50
|
+
// Cartesian coordinate system
|
|
51
|
+
// xAxisIndex: 0,
|
|
52
|
+
// yAxisIndex: 0,
|
|
53
|
+
|
|
54
|
+
// Polar coordinate system
|
|
55
|
+
// polarIndex: 0,
|
|
56
|
+
|
|
57
|
+
// Geo coordinate system
|
|
58
|
+
// geoIndex: 0,
|
|
59
|
+
|
|
60
|
+
// label: {}
|
|
61
|
+
// itemStyle: {}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getInitialData: function (option, ecModel) {
|
|
65
|
+
return createListFromArray(option.data, this, ecModel);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// -----
|
|
70
|
+
// View
|
|
71
|
+
// -----
|
|
72
|
+
|
|
73
|
+
echarts.extendChartView({
|
|
74
|
+
|
|
75
|
+
type: 'custom',
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @private
|
|
79
|
+
* @type {module:echarts/data/List}
|
|
80
|
+
*/
|
|
81
|
+
_data: null,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @override
|
|
85
|
+
*/
|
|
86
|
+
render: function (customSeries, ecModel, api) {
|
|
87
|
+
var oldData = this._data;
|
|
88
|
+
var data = customSeries.getData();
|
|
89
|
+
var group = this.group;
|
|
90
|
+
var renderItem = makeRenderItem(customSeries, data, ecModel, api);
|
|
91
|
+
|
|
92
|
+
data.diff(oldData)
|
|
93
|
+
.add(function (newIdx) {
|
|
94
|
+
data.hasValue(newIdx) && createOrUpdate(
|
|
95
|
+
null, newIdx, renderItem(newIdx), customSeries, group, data
|
|
96
|
+
);
|
|
97
|
+
})
|
|
98
|
+
.update(function (newIdx, oldIdx) {
|
|
99
|
+
var el = oldData.getItemGraphicEl(oldIdx);
|
|
100
|
+
data.hasValue(newIdx)
|
|
101
|
+
? createOrUpdate(
|
|
102
|
+
el, newIdx, renderItem(newIdx), customSeries, group, data
|
|
103
|
+
)
|
|
104
|
+
: (el && group.remove(el));
|
|
105
|
+
})
|
|
106
|
+
.remove(function (oldIdx) {
|
|
107
|
+
var el = oldData.getItemGraphicEl(oldIdx);
|
|
108
|
+
el && group.remove(el);
|
|
109
|
+
})
|
|
110
|
+
.execute();
|
|
111
|
+
|
|
112
|
+
this._data = data;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
function createEl(elOption) {
|
|
118
|
+
var graphicType = elOption.type;
|
|
119
|
+
var el;
|
|
120
|
+
|
|
121
|
+
if (graphicType === 'path') {
|
|
122
|
+
var shape = elOption.shape;
|
|
123
|
+
el = graphicUtil.makePath(
|
|
124
|
+
shape.pathData,
|
|
125
|
+
null,
|
|
126
|
+
{
|
|
127
|
+
x: shape.x || 0,
|
|
128
|
+
y: shape.y || 0,
|
|
129
|
+
width: shape.width || 0,
|
|
130
|
+
height: shape.height || 0
|
|
131
|
+
},
|
|
132
|
+
'center'
|
|
133
|
+
);
|
|
134
|
+
el.__customPathData = elOption.pathData;
|
|
135
|
+
}
|
|
136
|
+
else if (graphicType === 'image') {
|
|
137
|
+
el = new graphicUtil.Image({
|
|
138
|
+
});
|
|
139
|
+
el.__customImagePath = elOption.style.image;
|
|
140
|
+
}
|
|
141
|
+
else if (graphicType === 'text') {
|
|
142
|
+
el = new graphicUtil.Text({
|
|
143
|
+
});
|
|
144
|
+
el.__customText = elOption.style.text;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
|
|
148
|
+
|
|
149
|
+
if (__DEV__) {
|
|
150
|
+
zrUtil.assert(Clz, 'graphic type "' + graphicType + '" can not be found.');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
el = new Clz();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
el.__customGraphicType = graphicType;
|
|
157
|
+
|
|
158
|
+
return el;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function updateEl(el, dataIndex, elOption, animatableModel, data, isInit) {
|
|
162
|
+
var targetProps = {};
|
|
163
|
+
var elOptionStyle = elOption.style || {};
|
|
164
|
+
|
|
165
|
+
elOption.shape && (targetProps.shape = zrUtil.clone(elOption.shape));
|
|
166
|
+
elOption.position && (targetProps.position = elOption.position.slice());
|
|
167
|
+
elOption.scale && (targetProps.scale = elOption.scale.slice());
|
|
168
|
+
elOption.origin && (targetProps.origin = elOption.origin.slice());
|
|
169
|
+
elOption.rotation && (targetProps.rotation = elOption.rotation);
|
|
170
|
+
|
|
171
|
+
if (el.type === 'image' && elOption.style) {
|
|
172
|
+
var targetStyle = targetProps.style = {};
|
|
173
|
+
zrUtil.each(['x', 'y', 'width', 'height'], function (prop) {
|
|
174
|
+
prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (el.type === 'text' && elOption.style) {
|
|
179
|
+
var targetStyle = targetProps.style = {};
|
|
180
|
+
zrUtil.each(['x', 'y'], function (prop) {
|
|
181
|
+
prepareStyleTransition(prop, targetStyle, elOptionStyle, el.style, isInit);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (el.type !== 'group') {
|
|
186
|
+
el.useStyle(elOptionStyle);
|
|
187
|
+
|
|
188
|
+
// Init animation.
|
|
189
|
+
if (isInit) {
|
|
190
|
+
el.style.opacity = 0;
|
|
191
|
+
var targetOpacity = elOptionStyle.opacity;
|
|
192
|
+
targetOpacity == null && (targetOpacity = 1);
|
|
193
|
+
graphicUtil.initProps(el, {style: {opacity: targetOpacity}}, animatableModel, dataIndex);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (isInit) {
|
|
198
|
+
el.attr(targetProps);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
graphicUtil.updateProps(el, targetProps, animatableModel, dataIndex);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// z2 must not be null/undefined, otherwise sort error may occur.
|
|
205
|
+
el.attr({z2: elOption.z2 || 0, silent: elOption.silent});
|
|
206
|
+
|
|
207
|
+
el.styleEmphasis !== false && graphicUtil.setHoverStyle(el, el.styleEmphasis);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function prepareStyleTransition(prop, targetStyle, elOptionStyle, oldElStyle, isInit) {
|
|
211
|
+
if (elOptionStyle[prop] != null && !isInit) {
|
|
212
|
+
targetStyle[prop] = elOptionStyle[prop];
|
|
213
|
+
elOptionStyle[prop] = oldElStyle[prop];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function makeRenderItem(customSeries, data, ecModel, api) {
|
|
218
|
+
var renderItem = customSeries.get('renderItem');
|
|
219
|
+
var coordSys = customSeries.coordinateSystem;
|
|
220
|
+
|
|
221
|
+
if (__DEV__) {
|
|
222
|
+
zrUtil.assert(renderItem, 'series.render is required.');
|
|
223
|
+
zrUtil.assert(prepareCustoms[coordSys.type], 'This coordSys does not support custom series.');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var prepareResult = prepareCustoms[coordSys.type](coordSys);
|
|
227
|
+
|
|
228
|
+
var userAPI = zrUtil.defaults({
|
|
229
|
+
getWidth: api.getWidth,
|
|
230
|
+
getHeight: api.getHeight,
|
|
231
|
+
getZr: api.getZr,
|
|
232
|
+
getDevicePixelRatio: api.getDevicePixelRatio,
|
|
233
|
+
value: value,
|
|
234
|
+
style: style,
|
|
235
|
+
styleEmphasis: styleEmphasis,
|
|
236
|
+
visual: visual,
|
|
237
|
+
barLayout: barLayout,
|
|
238
|
+
currentSeriesIndices: currentSeriesIndices,
|
|
239
|
+
font: font
|
|
240
|
+
}, prepareResult.api);
|
|
241
|
+
|
|
242
|
+
var userParams = {
|
|
243
|
+
context: {},
|
|
244
|
+
seriesId: customSeries.id,
|
|
245
|
+
seriesName: customSeries.name,
|
|
246
|
+
seriesIndex: customSeries.seriesIndex,
|
|
247
|
+
coordSys: prepareResult.coordSys,
|
|
248
|
+
dataInsideLength: data.count(),
|
|
249
|
+
encode: wrapEncodeDef(customSeries.getData())
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// Do not support call `api` asynchronously without dataIndexInside input.
|
|
253
|
+
var currDataIndexInside;
|
|
254
|
+
var currDirty = true;
|
|
255
|
+
var currItemModel;
|
|
256
|
+
var currLabelNormalModel;
|
|
257
|
+
var currLabelEmphasisModel;
|
|
258
|
+
var currLabelValueDim;
|
|
259
|
+
var currVisualColor;
|
|
260
|
+
|
|
261
|
+
return function (dataIndexInside) {
|
|
262
|
+
currDataIndexInside = dataIndexInside;
|
|
263
|
+
currDirty = true;
|
|
264
|
+
return renderItem && renderItem(
|
|
265
|
+
zrUtil.defaults({
|
|
266
|
+
dataIndexInside: dataIndexInside,
|
|
267
|
+
dataIndex: data.getRawIndex(dataIndexInside)
|
|
268
|
+
}, userParams),
|
|
269
|
+
userAPI
|
|
270
|
+
) || {};
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Do not update cache until api called.
|
|
274
|
+
function updateCache(dataIndexInside) {
|
|
275
|
+
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
|
|
276
|
+
if (currDirty) {
|
|
277
|
+
currItemModel = data.getItemModel(dataIndexInside);
|
|
278
|
+
currLabelNormalModel = currItemModel.getModel(LABEL_NORMAL);
|
|
279
|
+
currLabelEmphasisModel = currItemModel.getModel(LABEL_EMPHASIS);
|
|
280
|
+
currLabelValueDim = labelHelper.findLabelValueDim(data);
|
|
281
|
+
currVisualColor = data.getItemVisual(dataIndexInside, 'color');
|
|
282
|
+
|
|
283
|
+
currDirty = false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @public
|
|
289
|
+
* @param {nubmer|string} dim
|
|
290
|
+
* @param {number} [dataIndexInside=currDataIndexInside]
|
|
291
|
+
* @return {number|string} value
|
|
292
|
+
*/
|
|
293
|
+
function value(dim, dataIndexInside) {
|
|
294
|
+
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
|
|
295
|
+
return data.get(data.getDimension(dim || 0), dataIndexInside);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* By default, `visual` is applied to style (to support visualMap).
|
|
300
|
+
* `visual.color` is applied at `fill`. If user want apply visual.color on `stroke`,
|
|
301
|
+
* it can be implemented as:
|
|
302
|
+
* `api.style({stroke: api.visual('color'), fill: null})`;
|
|
303
|
+
* @public
|
|
304
|
+
* @param {Object} [extra]
|
|
305
|
+
* @param {number} [dataIndexInside=currDataIndexInside]
|
|
306
|
+
*/
|
|
307
|
+
function style(extra, dataIndexInside) {
|
|
308
|
+
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
|
|
309
|
+
updateCache(dataIndexInside);
|
|
310
|
+
|
|
311
|
+
var itemStyle = currItemModel.getModel(ITEM_STYLE_NORMAL_PATH).getItemStyle();
|
|
312
|
+
|
|
313
|
+
currVisualColor != null && (itemStyle.fill = currVisualColor);
|
|
314
|
+
var opacity = data.getItemVisual(dataIndexInside, 'opacity');
|
|
315
|
+
opacity != null && (itemStyle.opacity = opacity);
|
|
316
|
+
|
|
317
|
+
labelHelper.setTextToStyle(
|
|
318
|
+
data, dataIndexInside, currLabelValueDim, itemStyle,
|
|
319
|
+
customSeries, currLabelNormalModel, currVisualColor
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
extra && zrUtil.extend(itemStyle, extra);
|
|
323
|
+
return itemStyle;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @public
|
|
328
|
+
* @param {Object} [extra]
|
|
329
|
+
* @param {number} [dataIndexInside=currDataIndexInside]
|
|
330
|
+
*/
|
|
331
|
+
function styleEmphasis(extra, dataIndexInside) {
|
|
332
|
+
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
|
|
333
|
+
updateCache(dataIndexInside);
|
|
334
|
+
|
|
335
|
+
var itemStyle = currItemModel.getModel(ITEM_STYLE_EMPHASIS_PATH).getItemStyle();
|
|
336
|
+
|
|
337
|
+
labelHelper.setTextToStyle(
|
|
338
|
+
data, dataIndexInside, currLabelValueDim, itemStyle,
|
|
339
|
+
customSeries, currLabelEmphasisModel, currVisualColor
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
extra && zrUtil.extend(itemStyle, extra);
|
|
343
|
+
return itemStyle;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* @public
|
|
348
|
+
* @param {string} visualType
|
|
349
|
+
* @param {number} [dataIndexInside=currDataIndexInside]
|
|
350
|
+
*/
|
|
351
|
+
function visual(visualType, dataIndexInside) {
|
|
352
|
+
dataIndexInside == null && (dataIndexInside = currDataIndexInside);
|
|
353
|
+
return data.getItemVisual(dataIndexInside, visualType);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @public
|
|
358
|
+
* @param {number} opt.count Positive interger.
|
|
359
|
+
* @param {number} [opt.barWidth]
|
|
360
|
+
* @param {number} [opt.barMaxWidth]
|
|
361
|
+
* @param {number} [opt.barGap]
|
|
362
|
+
* @param {number} [opt.barCategoryGap]
|
|
363
|
+
* @return {Object} {width, offset, offsetCenter} is not support, return undefined.
|
|
364
|
+
*/
|
|
365
|
+
function barLayout(opt) {
|
|
366
|
+
if (coordSys.getBaseAxis) {
|
|
367
|
+
var baseAxis = coordSys.getBaseAxis();
|
|
368
|
+
return barGrid.getLayoutOnAxis(zrUtil.defaults({axis: baseAxis}, opt), api);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @public
|
|
374
|
+
* @return {Array.<number>}
|
|
375
|
+
*/
|
|
376
|
+
function currentSeriesIndices() {
|
|
377
|
+
return ecModel.getCurrentSeriesIndices();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* @public
|
|
382
|
+
* @param {Object} opt
|
|
383
|
+
* @param {string} [opt.fontStyle]
|
|
384
|
+
* @param {number} [opt.fontWeight]
|
|
385
|
+
* @param {number} [opt.fontSize]
|
|
386
|
+
* @param {string} [opt.fontFamily]
|
|
387
|
+
* @return {string} font string
|
|
388
|
+
*/
|
|
389
|
+
function font(opt) {
|
|
390
|
+
return graphicUtil.getFont(opt, ecModel);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function wrapEncodeDef(data) {
|
|
395
|
+
var encodeDef = {};
|
|
396
|
+
zrUtil.each(data.dimensions, function (dimName, dataDimIndex) {
|
|
397
|
+
var dimInfo = data.getDimensionInfo(dimName);
|
|
398
|
+
if (!dimInfo.isExtraCoord) {
|
|
399
|
+
var coordDim = dimInfo.coordDim;
|
|
400
|
+
var dataDims = encodeDef[coordDim] = encodeDef[coordDim] || [];
|
|
401
|
+
dataDims[dimInfo.coordDimIndex] = dataDimIndex;
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
return encodeDef;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function createOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
|
|
408
|
+
el = doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data);
|
|
409
|
+
el && data.setItemGraphicEl(dataIndex, el);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
|
|
413
|
+
var elOptionType = elOption.type;
|
|
414
|
+
if (el
|
|
415
|
+
&& elOptionType !== el.__customGraphicType
|
|
416
|
+
&& (elOptionType !== 'path' || elOption.pathData !== el.__customPathData)
|
|
417
|
+
&& (elOptionType !== 'image' || elOption.style.image !== el.__customImagePath)
|
|
418
|
+
&& (elOptionType !== 'text' || elOption.style.text !== el.__customText)
|
|
419
|
+
) {
|
|
420
|
+
group.remove(el);
|
|
421
|
+
el = null;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// `elOption.type` is undefined when `renderItem` returns nothing.
|
|
425
|
+
if (elOptionType == null) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
var isInit = !el;
|
|
430
|
+
!el && (el = createEl(elOption));
|
|
431
|
+
updateEl(el, dataIndex, elOption, animatableModel, data, isInit);
|
|
432
|
+
|
|
433
|
+
elOptionType === 'group' && zrUtil.each(elOption.children, function (childOption, index) {
|
|
434
|
+
doCreateOrUpdate(el.childAt(index), dataIndex, childOption, animatableModel, el, data);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
group.add(el);
|
|
438
|
+
|
|
439
|
+
return el;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
});
|
|
@@ -11,7 +11,8 @@ define(function (require) {
|
|
|
11
11
|
|
|
12
12
|
categoriesData.each(function (idx) {
|
|
13
13
|
var name = categoriesData.getName(idx);
|
|
14
|
-
|
|
14
|
+
// Add prefix to avoid conflict with Object.prototype.
|
|
15
|
+
categoryNameIdxMap['ec-' + name] = idx;
|
|
15
16
|
|
|
16
17
|
var itemModel = categoriesData.getItemModel(idx);
|
|
17
18
|
var color = itemModel.get('itemStyle.normal.color')
|
|
@@ -26,7 +27,7 @@ define(function (require) {
|
|
|
26
27
|
var category = model.getShallow('category');
|
|
27
28
|
if (category != null) {
|
|
28
29
|
if (typeof category === 'string') {
|
|
29
|
-
category = categoryNameIdxMap[category];
|
|
30
|
+
category = categoryNameIdxMap['ec-' + category];
|
|
30
31
|
}
|
|
31
32
|
if (!data.getItemVisual(idx, 'color', true)) {
|
|
32
33
|
data.setItemVisual(
|
|
@@ -109,7 +109,6 @@ define(function (require) {
|
|
|
109
109
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
112
|
var group = this.group;
|
|
114
113
|
var data = seriesModel.getData();
|
|
115
114
|
|
|
@@ -121,90 +120,93 @@ define(function (require) {
|
|
|
121
120
|
var hoverStl = seriesModel.getModel(hoverItemStyleQuery).getItemStyle();
|
|
122
121
|
var labelModel = seriesModel.getModel('label.normal');
|
|
123
122
|
var hoverLabelModel = seriesModel.getModel('label.emphasis');
|
|
123
|
+
var coordSysType = coordSys.type;
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
shape: {
|
|
144
|
-
x: point[0] - width / 2,
|
|
145
|
-
y: point[1] - height / 2,
|
|
146
|
-
width: width,
|
|
147
|
-
height: height
|
|
148
|
-
},
|
|
149
|
-
style: {
|
|
150
|
-
fill: data.getItemVisual(idx, 'color'),
|
|
151
|
-
opacity: data.getItemVisual(idx, 'opacity')
|
|
152
|
-
}
|
|
153
|
-
});
|
|
125
|
+
var dataDims = coordSysType === 'cartesian2d'
|
|
126
|
+
? [
|
|
127
|
+
seriesModel.coordDimToDataDim('x')[0],
|
|
128
|
+
seriesModel.coordDimToDataDim('y')[0],
|
|
129
|
+
seriesModel.coordDimToDataDim('value')[0]
|
|
130
|
+
]
|
|
131
|
+
: [
|
|
132
|
+
seriesModel.coordDimToDataDim('time')[0],
|
|
133
|
+
seriesModel.coordDimToDataDim('value')[0]
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
data.each(function (idx) {
|
|
137
|
+
var rect;
|
|
138
|
+
|
|
139
|
+
if (coordSysType === 'cartesian2d') {
|
|
140
|
+
// Ignore empty data
|
|
141
|
+
if (isNaN(data.get(dataDims[2], idx))) {
|
|
142
|
+
return;
|
|
154
143
|
}
|
|
155
|
-
else {
|
|
156
|
-
// x => time y => value z => idx
|
|
157
144
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
var point = coordSys.dataToPoint([
|
|
146
|
+
data.get(dataDims[0], idx),
|
|
147
|
+
data.get(dataDims[1], idx)
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
rect = new graphic.Rect({
|
|
151
|
+
shape: {
|
|
152
|
+
x: point[0] - width / 2,
|
|
153
|
+
y: point[1] - height / 2,
|
|
154
|
+
width: width,
|
|
155
|
+
height: height
|
|
156
|
+
},
|
|
157
|
+
style: {
|
|
158
|
+
fill: data.getItemVisual(idx, 'color'),
|
|
159
|
+
opacity: data.getItemVisual(idx, 'opacity')
|
|
161
160
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
style: {
|
|
169
|
-
fill: data.getItemVisual(idx, 'color'),
|
|
170
|
-
opacity: data.getItemVisual(idx, 'opacity')
|
|
171
|
-
}
|
|
172
|
-
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// Ignore empty data
|
|
165
|
+
if (isNaN(data.get(dataDims[1], idx))) {
|
|
166
|
+
return;
|
|
173
167
|
}
|
|
174
168
|
|
|
169
|
+
rect = new graphic.Rect({
|
|
170
|
+
z2: 1,
|
|
171
|
+
shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape,
|
|
172
|
+
style: {
|
|
173
|
+
fill: data.getItemVisual(idx, 'color'),
|
|
174
|
+
opacity: data.getItemVisual(idx, 'opacity')
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
175
178
|
|
|
176
|
-
|
|
179
|
+
var itemModel = data.getItemModel(idx);
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
// Optimization for large datset
|
|
182
|
+
if (data.hasItemOption) {
|
|
183
|
+
style = itemModel.getModel(itemStyleQuery).getItemStyle(['color']);
|
|
184
|
+
hoverStl = itemModel.getModel(hoverItemStyleQuery).getItemStyle();
|
|
185
|
+
labelModel = itemModel.getModel(labelQuery);
|
|
186
|
+
hoverLabelModel = itemModel.getModel(hoverLabelQuery);
|
|
187
|
+
}
|
|
185
188
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
var rawValue = seriesModel.getRawValue(idx);
|
|
190
|
+
var defaultText = '-';
|
|
191
|
+
if (rawValue && rawValue[2] != null) {
|
|
192
|
+
defaultText = rawValue[2];
|
|
193
|
+
}
|
|
194
|
+
if (labelModel.getShallow('show')) {
|
|
195
|
+
graphic.setText(style, labelModel);
|
|
196
|
+
style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText;
|
|
197
|
+
}
|
|
198
|
+
if (hoverLabelModel.getShallow('show')) {
|
|
199
|
+
graphic.setText(hoverStl, hoverLabelModel);
|
|
200
|
+
hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText;
|
|
201
|
+
}
|
|
199
202
|
|
|
200
|
-
|
|
203
|
+
rect.setStyle(style);
|
|
201
204
|
|
|
202
|
-
|
|
205
|
+
graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
|
|
203
206
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
207
|
+
group.add(rect);
|
|
208
|
+
data.setItemGraphicEl(idx, rect);
|
|
209
|
+
});
|
|
208
210
|
},
|
|
209
211
|
|
|
210
212
|
_renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
|
|
@@ -7,6 +7,7 @@ define(function (require) {
|
|
|
7
7
|
var symbolUtil = require('../../util/symbol');
|
|
8
8
|
var graphic = require('../../util/graphic');
|
|
9
9
|
var numberUtil = require('../../util/number');
|
|
10
|
+
var labelHelper = require('./labelHelper');
|
|
10
11
|
|
|
11
12
|
function getSymbolSize(data, idx) {
|
|
12
13
|
var symbolSize = data.getItemVisual(idx, 'symbolSize');
|
|
@@ -218,37 +219,13 @@ define(function (require) {
|
|
|
218
219
|
elStyle.opacity = opacity;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
valueDim
|
|
227
|
-
|
|
228
|
-
dataType === 'ordinal' || dataType === 'time'
|
|
229
|
-
)) {} // jshint ignore:line
|
|
230
|
-
|
|
231
|
-
if (valueDim != null && labelModel.getShallow('show')) {
|
|
232
|
-
graphic.setText(elStyle, labelModel, color);
|
|
233
|
-
elStyle.text = zrUtil.retrieve(
|
|
234
|
-
seriesModel.getFormattedLabel(idx, 'normal'),
|
|
235
|
-
data.get(valueDim, idx)
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
elStyle.text = '';
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (valueDim != null && hoverLabelModel.getShallow('show')) {
|
|
243
|
-
graphic.setText(hoverItemStyle, hoverLabelModel, color);
|
|
244
|
-
hoverItemStyle.text = zrUtil.retrieve(
|
|
245
|
-
seriesModel.getFormattedLabel(idx, 'emphasis'),
|
|
246
|
-
data.get(valueDim, idx)
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
hoverItemStyle.text = '';
|
|
251
|
-
}
|
|
222
|
+
var valueDim = labelHelper.findLabelValueDim(data);
|
|
223
|
+
labelHelper.setTextToStyle(
|
|
224
|
+
data, idx, valueDim, elStyle, seriesModel, labelModel, color
|
|
225
|
+
);
|
|
226
|
+
labelHelper.setTextToStyle(
|
|
227
|
+
data, idx, valueDim, hoverItemStyle, seriesModel, hoverLabelModel, color
|
|
228
|
+
);
|
|
252
229
|
|
|
253
230
|
symbolPath.off('mouseover')
|
|
254
231
|
.off('mouseout')
|