echarts 3.5.1 → 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.
Files changed (261) hide show
  1. package/LICENSE +21 -18
  2. package/README.md +10 -0
  3. package/dist/echarts.common.js +11010 -9830
  4. package/dist/echarts.common.min.js +13 -13
  5. package/dist/echarts.js +13291 -10852
  6. package/dist/echarts.min.js +22 -21
  7. package/dist/echarts.simple.js +9904 -8990
  8. package/dist/echarts.simple.min.js +9 -10
  9. package/index.js +1 -0
  10. package/lib/ExtensionAPI.js +2 -4
  11. package/lib/chart/bar/BarView.js +141 -49
  12. package/lib/chart/bar/BaseBarSeries.js +2 -6
  13. package/lib/chart/bar.js +1 -0
  14. package/lib/chart/boxplot/BoxplotSeries.js +1 -1
  15. package/lib/chart/boxplot/boxplotLayout.js +23 -7
  16. package/lib/chart/candlestick/CandlestickSeries.js +3 -22
  17. package/lib/chart/candlestick/candlestickLayout.js +23 -7
  18. package/lib/chart/custom.js +442 -0
  19. package/lib/chart/funnel/funnelLayout.js +10 -3
  20. package/lib/chart/gauge/GaugeView.js +1 -1
  21. package/lib/chart/graph/GraphView.js +15 -9
  22. package/lib/chart/graph/categoryVisual.js +3 -2
  23. package/lib/chart/heatmap/HeatmapLayer.js +1 -1
  24. package/lib/chart/heatmap/HeatmapView.js +75 -73
  25. package/lib/chart/helper/Symbol.js +8 -31
  26. package/lib/chart/helper/createListFromArray.js +15 -10
  27. package/lib/chart/helper/labelHelper.js +48 -0
  28. package/lib/chart/helper/whiskerBoxCommon.js +25 -44
  29. package/lib/chart/map/mapDataStatistic.js +9 -8
  30. package/lib/chart/parallel/ParallelSeries.js +2 -0
  31. package/lib/chart/parallel/ParallelView.js +13 -12
  32. package/lib/chart/parallel/parallelVisual.js +9 -1
  33. package/lib/chart/pie/pieLayout.js +25 -17
  34. package/lib/chart/radar/RadarSeries.js +1 -1
  35. package/lib/chart/sankey/sankeyLayout.js +1 -1
  36. package/lib/chart/scatter/ScatterSeries.js +2 -3
  37. package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
  38. package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
  39. package/lib/chart/treemap/TreemapSeries.js +3 -3
  40. package/lib/chart/treemap/TreemapView.js +1 -1
  41. package/lib/chart/treemap/treemapLayout.js +6 -1
  42. package/lib/component/axis/AxisBuilder.js +53 -34
  43. package/lib/component/axis/ParallelAxisView.js +45 -37
  44. package/lib/component/axisPointer/AxisPointerModel.js +1 -1
  45. package/lib/component/axisPointer/BaseAxisPointer.js +20 -15
  46. package/lib/component/axisPointer/CartesianAxisPointer.js +9 -6
  47. package/lib/component/axisPointer/PolarAxisPointer.js +10 -8
  48. package/lib/component/axisPointer/SingleAxisPointer.js +11 -7
  49. package/lib/component/axisPointer/axisTrigger.js +87 -72
  50. package/lib/component/axisPointer/viewHelper.js +6 -3
  51. package/lib/component/axisPointer.js +2 -2
  52. package/lib/component/brush/BrushModel.js +6 -4
  53. package/lib/component/brush/BrushView.js +1 -1
  54. package/lib/component/brush/visualEncoding.js +6 -4
  55. package/lib/component/calendar/CalendarView.js +5 -5
  56. package/lib/component/dataZoom/AxisProxy.js +76 -13
  57. package/lib/component/dataZoom/DataZoomModel.js +21 -5
  58. package/lib/component/dataZoom/InsideZoomModel.js +4 -1
  59. package/lib/component/dataZoom/InsideZoomView.js +17 -27
  60. package/lib/component/dataZoom/SliderZoomView.js +63 -26
  61. package/lib/component/dataZoom/roams.js +9 -4
  62. package/lib/component/graphic.js +13 -12
  63. package/lib/component/helper/BrushController.js +75 -114
  64. package/lib/component/helper/BrushTargetManager.js +16 -8
  65. package/lib/component/helper/MapDraw.js +25 -11
  66. package/lib/component/helper/RoamController.js +111 -139
  67. package/lib/component/helper/brushHelper.js +25 -213
  68. package/lib/component/helper/cursorHelper.js +21 -0
  69. package/lib/component/helper/roamHelper.js +54 -0
  70. package/lib/component/helper/selectableMixin.js +7 -7
  71. package/lib/component/helper/sliderMove.js +66 -37
  72. package/lib/component/legend/LegendView.js +6 -6
  73. package/lib/component/legend/legendAction.js +1 -1
  74. package/lib/component/marker/MarkAreaView.js +3 -6
  75. package/lib/component/marker/MarkLineView.js +3 -5
  76. package/lib/component/marker/MarkPointView.js +3 -5
  77. package/lib/component/marker/MarkerView.js +10 -12
  78. package/lib/component/marker/markerHelper.js +1 -1
  79. package/lib/component/parallel.js +94 -29
  80. package/lib/component/polar.js +5 -0
  81. package/lib/component/timeline/SliderTimelineView.js +1 -1
  82. package/lib/component/toolbox/feature/Brush.js +7 -0
  83. package/lib/component/toolbox/feature/DataZoom.js +17 -4
  84. package/lib/component/tooltip/TooltipView.js +92 -20
  85. package/lib/component/visualMap/ContinuousView.js +6 -4
  86. package/lib/coord/Axis.js +34 -2
  87. package/lib/coord/axisDefault.js +4 -1
  88. package/lib/coord/axisHelper.js +32 -26
  89. package/lib/coord/axisModelCommonMixin.js +1 -1
  90. package/lib/coord/calendar/Calendar.js +14 -17
  91. package/lib/coord/calendar/prepareCustom.js +31 -0
  92. package/lib/coord/cartesian/Axis2D.js +0 -12
  93. package/lib/coord/cartesian/Cartesian2D.js +1 -0
  94. package/lib/coord/cartesian/Grid.js +5 -2
  95. package/lib/coord/cartesian/prepareCustom.js +36 -0
  96. package/lib/coord/geo/Geo.js +9 -14
  97. package/lib/coord/geo/GeoModel.js +5 -5
  98. package/lib/coord/geo/geoCreator.js +3 -3
  99. package/lib/coord/geo/parseGeoJson.js +11 -4
  100. package/lib/coord/geo/prepareCustom.js +36 -0
  101. package/lib/coord/parallel/Parallel.js +225 -101
  102. package/lib/coord/parallel/ParallelModel.js +7 -1
  103. package/lib/coord/polar/Polar.js +2 -1
  104. package/lib/coord/polar/prepareCustom.js +53 -0
  105. package/lib/coord/single/Single.js +9 -8
  106. package/lib/coord/single/SingleAxis.js +0 -27
  107. package/lib/coord/single/prepareCustom.js +33 -0
  108. package/lib/data/DataDiffer.js +2 -1
  109. package/lib/data/Graph.js +11 -7
  110. package/lib/data/List.js +59 -20
  111. package/lib/data/helper/completeDimensions.js +184 -23
  112. package/lib/echarts.js +68 -36
  113. package/lib/helper.js +1 -8
  114. package/lib/layout/barGrid.js +91 -19
  115. package/lib/layout/barPolar.js +286 -0
  116. package/lib/layout/points.js +22 -16
  117. package/lib/model/Global.js +34 -31
  118. package/lib/model/Series.js +41 -29
  119. package/lib/model/globalDefault.js +4 -1
  120. package/lib/model/mixin/colorPalette.js +2 -1
  121. package/lib/model/mixin/textStyle.js +7 -13
  122. package/lib/scale/Interval.js +46 -76
  123. package/lib/scale/Log.js +5 -7
  124. package/lib/scale/Scale.js +10 -1
  125. package/lib/scale/Time.js +34 -12
  126. package/lib/scale/helper.js +93 -0
  127. package/lib/util/format.js +20 -9
  128. package/lib/util/graphic.js +70 -8
  129. package/lib/util/layout.js +7 -3
  130. package/lib/util/model.js +63 -7
  131. package/lib/util/number.js +59 -19
  132. package/lib/util/throttle.js +14 -3
  133. package/map/js/world.js +1 -1
  134. package/map/json/world.json +1 -1
  135. package/package.json +3 -3
  136. package/src/ExtensionAPI.js +2 -4
  137. package/src/chart/bar/BarView.js +141 -49
  138. package/src/chart/bar/BaseBarSeries.js +2 -6
  139. package/src/chart/bar.js +1 -0
  140. package/src/chart/boxplot/BoxplotSeries.js +1 -1
  141. package/src/chart/boxplot/boxplotLayout.js +23 -7
  142. package/src/chart/candlestick/CandlestickSeries.js +3 -22
  143. package/src/chart/candlestick/candlestickLayout.js +23 -7
  144. package/src/chart/custom.js +442 -0
  145. package/src/chart/funnel/funnelLayout.js +10 -4
  146. package/src/chart/gauge/GaugeView.js +1 -1
  147. package/src/chart/graph/GraphView.js +15 -9
  148. package/src/chart/graph/categoryVisual.js +3 -2
  149. package/src/chart/heatmap/HeatmapLayer.js +1 -1
  150. package/src/chart/heatmap/HeatmapView.js +75 -73
  151. package/src/chart/helper/Symbol.js +8 -31
  152. package/src/chart/helper/createListFromArray.js +15 -10
  153. package/src/chart/helper/labelHelper.js +49 -0
  154. package/src/chart/helper/whiskerBoxCommon.js +25 -44
  155. package/src/chart/map/mapDataStatistic.js +9 -8
  156. package/src/chart/parallel/ParallelSeries.js +2 -0
  157. package/src/chart/parallel/ParallelView.js +13 -12
  158. package/src/chart/parallel/parallelVisual.js +9 -1
  159. package/src/chart/pie/pieLayout.js +25 -17
  160. package/src/chart/radar/RadarSeries.js +1 -1
  161. package/src/chart/sankey/sankeyLayout.js +1 -1
  162. package/src/chart/scatter/ScatterSeries.js +2 -3
  163. package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
  164. package/src/chart/themeRiver/themeRiverVisual.js +1 -1
  165. package/src/chart/treemap/TreemapSeries.js +3 -3
  166. package/src/chart/treemap/TreemapView.js +1 -1
  167. package/src/chart/treemap/treemapLayout.js +6 -1
  168. package/src/component/axis/AxisBuilder.js +53 -34
  169. package/src/component/axis/ParallelAxisView.js +45 -37
  170. package/src/component/axisPointer/AxisPointerModel.js +1 -1
  171. package/src/component/axisPointer/BaseAxisPointer.js +20 -15
  172. package/src/component/axisPointer/CartesianAxisPointer.js +9 -6
  173. package/src/component/axisPointer/PolarAxisPointer.js +10 -8
  174. package/src/component/axisPointer/SingleAxisPointer.js +11 -7
  175. package/src/component/axisPointer/axisTrigger.js +87 -72
  176. package/src/component/axisPointer/viewHelper.js +6 -3
  177. package/src/component/axisPointer.js +2 -2
  178. package/src/component/brush/BrushModel.js +6 -4
  179. package/src/component/brush/BrushView.js +1 -1
  180. package/src/component/brush/visualEncoding.js +6 -4
  181. package/src/component/calendar/CalendarView.js +5 -5
  182. package/src/component/dataZoom/AxisProxy.js +76 -13
  183. package/src/component/dataZoom/DataZoomModel.js +21 -5
  184. package/src/component/dataZoom/InsideZoomModel.js +4 -1
  185. package/src/component/dataZoom/InsideZoomView.js +17 -27
  186. package/src/component/dataZoom/SliderZoomView.js +63 -26
  187. package/src/component/dataZoom/roams.js +9 -4
  188. package/src/component/graphic.js +13 -12
  189. package/src/component/helper/BrushController.js +75 -114
  190. package/src/component/helper/BrushTargetManager.js +16 -8
  191. package/src/component/helper/MapDraw.js +25 -11
  192. package/src/component/helper/RoamController.js +111 -139
  193. package/src/component/helper/brushHelper.js +41 -0
  194. package/src/component/helper/cursorHelper.js +22 -0
  195. package/src/component/helper/roamHelper.js +55 -0
  196. package/src/component/helper/selectableMixin.js +7 -7
  197. package/src/component/helper/sliderMove.js +66 -37
  198. package/src/component/legend/LegendView.js +6 -6
  199. package/src/component/legend/legendAction.js +1 -1
  200. package/src/component/marker/MarkAreaView.js +3 -6
  201. package/src/component/marker/MarkLineView.js +3 -5
  202. package/src/component/marker/MarkPointView.js +3 -5
  203. package/src/component/marker/MarkerView.js +10 -12
  204. package/src/component/marker/markerHelper.js +1 -1
  205. package/src/component/parallel.js +94 -29
  206. package/src/component/polar.js +5 -0
  207. package/src/component/timeline/SliderTimelineView.js +1 -1
  208. package/src/component/toolbox/feature/Brush.js +7 -0
  209. package/src/component/toolbox/feature/DataZoom.js +17 -4
  210. package/src/component/tooltip/TooltipView.js +92 -20
  211. package/src/component/visualMap/ContinuousView.js +6 -4
  212. package/src/coord/Axis.js +34 -2
  213. package/src/coord/axisDefault.js +4 -1
  214. package/src/coord/axisHelper.js +32 -26
  215. package/src/coord/axisModelCommonMixin.js +1 -1
  216. package/src/coord/calendar/Calendar.js +14 -17
  217. package/src/coord/calendar/prepareCustom.js +32 -0
  218. package/src/coord/cartesian/Axis2D.js +0 -12
  219. package/src/coord/cartesian/Cartesian2D.js +1 -0
  220. package/src/coord/cartesian/Grid.js +5 -2
  221. package/src/coord/cartesian/prepareCustom.js +37 -0
  222. package/src/coord/geo/Geo.js +9 -14
  223. package/src/coord/geo/GeoModel.js +5 -5
  224. package/src/coord/geo/geoCreator.js +3 -3
  225. package/src/coord/geo/parseGeoJson.js +11 -4
  226. package/src/coord/geo/prepareCustom.js +37 -0
  227. package/src/coord/parallel/Parallel.js +225 -101
  228. package/src/coord/parallel/ParallelModel.js +7 -1
  229. package/src/coord/polar/Polar.js +2 -1
  230. package/src/coord/polar/prepareCustom.js +54 -0
  231. package/src/coord/single/Single.js +9 -8
  232. package/src/coord/single/SingleAxis.js +0 -27
  233. package/src/coord/single/prepareCustom.js +34 -0
  234. package/src/data/DataDiffer.js +2 -1
  235. package/src/data/Graph.js +11 -7
  236. package/src/data/List.js +59 -20
  237. package/src/data/helper/completeDimensions.js +184 -23
  238. package/src/echarts.js +68 -36
  239. package/src/helper.js +1 -8
  240. package/src/layout/barGrid.js +91 -19
  241. package/src/layout/barPolar.js +287 -0
  242. package/src/layout/points.js +22 -16
  243. package/src/model/Global.js +34 -31
  244. package/src/model/Series.js +41 -29
  245. package/src/model/globalDefault.js +4 -1
  246. package/src/model/mixin/colorPalette.js +2 -1
  247. package/src/model/mixin/textStyle.js +7 -13
  248. package/src/scale/Interval.js +46 -76
  249. package/src/scale/Log.js +5 -7
  250. package/src/scale/Scale.js +10 -1
  251. package/src/scale/Time.js +34 -12
  252. package/src/scale/helper.js +94 -0
  253. package/src/util/format.js +20 -9
  254. package/src/util/graphic.js +70 -8
  255. package/src/util/layout.js +7 -3
  256. package/src/util/model.js +63 -7
  257. package/src/util/number.js +59 -19
  258. package/src/util/throttle.js +14 -3
  259. package/src/coord/cartesian/axisLabelInterval.js +0 -26
  260. package/theme/default.js +0 -23
  261. package/theme/halloween.js +0 -528
