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
@@ -3,163 +3,34 @@
3
3
  */
4
4
 
5
5
 
6
-
7
6
  var Eventful = require('zrender/lib/mixin/Eventful');
8
7
  var zrUtil = require('zrender/lib/core/util');
9
8
  var eventTool = require('zrender/lib/core/event');
10
9
  var interactionMutex = require('./interactionMutex');
11
10
 
12
- function mousedown(e) {
13
- if (e.target && e.target.draggable) {
14
- return;
15
- }
16
-
17
- var x = e.offsetX;
18
- var y = e.offsetY;
19
-
20
- if (this.containsPoint && this.containsPoint(x, y)) {
21
- this._x = x;
22
- this._y = y;
23
- this._dragging = true;
24
- }
25
- }
26
-
27
- function mousemove(e) {
28
- if (!this._dragging) {
29
- return;
30
- }
31
-
32
- eventTool.stop(e.event);
33
-
34
- if (e.gestureEvent !== 'pinch') {
35
-
36
- if (interactionMutex.isTaken(this._zr, 'globalPan')) {
37
- return;
38
- }
39
-
40
- var x = e.offsetX;
41
- var y = e.offsetY;
42
-
43
- var oldX = this._x;
44
- var oldY = this._y;
45
-
46
- var dx = x - oldX;
47
- var dy = y - oldY;
48
-
49
- this._x = x;
50
- this._y = y;
51
-
52
- var target = this.target;
53
-
54
- if (target) {
55
- var pos = target.position;
56
- pos[0] += dx;
57
- pos[1] += dy;
58
- target.dirty();
59
- }
60
-
61
- eventTool.stop(e.event);
62
- this.trigger('pan', dx, dy, oldX, oldY, x, y);
63
- }
64
- }
65
-
66
- function mouseup(e) {
67
- this._dragging = false;
68
- }
69
-
70
- function mousewheel(e) {
71
- // wheelDelta maybe -0 in chrome mac.
72
- if (e.wheelDelta === 0) {
73
- return;
74
- }
75
- // Convenience:
76
- // Mac and VM Windows on Mac: scroll up: zoom out.
77
- // Windows: scroll up: zoom in.
78
- var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
79
- zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
80
- }
81
-
82
- function pinch(e) {
83
- if (interactionMutex.isTaken(this._zr, 'globalPan')) {
84
- return;
85
- }
86
- var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
87
- zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
88
- }
89
-
90
- function zoom(e, zoomDelta, zoomX, zoomY) {
91
- if (this.containsPoint && this.containsPoint(zoomX, zoomY)) {
92
- // When mouse is out of roamController rect,
93
- // default befavoius should be be disabled, otherwise
94
- // page sliding is disabled, contrary to expectation.
95
- eventTool.stop(e.event);
96
-
97
- var target = this.target;
98
- var zoomLimit = this.zoomLimit;
99
-
100
- if (target) {
101
- var pos = target.position;
102
- var scale = target.scale;
103
-
104
- var newZoom = this.zoom = this.zoom || 1;
105
- newZoom *= zoomDelta;
106
- if (zoomLimit) {
107
- var zoomMin = zoomLimit.min || 0;
108
- var zoomMax = zoomLimit.max || Infinity;
109
- newZoom = Math.max(
110
- Math.min(zoomMax, newZoom),
111
- zoomMin
112
- );
113
- }
114
- var zoomScale = newZoom / this.zoom;
115
- this.zoom = newZoom;
116
- // Keep the mouse center when scaling
117
- pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
118
- pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
119
- scale[0] *= zoomScale;
120
- scale[1] *= zoomScale;
121
-
122
- target.dirty();
123
- }
124
-
125
- this.trigger('zoom', zoomDelta, zoomX, zoomY);
126
- }
127
- }
128
-
129
11
  /**
130
12
  * @alias module:echarts/component/helper/RoamController
131
13
  * @constructor
132
14
  * @mixin {module:zrender/mixin/Eventful}
133
15
  *
134
16
  * @param {module:zrender/zrender~ZRender} zr
135
- * @param {module:zrender/Element} target
136
17
  */