@@ -0,0 +1,442 @@
1
+
2
+
3
+ var echarts = require('../echarts');
4
+ var zrUtil = require('zrender/lib/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
+
@@ -23,9 +23,15 @@
23
23
  for (var i = 0, len = data.count(); i < len; i++) {
24
24
  indices[i] = i;
25
25
  }
26
- indices.sort(function (a, b) {
27
- return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
28
- });
26
+
27
+ // Add custom sortable function & none sortable opetion by "options.sort"
28
+ if (typeof sort === 'function') {
29
+ indices.sort(sort);
30
+ } else if (sort !== 'none') {
31
+ indices.sort(function (a, b) {
32
+ return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
33
+ });
34
+ }
29
35
  return indices;
30
36
  }
31
37
 
@@ -167,3 +173,4 @@
167
173
  labelLayout(data);
168
174
  });
169
175
  };
176
+
@@ -291,7 +291,7 @@
291
291
  }
292
292
  });
293
293
 
294
- graphic.updateProps(pointer, {
294
+ graphic.initProps(pointer, {
295
295
  shape: {
296
296
  angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
297
297
  }
@@ -4,6 +4,8 @@
4
4
  var SymbolDraw = require('../helper/SymbolDraw');
5
5
  var LineDraw = require('../helper/LineDraw');
6
6
  var RoamController = require('../../component/helper/RoamController');
7
+ var roamHelper = require('../../component/helper/roamHelper');
8
+ var cursorHelper = require('../../component/helper/cursorHelper');
7
9
 
8
10
  var graphic = require('../../util/graphic');
9
11
  var adjustEdge = require('./adjustEdge');
@@ -25,14 +27,14 @@
25
27
  var lineDraw = new LineDraw();
26
28
  var group = this.group;
27
29
 
28
- var controller = new RoamController(api.getZr(), group);
30
+ this._controller = new RoamController(api.getZr());
31
+ this._controllerHost = {target: group};
29
32
 
30
33
  group.add(symbolDraw.group);
31
34
  group.add(lineDraw.group);
32
35
 
33
36
  this._symbolDraw = symbolDraw;
34
37
  this._lineDraw = lineDraw;
35
- this._controller = controller;
36
38
 
37
39
  this._firstRender = true;
38
40
  },
@@ -71,7 +73,7 @@
71
73
 
72
74
  this._updateNodeAndLinkScale();
73
75
 
74
- this._updateController(seriesModel, api);
76
+ this._updateController(seriesModel, ecModel, api);
75
77
 
76
78
  clearTimeout(this._layoutTimeout);
77
79
  var forceLayout = seriesModel.forceLayout;
@@ -157,6 +159,7 @@
157
159
 
158
160
  dispose: function () {
159
161
  this._controller && this._controller.dispose();
162
+ this._controllerHost = {};
160
163
  },
161
164
 
162
165
  focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
@@ -254,14 +257,16 @@
254
257
  })();
255
258
  },
256
259
 
257
- _updateController: function (seriesModel, api) {
260
+ _updateController: function (seriesModel, ecModel, api) {
258
261
  var controller = this._controller;
262
+ var controllerHost = this._controllerHost;
259
263
  var group = this.group;
260
264
 
261
- controller.setContainsPoint(function (x, y) {
265
+ controller.setPointerChecker(function (e, x, y) {
262
266
  var rect = group.getBoundingRect();
263
267
  rect.applyTransform(group.transform);
264
- return rect.contain(x, y);
268
+ return rect.contain(x, y)
269
+ && !cursorHelper.onIrrelevantElement(e, api, seriesModel);
265
270
  });
266
271
 
267
272
  if (seriesModel.coordinateSystem.type !== 'view') {
@@ -269,14 +274,14 @@
269
274
  return;
270
275
  }
271
276
  controller.enable(seriesModel.get('roam'));
272
- controller.zoomLimit = seriesModel.get('scaleLimit');
273
- // Update zoom from model
274
- controller.zoom = seriesModel.coordinateSystem.getZoom();
277
+ controllerHost.zoomLimit = seriesModel.get('scaleLimit');
278
+ controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
275
279
 
276
280
  controller
277
281
  .off('pan')
278
282
  .off('zoom')
279
283
  .on('pan', function (dx, dy) {
284
+ roamHelper.updateViewOnPan(controllerHost, dx, dy);
280
285
  api.dispatchAction({
281
286
  seriesId: seriesModel.id,
282
287
  type: 'graphRoam',
@@ -285,6 +290,7 @@
285
290
  });
286
291
  })
287
292
  .on('zoom', function (zoom, mouseX, mouseY) {
293
+ roamHelper.updateViewOnZoom(controllerHost, zoom, mouseX, mouseY);
288
294
  api.dispatchAction({
289
295
  seriesId: seriesModel.id,
290
296
  type: 'graphRoam',
@@ -11,7 +11,8 @@
11
11
 
12
12
  categoriesData.each(function (idx) {
13
13
  var name = categoriesData.getName(idx);
14
- categoryNameIdxMap[name] = idx;
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 @@
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(
@@ -131,7 +131,7 @@
131
131
  _getGradient: function (data, colorFunc, state) {
132
132
  var gradientPixels = this._gradientPixels;
133
133
  var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
134
- var color = [];
134
+ var color = [0, 0, 0, 0];
135
135
  var off = 0;
136
136
  for (var i = 0; i < 256; i++) {
137
137
  colorFunc[state](i / 255, true, color);