137
- function RoamController(zr, target) {
138
-
139
- /**
140
- * @type {module:zrender/Element}
141
- */
142
- this.target = target;
18
+ function RoamController(zr) {
143
19
 
144
20
  /**
145
21
  * @type {Function}
146
22
  */
147
- this.containsPoint;
23
+ this.pointerChecker;
148
24
 
149
25
  /**
150
- * { min: 1, max: 2 }
151
- * @type {Object}
26
+ * @type {module:zrender}
152
27
  */
153
- this.zoomLimit;
28
+ this._zr = zr;
154
29
 
155
30
  /**
156
- * @type {number}
157
- */
158
- this.zoom;
159
- /**
160
- * @type {module:zrender}
31
+ * @type {Object}
161
32
  */
162
- this._zr = zr;
33
+ this._opt = {};
163
34
 
164
35
  // Avoid two roamController bind the same handler
165
36
  var bind = zrUtil.bind;
@@ -172,12 +43,12 @@
172
43
  Eventful.call(this);
173
44
 
174
45
  /**
175
- * @param {Function} containsPoint
46
+ * @param {Function} pointerChecker
176
47
  * input: x, y
177
48
  * output: boolean
178
49
  */
179
- this.setContainsPoint = function (containsPoint) {
180
- this.containsPoint = containsPoint;
50
+ this.setPointerChecker = function (pointerChecker) {
51
+ this.pointerChecker = pointerChecker;
181
52
  };
182
53
 
183
54
  /**
@@ -188,11 +59,22 @@
188
59
  * @param {boolean|string} [controlType=true] Specify the control type,
189
60
  * which can be null/undefined or true/false
190
61
  * or 'pan/move' or 'zoom'/'scale'
62
+ * @param {Object} [opt]
63
+ * @param {Object} [opt.zoomOnMouseWheel=true]
64
+ * @param {Object} [opt.moveOnMouseMove=true]
65
+ * @param {Object} [opt.preventDefaultMouseMove=true] When pan.
191
66
  */
192
- this.enable = function (controlType) {
67
+ this.enable = function (controlType, opt) {
68
+
193
69
  // Disable previous first
194
70
  this.disable();
195
71
 
72
+ this._opt = zrUtil.defaults(zrUtil.clone(opt) || {}, {
73
+ zoomOnMouseWheel: true,
74
+ moveOnMouseMove: true,
75
+ preventDefaultMouseMove: true
76
+ });
77
+
196
78
  if (controlType == null) {
197
79
  controlType = true;
198
80
  }
@@ -229,4 +111,94 @@
229
111
 
230
112
  zrUtil.mixin(RoamController, Eventful);
231
113
 
114
+
115
+ function mousedown(e) {
116
+ if (e.target && e.target.draggable) {
117
+ return;
118
+ }
119
+
120
+ var x = e.offsetX;
121
+ var y = e.offsetY;
122
+
123
+ // Only check on mosedown, but not mousemove.
124
+ // Mouse can be out of target when mouse moving.
125
+ if (this.pointerChecker && this.pointerChecker(e, x, y)) {
126
+ this._x = x;
127
+ this._y = y;
128
+ this._dragging = true;
129
+ }
130
+ }
131
+
132
+ function mousemove(e) {
133
+ if (!checkKeyBinding(this, 'moveOnMouseMove', e) || !this._dragging) {
134
+ return;
135
+ }
136
+
137
+ if (e.gestureEvent === 'pinch') {
138
+ return;
139
+ }
140
+
141
+ if (interactionMutex.isTaken(this._zr, 'globalPan')) {
142
+ return;
143
+ }
144
+
145
+ var x = e.offsetX;
146
+ var y = e.offsetY;
147
+
148
+ var oldX = this._x;
149
+ var oldY = this._y;
150
+
151
+ var dx = x - oldX;
152
+ var dy = y - oldY;
153
+
154
+ this._x = x;
155
+ this._y = y;
156
+
157
+ this._opt.preventDefaultMouseMove && eventTool.stop(e.event);
158
+
159
+ this.trigger('pan', dx, dy, oldX, oldY, x, y);
160
+ }
161
+
162
+ function mouseup(e) {
163
+ this._dragging = false;
164
+ }
165
+
166
+ function mousewheel(e) {
167
+ // wheelDelta maybe -0 in chrome mac.
168
+ if (!checkKeyBinding(this, 'zoomOnMouseWheel', e) || e.wheelDelta === 0) {
169
+ return;
170
+ }
171
+
172
+ // Convenience:
173
+ // Mac and VM Windows on Mac: scroll up: zoom out.
174
+ // Windows: scroll up: zoom in.
175
+ var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
176
+ zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
177
+ }
178
+
179
+ function pinch(e) {
180
+ if (interactionMutex.isTaken(this._zr, 'globalPan')) {
181
+ return;
182
+ }
183
+ var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
184
+ zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
185
+ }
186
+
187
+ function zoom(e, zoomDelta, zoomX, zoomY) {
188
+ if (this.pointerChecker && this.pointerChecker(e, zoomX, zoomY)) {
189
+ // When mouse is out of roamController rect,
190
+ // default befavoius should not be be disabled, otherwise
191
+ // page sliding is disabled, contrary to expectation.
192
+ eventTool.stop(e.event);
193
+
194
+ this.trigger('zoom', zoomDelta, zoomX, zoomY);
195
+ }
196
+ }
197
+
198
+ function checkKeyBinding(roamController, prop, e) {
199
+ var setting = roamController._opt[prop];
200
+ return setting
201
+ && (!zrUtil.isString(setting) || e.event[setting + 'Key']);
202
+ }
203
+
232
204
  module.exports = RoamController;
@@ -1,228 +1,40 @@
1
1
 
2
2
 
3
- var zrUtil = require('zrender/lib/core/util');
4
- var graphic = require('../../util/graphic');
5
-
6
- var each = zrUtil.each;
3
+ var cursorHelper = require('./cursorHelper');
4
+ var BoundingRect = require('zrender/lib/core/BoundingRect');
5
+ var graphicUtil = require('../../util/graphic');
7
6
 
8
7
  var helper = {};
9
8
 
10
- var COMPONENT_NAMES = ['geo', 'xAxis', 'yAxis'];
11
- var PANEL_ID_SPLIT = '--';
12
- var COORD_CONVERTS = ['dataToPoint', 'pointToData'];
13
-
14
- helper.parseOutputRanges = function (areas, coordInfoList, ecModel, rangesCoordInfo) {
15
- each(areas, function (area, index) {
16
- var panelId = area.panelId;
17
-
18
- if (panelId) {
19
- panelId = panelId.split(PANEL_ID_SPLIT);
20
-
21
- area[panelId[0] + 'Index'] = +panelId[1];
22
-
23
- var coordInfo = findCoordInfo(area, coordInfoList);
24
- area.coordRange = coordConvert[area.brushType](
25
- 1, coordInfo, area.range
26
- );
27
- rangesCoordInfo && (rangesCoordInfo[index] = coordInfo);
28
- }
29
- });
30
- };
31
-
32
- helper.parseInputRanges = function (brushModel, ecModel) {
33
- each(brushModel.areas, function (area) {
34
- var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
35
-
36
- if (__DEV__) {
37
- zrUtil.assert(
38
- !coordInfo || coordInfo === true || area.coordRange,
39
- 'coordRange must be specified when coord index specified.'
40
- );
41
- zrUtil.assert(
42
- !coordInfo || coordInfo !== true || area.range,
43
- 'range must be specified.'
44
- );
45
- }
46
-
47
- area.range = area.range || [];
48
-
49
- // convert coordRange to global range and set panelId.
50
- if (coordInfo && coordInfo !== true) {
51
- area.range = coordConvert[area.brushType](
52
- 0, coordInfo, area.coordRange
53
- );
54
- area.panelId = coordInfo.panelId;
55
- }
56
- });
9
+ helper.makeRectPanelClipPath = function (rect) {
10
+ rect = normalizeRect(rect);
11
+ return function (localPoints, transform) {
12
+ return graphicUtil.clipPointsByRect(localPoints, rect);
13
+ };
57
14
  };
58
15
 
59
- helper.makePanelOpts = function (coordInfoList) {
60
- var panelOpts = [];
61
-
62
- each(coordInfoList, function (coordInfo) {
63
- var coordSys = coordInfo.coordSys;
64
- var rect;
65
-
66
- if (coordInfo.geoIndex >= 0) {
67
- rect = coordSys.getBoundingRect().clone();
68
- // geo roam and zoom transform
69
- rect.applyTransform(graphic.getTransform(coordSys));
70
- }
71
- else { // xAxis or yAxis
72
- // grid is not Transformable.
73
- rect = coordSys.grid.getRect().clone();
74
- }
75
-
76
- panelOpts.push({panelId: coordInfo.panelId, rect: rect});
77
- });
78
-
79
- return panelOpts;
80
- };
81
-
82
- /**
83
- * @param {Object} option {xAxisIndex, yAxisIndex, geoIndex}
84
- * @param {module:echarts/model/Global} ecModel
85
- * @return {Array.<Obejct>} coordInfoList
86
- */
87
- helper.makeCoordInfoList = function (option, ecModel) {
88
- var coordInfoList = [];
89
-
90
- each(COMPONENT_NAMES, function (componentName) {
91
- var componentIndices = option[componentName + 'Index'];
92
- if (componentIndices == null || componentIndices === 'none') {
93
- return;
94
- }
95
- if (componentIndices !== 'all' && !zrUtil.isArray(componentIndices)) {
96
- componentIndices = [componentIndices];
97
- }
98
-
99
- ecModel.eachComponent({mainType: componentName}, function (componentModel, index) {
100
- if (componentIndices !== 'all' && zrUtil.indexOf(componentIndices, index) < 0) {
101
- return;
102
- }
103
-
104
- var grid;
105
- var coordSys;
106
-
107
- (componentName === 'xAxis' || componentName === 'yAxis')
108
- ? (grid = componentModel.axis.grid)
109
- : (coordSys = componentModel.coordinateSystem); // geo
110
-
111
- var coordInfo;
112
-
113
- // Check duplicate and find cartesian when tranval to yAxis.
114
- for (var i = 0, len = coordInfoList.length; i < len; i++) {
115
- var cInfo = coordInfoList[i];
116
- if (__DEV__) {
117
- zrUtil.assert(
118
- cInfo[componentName + 'Index'] != index,
119
- 'Coord should not be defined duplicately: ' + componentName + index
120
- );
121
- }
122
- // CoordSys is always required for `rect brush` or `polygon brush`.
123
- // If both xAxisIndex and yAxisIndex specified, fetch cartesian by them.
124
- if (componentName === 'yAxis' && !cInfo.yAxis && cInfo.xAxis) {
125
- var aCoordSys = grid.getCartesian(cInfo.xAxisIndex, index);
126
- if (aCoordSys) { // The yAxis and xAxis are in the same cartesian.
127
- coordSys = aCoordSys;
128
- coordInfo = cInfo;
129
- break;
130
- }
131
- }
132
- }
133
-
134
- !coordInfo && coordInfoList.push(coordInfo = {});
135
-
136
- coordInfo[componentName] = componentModel;
137
- coordInfo[componentName + 'Index'] = index;
138
- // If both xAxisIndex and yAxisIndex specified, panelId only use yAxisIndex,
139
- // which is enough to index panel.
140
- coordInfo.panelId = componentName + PANEL_ID_SPLIT + index;
141
- coordInfo.coordSys = coordSys
142
- // If only xAxisIndex or only yAxisIndex specified, find its first cartesian.
143
- || grid.getCartesian(coordInfo.xAxisIndex, coordInfo.yAxisIndex);
144
-
145
- coordInfo.coordSys
146
- ? (coordInfoList[componentName + 'Has'] = true)
147
- : coordInfoList.pop(); // If a coordInfo exists originally, existance of coordSys is ensured.
148
- });
149
- });
150
-
151
- return coordInfoList;
16
+ helper.makeLinearBrushOtherExtent = function (rect, specifiedXYIndex) {
17
+ rect = normalizeRect(rect);
18
+ return function (xyIndex) {
19
+ var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex;
20
+ var brushWidth = idx ? rect.width : rect.height;
21
+ var base = idx ? rect.x : rect.y;
22
+ return [base, base + (brushWidth || 0)];
23
+ };
152
24
  };
153
25
 
154
- helper.controlSeries = function (area, brushModel, seriesModel) {
155
- // Check whether area is bound in coord, and series do not belong to that coord.
156
- // If do not do this check, some brush (like lineX) will controll all axes.
157
- var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
158
- return coordInfo === true || (coordInfo && coordInfo.coordSys === seriesModel.coordinateSystem);
26
+ helper.makeRectIsTargetByCursor = function (rect, api, targetModel) {
27
+ rect = normalizeRect(rect);
28
+ return function (e, localCursorPoint, transform) {
29
+ return rect.contain(localCursorPoint[0], localCursorPoint[1])
30
+ && !cursorHelper.onIrrelevantElement(e, api, targetModel);
31
+ };
159
32
  };
160
33
 
161
- function formatMinMax(minMax) {
162
- minMax[0] > minMax[1] && minMax.reverse();
163
- return minMax;
34
+ // Consider width/height is negative.
35
+ function normalizeRect(rect) {
36
+ return BoundingRect.create(rect);
164
37
  }
165
38
 
166
- /**
167
- * If return Object, a coord found.
168
- * If reutrn true, global found.
169
- * Otherwise nothing found.
170
- *
171
- * @param {Object} area {<componentName>Index}
172
- * @param {Array} coordInfoList
173
- * @return {Obejct|boolean}
174
- */
175
- function findCoordInfo(area, coordInfoList) {
176
- var isGlobal = true;
177
- for (var j = 0; j < COMPONENT_NAMES.length; j++) {
178
- var indexAttr = COMPONENT_NAMES[j] + 'Index';
179
- if (area[indexAttr] >= 0) {
180
- isGlobal = false;
181
- for (var i = 0; i < coordInfoList.length; i++) {
182
- if (coordInfoList[i][indexAttr] === area[indexAttr]) {
183
- return coordInfoList[i];
184
- }
185
- }
186
- }
187
- }
188
- return isGlobal;
189
- }
190
-
191
- function axisConvert(axisName, to, coordInfo, coordRange) {
192
- var axis = coordInfo.coordSys.getAxis(axisName);
193
-
194
- if (__DEV__) {
195
- zrUtil.assert(axis, 'line brush is only available in cartesian (grid).');
196
- }
197
-
198
- return formatMinMax(zrUtil.map([0, 1], function (i) {
199
- return to
200
- ? axis.coordToData(axis.toLocalCoord(coordRange[i]))
201
- : axis.toGlobalCoord(axis.dataToCoord(coordRange[i]));
202
- }));
203
- }
204
-
205
- var coordConvert = {
206
-
207
- lineX: zrUtil.curry(axisConvert, 'x'),
208
-
209
- lineY: zrUtil.curry(axisConvert, 'y'),
210
-
211
- rect: function (to, coordInfo, coordRange) {
212
- var coordSys = coordInfo.coordSys;
213
- var xminymin = coordSys[COORD_CONVERTS[to]]([coordRange[0][0], coordRange[1][0]]);
214
- var xmaxymax = coordSys[COORD_CONVERTS[to]]([coordRange[0][1], coordRange[1][1]]);
215
- return [
216
- formatMinMax([xminymin[0], xmaxymax[0]]),
217
- formatMinMax([xminymin[1], xmaxymax[1]])
218
- ];
219
- },
220
-
221
- polygon: function (to, coordInfo, coordRange) {
222
- var coordSys = coordInfo.coordSys;
223
- return zrUtil.map(coordRange, coordSys[COORD_CONVERTS[to]], coordSys);
224
- }
225
- };
226
-
227
39
  module.exports = helper;
228
40
 
@@ -0,0 +1,21 @@
1
+
2
+
3
+ var helper = {};
4
+
5
+ var IRRELEVANT_EXCLUDES = {'axisPointer': 1, 'tooltip': 1, 'brush': 1};
6
+
7
+ /**
8
+ * Avoid that: mouse click on a elements that is over geo or graph,
9
+ * but roam is triggered.
10
+ */
11
+ helper.onIrrelevantElement = function (e, api, targetCoordSysModel) {
12
+ var model = api.getComponentByElement(e.topTarget);
13
+ // If model is axisModel, it works only if it is injected with coordinateSystem.
14
+ var coordSys = model && model.coordinateSystem;
15
+ return model
16
+ && model !== targetCoordSysModel
17
+ && !IRRELEVANT_EXCLUDES[model.mainType]
18
+ && (coordSys && coordSys.model !== targetCoordSysModel);
19
+ };
20
+
21
+ module.exports = helper;
@@ -0,0 +1,54 @@
1
+
2
+
3
+ var helper = {};
4
+
5
+ /**
6
+ * For geo and graph.
7
+ *
8
+ * @param {Object} controllerHost
9
+ * @param {module:zrender/Element} controllerHost.target
10
+ */
11
+ helper.updateViewOnPan = function (controllerHost, dx, dy) {
12
+ var target = controllerHost.target;
13
+ var pos = target.position;
14
+ pos[0] += dx;
15
+ pos[1] += dy;
16
+ target.dirty();
17
+ };
18
+
19
+ /**
20
+ * For geo and graph.
21
+ *
22
+ * @param {Object} controllerHost
23
+ * @param {module:zrender/Element} controllerHost.target
24
+ * @param {number} controllerHost.zoom
25
+ * @param {number} controllerHost.zoomLimit like: {min: 1, max: 2}
26
+ */
27
+ helper.updateViewOnZoom = function (controllerHost, zoomDelta, zoomX, zoomY) {
28
+ var target = controllerHost.target;
29
+ var zoomLimit = controllerHost.zoomLimit;
30
+ var pos = target.position;
31
+ var scale = target.scale;
32
+
33
+ var newZoom = controllerHost.zoom = controllerHost.zoom || 1;
34
+ newZoom *= zoomDelta;
35
+ if (zoomLimit) {
36
+ var zoomMin = zoomLimit.min || 0;
37
+ var zoomMax = zoomLimit.max || Infinity;
38
+ newZoom = Math.max(
39
+ Math.min(zoomMax, newZoom),
40
+ zoomMin
41
+ );
42
+ }
43
+ var zoomScale = newZoom / controllerHost.zoom;
44
+ controllerHost.zoom = newZoom;
45
+ // Keep the mouse center when scaling
46
+ pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
47
+ pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
48
+ scale[0] *= zoomScale;
49
+ scale[1] *= zoomScale;
50
+
51
+ target.dirty();
52
+ };
53
+
54
+ module.exports = helper;
@@ -13,9 +13,9 @@
13
13
 
14
14
  updateSelectedMap: function (targetList) {
15
15
  this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
16
- targetMap[target.name] = target;
16
+ targetMap.set(target.name, target);
17
17
  return targetMap;
18
- }, {});
18
+ }, zrUtil.createHashMap());
19
19
  },
20
20
  /**
21
21
  * @param {string} name
@@ -23,10 +23,10 @@
23
23
  // PENGING If selectedMode is null ?
24
24
  select: function (name) {
25
25
  var targetMap = this._selectTargetMap;
26
- var target = targetMap[name];
26
+ var target = targetMap.get(name);
27
27
  var selectedMode = this.get('selectedMode');
28
28
  if (selectedMode === 'single') {
29
- zrUtil.each(targetMap, function (target) {
29
+ targetMap.each(function (target) {
30
30
  target.selected = false;
31
31
  });
32
32
  }
@@ -37,7 +37,7 @@
37
37
  * @param {string} name
38
38
  */
39
39
  unSelect: function (name) {
40
- var target = this._selectTargetMap[name];
40
+ var target = this._selectTargetMap.get(name);
41
41
  // var selectedMode = this.get('selectedMode');
42
42
  // selectedMode !== 'single' && target && (target.selected = false);
43
43
  target && (target.selected = false);
@@ -47,7 +47,7 @@
47
47
  * @param {string} name
48
48
  */
49
49
  toggleSelected: function (name) {
50
- var target = this._selectTargetMap[name];
50
+ var target = this._selectTargetMap.get(name);
51
51
  if (target != null) {
52
52
  this[target.selected ? 'unSelect' : 'select'](name);
53
53
  return target.selected;
@@ -58,7 +58,7 @@
58
58
  * @param {string} name
59
59
  */
60
60
  isSelected: function (name) {
61
- var target = this._selectTargetMap[name];
61
+ var target = this._selectTargetMap.get(name);
62
62
  return target && target.selected;
63
63
  }
64
64
  };