echarts 4.4.0 → 4.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 (211) hide show
  1. package/.github/ISSUE_TEMPLATE.md +1 -1
  2. package/.github/workflows/nodejs.yml +31 -0
  3. package/CONTRIBUTING.md +2 -2
  4. package/README.md +6 -12
  5. package/dist/echarts-en.common.js +2354 -1029
  6. package/dist/echarts-en.common.min.js +1 -1
  7. package/dist/echarts-en.js +2727 -1138
  8. package/dist/echarts-en.js.map +1 -1
  9. package/dist/echarts-en.min.js +1 -1
  10. package/dist/echarts-en.simple.js +2028 -759
  11. package/dist/echarts-en.simple.min.js +1 -1
  12. package/dist/echarts.common.js +2354 -1029
  13. package/dist/echarts.common.min.js +1 -1
  14. package/dist/echarts.js +2727 -1138
  15. package/dist/echarts.js.map +1 -1
  16. package/dist/echarts.min.js +1 -1
  17. package/dist/echarts.simple.js +2028 -759
  18. package/dist/echarts.simple.min.js +1 -1
  19. package/dist/extension/dataTool.js +9 -0
  20. package/dist/extension/dataTool.js.map +1 -1
  21. package/echarts.all.js +1 -1
  22. package/lib/chart/bar/BarSeries.js +4 -1
  23. package/lib/chart/bar/BarView.js +20 -6
  24. package/lib/chart/bar/BaseBarSeries.js +5 -1
  25. package/lib/chart/candlestick/CandlestickSeries.js +1 -0
  26. package/lib/chart/candlestick/CandlestickView.js +42 -1
  27. package/lib/chart/custom.js +1 -0
  28. package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
  29. package/lib/chart/funnel/FunnelSeries.js +15 -5
  30. package/lib/chart/gauge/GaugeSeries.js +0 -9
  31. package/lib/chart/graph/GraphSeries.js +11 -4
  32. package/lib/chart/graph/GraphView.js +28 -8
  33. package/lib/chart/graph/forceHelper.js +8 -2
  34. package/lib/chart/graph/forceLayout.js +5 -2
  35. package/lib/chart/heatmap/HeatmapView.js +4 -4
  36. package/lib/chart/helper/Symbol.js +8 -0
  37. package/lib/chart/helper/createListFromArray.js +14 -8
  38. package/lib/chart/helper/whiskerBoxCommon.js +22 -16
  39. package/lib/chart/line/LineSeries.js +3 -1
  40. package/lib/chart/line/LineView.js +8 -2
  41. package/lib/chart/map/MapSeries.js +8 -1
  42. package/lib/chart/pie/PieSeries.js +27 -6
  43. package/lib/chart/pie/PieView.js +1 -1
  44. package/lib/chart/pie/labelLayout.js +102 -19
  45. package/lib/chart/pie/pieLayout.js +19 -7
  46. package/lib/chart/radar/RadarSeries.js +3 -3
  47. package/lib/chart/sankey/SankeyView.js +28 -9
  48. package/lib/chart/scatter/ScatterSeries.js +3 -1
  49. package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
  50. package/lib/chart/tree/TreeSeries.js +15 -1
  51. package/lib/chart/tree/TreeView.js +4 -2
  52. package/lib/component/axis/AngleAxisView.js +97 -20
  53. package/lib/component/axis/AxisBuilder.js +63 -24
  54. package/lib/component/axis/CartesianAxisView.js +55 -11
  55. package/lib/component/axis/RadiusAxisView.js +36 -4
  56. package/lib/component/brush/BrushView.js +6 -0
  57. package/lib/component/brush/brushAction.js +5 -0
  58. package/lib/component/dataZoom/DataZoomModel.js +15 -1
  59. package/lib/component/dataZoom/SliderZoomView.js +4 -10
  60. package/lib/component/helper/BrushController.js +43 -25
  61. package/lib/component/legend/LegendModel.js +3 -3
  62. package/lib/component/legend/LegendView.js +17 -13
  63. package/lib/component/toolbox/ToolboxView.js +16 -7
  64. package/lib/component/toolbox/feature/MagicType.js +19 -14
  65. package/lib/coord/Axis.js +44 -12
  66. package/lib/coord/axisDefault.js +21 -2
  67. package/lib/coord/axisTickLabelBuilder.js +9 -1
  68. package/lib/coord/cartesian/Cartesian2D.js +0 -15
  69. package/lib/coord/geo/geoJSONLoader.js +1 -1
  70. package/lib/coord/polar/polarCreator.js +11 -2
  71. package/lib/coord/radar/Radar.js +3 -1
  72. package/lib/coord/radar/RadarModel.js +4 -1
  73. package/lib/data/DataDiffer.js +2 -4
  74. package/lib/data/DataDimensionInfo.js +157 -0
  75. package/lib/data/List.js +29 -23
  76. package/lib/data/Tree.js +2 -1
  77. package/lib/data/helper/completeDimensions.js +43 -32
  78. package/lib/data/helper/createDimensions.js +2 -0
  79. package/lib/data/helper/sourceHelper.js +214 -114
  80. package/lib/echarts.js +2 -2
  81. package/lib/layout/barGrid.js +136 -11
  82. package/lib/layout/barPolar.js +2 -2
  83. package/lib/model/Global.js +1 -1
  84. package/lib/model/Series.js +3 -3
  85. package/lib/model/referHelper.js +40 -12
  86. package/lib/scale/Interval.js +87 -2
  87. package/lib/scale/Log.js +9 -2
  88. package/lib/scale/helper.js +1 -43
  89. package/lib/theme/dark.js +3 -0
  90. package/lib/util/graphic.js +1 -2
  91. package/lib/util/number.js +25 -1
  92. package/lib/util/shape/sausage.js +93 -0
  93. package/lib/visual/LegendVisualProvider.js +75 -0
  94. package/lib/visual/dataColor.js +2 -12
  95. package/lib/visual/seriesColor.js +15 -7
  96. package/map/js/china.js +2 -2
  97. package/map/json/china.json +1 -1
  98. package/map/json/province/tianjin.json +1 -1
  99. package/package.json +3 -2
  100. package/src/chart/bar/BarSeries.js +5 -1
  101. package/src/chart/bar/BarView.js +24 -8
  102. package/src/chart/bar/BaseBarSeries.js +5 -1
  103. package/src/chart/candlestick/CandlestickSeries.js +2 -0
  104. package/src/chart/candlestick/CandlestickView.js +44 -1
  105. package/src/chart/custom.js +1 -0
  106. package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
  107. package/src/chart/funnel/FunnelSeries.js +11 -4
  108. package/src/chart/gauge/GaugeSeries.js +0 -6
  109. package/src/chart/graph/GraphSeries.js +10 -3
  110. package/src/chart/graph/GraphView.js +26 -8
  111. package/src/chart/graph/forceHelper.js +7 -3
  112. package/src/chart/graph/forceLayout.js +6 -3
  113. package/src/chart/heatmap/HeatmapView.js +4 -4
  114. package/src/chart/helper/Symbol.js +9 -0
  115. package/src/chart/helper/createClipPathFromCoordSys.js +5 -1
  116. package/src/chart/helper/createGraphFromNodeEdge.js +1 -1
  117. package/src/chart/helper/createListFromArray.js +13 -8
  118. package/src/chart/helper/whiskerBoxCommon.js +21 -16
  119. package/src/chart/line/LineSeries.js +1 -1
  120. package/src/chart/line/LineView.js +6 -1
  121. package/src/chart/map/MapSeries.js +5 -1
  122. package/src/chart/pie/PieSeries.js +26 -5
  123. package/src/chart/pie/PieView.js +1 -1
  124. package/src/chart/pie/labelLayout.js +114 -22
  125. package/src/chart/pie/pieLayout.js +20 -7
  126. package/src/chart/radar/RadarSeries.js +5 -3
  127. package/src/chart/sankey/SankeyView.js +26 -9
  128. package/src/chart/scatter/ScatterSeries.js +1 -1
  129. package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
  130. package/src/chart/tree/TreeSeries.js +12 -1
  131. package/src/chart/tree/TreeView.js +5 -2
  132. package/src/component/axis/AngleAxisView.js +106 -19
  133. package/src/component/axis/AxisBuilder.js +78 -33
  134. package/src/component/axis/CartesianAxisView.js +58 -11
  135. package/src/component/axis/RadiusAxisView.js +37 -4
  136. package/src/component/brush/BrushView.js +6 -0
  137. package/src/component/brush/brushAction.js +6 -1
  138. package/src/component/dataZoom/DataZoomModel.js +15 -1
  139. package/src/component/dataZoom/SliderZoomView.js +4 -9
  140. package/src/component/helper/BrushController.js +50 -28
  141. package/src/component/legend/LegendModel.js +3 -3
  142. package/src/component/legend/LegendView.js +18 -12
  143. package/src/component/toolbox/ToolboxView.js +18 -5
  144. package/src/component/toolbox/feature/MagicType.js +18 -13
  145. package/src/coord/Axis.js +48 -13
  146. package/src/coord/axisDefault.js +25 -1
  147. package/src/coord/axisTickLabelBuilder.js +10 -0
  148. package/src/coord/cartesian/Cartesian2D.js +0 -13
  149. package/src/coord/geo/geoJSONLoader.js +2 -2
  150. package/src/coord/polar/polarCreator.js +16 -3
  151. package/src/coord/radar/Radar.js +3 -1
  152. package/src/coord/radar/RadarModel.js +5 -2
  153. package/src/data/DataDiffer.js +1 -4
  154. package/src/data/DataDimensionInfo.js +135 -0
  155. package/src/data/Graph.js +1 -1
  156. package/src/data/List.js +33 -20
  157. package/src/data/Tree.js +3 -1
  158. package/src/data/helper/completeDimensions.js +49 -30
  159. package/src/data/helper/createDimensions.js +2 -0
  160. package/src/data/helper/sourceHelper.js +216 -124
  161. package/src/echarts.js +2 -2
  162. package/src/layout/barGrid.js +136 -13
  163. package/src/layout/barPolar.js +3 -2
  164. package/src/model/Global.js +1 -1
  165. package/src/model/Series.js +3 -3
  166. package/src/model/referHelper.js +34 -11
  167. package/src/scale/Interval.js +84 -4
  168. package/src/scale/Log.js +9 -2
  169. package/src/scale/helper.js +1 -39
  170. package/src/theme/dark.js +3 -0
  171. package/src/util/graphic.js +1 -2
  172. package/src/util/number.js +22 -2
  173. package/src/util/shape/sausage.js +93 -0
  174. package/src/visual/LegendVisualProvider.js +55 -0
  175. package/src/visual/dataColor.js +0 -13
  176. package/src/visual/seriesColor.js +13 -7
  177. package/theme/azul.js +163 -0
  178. package/theme/bee-inspired.js +178 -0
  179. package/theme/blue.js +178 -0
  180. package/theme/caravan.js +178 -0
  181. package/theme/carp.js +163 -0
  182. package/theme/cool.js +180 -0
  183. package/theme/dark-blue.js +168 -0
  184. package/theme/dark-bold.js +168 -0
  185. package/theme/dark-digerati.js +168 -0
  186. package/theme/dark-fresh-cut.js +168 -0
  187. package/theme/dark-mushroom.js +168 -0
  188. package/theme/dark.js +69 -62
  189. package/theme/eduardo.js +178 -0
  190. package/theme/forest.js +163 -0
  191. package/theme/fresh-cut.js +163 -0
  192. package/theme/fruit.js +178 -0
  193. package/theme/gray.js +220 -0
  194. package/theme/green.js +222 -0
  195. package/theme/helianthus.js +263 -0
  196. package/theme/infographic.js +72 -57
  197. package/theme/inspired.js +163 -0
  198. package/theme/jazz.js +163 -0
  199. package/theme/london.js +163 -0
  200. package/theme/macarons.js +80 -57
  201. package/theme/macarons2.js +251 -0
  202. package/theme/mint.js +155 -0
  203. package/theme/red-velvet.js +163 -0
  204. package/theme/red.js +225 -0
  205. package/theme/roma.js +55 -22
  206. package/theme/royal.js +163 -0
  207. package/theme/sakura.js +140 -0
  208. package/theme/shine.js +52 -45
  209. package/theme/tech-blue.js +180 -0
  210. package/theme/vintage.js +37 -23
  211. package/.travis.yml +0 -16
@@ -63,6 +63,11 @@ export default echarts.extendComponentView({
63
63
  var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
64
64
  var feature;
65
65
 
66
+ // FIX#11236, merge feature title from MagicType newOption. TODO: consider seriesIndex ?
67
+ if (payload && payload.newTitle != null) {
68
+ featureOpt.title = payload.newTitle;
69
+ }
70
+
66
71
  if (featureName && !oldName) { // Create
67
72
  if (isUserFeatureName(featureName)) {
68
73
  feature = {
@@ -157,6 +162,15 @@ export default echarts.extendComponentView({
157
162
  path.setStyle(iconStyleModel.getItemStyle());
158
163
  path.hoverStyle = iconStyleEmphasisModel.getItemStyle();
159
164
 
165
+ // Text position calculation
166
+ path.setStyle({
167
+ text: titles[iconName],
168
+ textAlign: iconStyleEmphasisModel.get('textAlign'),
169
+ textBorderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
170
+ textPadding: iconStyleEmphasisModel.get('textPadding'),
171
+ textFill: null
172
+ });
173
+
160
174
  var tooltipModel = toolboxModel.getModel('tooltip');
161
175
  if (tooltipModel && tooltipModel.get('show')) {
162
176
  path.attr('tooltip', zrUtil.extend({
@@ -182,15 +196,14 @@ export default echarts.extendComponentView({
182
196
  path.on('mouseover', function () {
183
197
  // Should not reuse above hoverStyle, which might be modified.
184
198
  var hoverStyle = iconStyleEmphasisModel.getItemStyle();
199
+ var defaultTextPosition = toolboxModel.get('orient') === 'vertical'
200
+ ? (toolboxModel.get('right') == null ? 'right' : 'left')
201
+ : (toolboxModel.get('bottom') == null ? 'bottom' : 'top');
185
202
  path.setStyle({
186
- text: titles[iconName],
187
- textPosition: iconStyleEmphasisModel.get('textPosition') || 'bottom',
188
203
  textFill: iconStyleEmphasisModel.get('textFill')
189
204
  || hoverStyle.fill || hoverStyle.stroke || '#000',
190
- textAlign: iconStyleEmphasisModel.get('textAlign') || 'center',
191
205
  textBackgroundColor: iconStyleEmphasisModel.get('textBackgroundColor'),
192
- textBorderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
193
- textPadding: iconStyleEmphasisModel.get('textPadding')
206
+ textPosition: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
194
207
  });
195
208
  })
196
209
  .on('mouseout', function () {
@@ -23,6 +23,7 @@ import lang from '../../../lang';
23
23
  import * as featureManager from '../featureManager';
24
24
 
25
25
  var magicTypeLang = lang.toolbox.magicType;
26
+ var INNER_STACK_KEYWORD = '__ec_magicType_stack__';
26
27
 
27
28
  function MagicType(model) {
28
29
  this.model = model;
@@ -36,8 +37,7 @@ MagicType.defaultOption = {
36
37
  /* eslint-disable */
37
38
  line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
38
39
  bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
39
- stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line
40
- tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
40
+ stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z' // jshint ignore:line
41
41
  /* eslint-enable */
42
42
  },
43
43
  // `line`, `bar`, `stack`, `tiled`
@@ -88,26 +88,20 @@ var seriesOptGenreator = {
88
88
  }
89
89
  },
90
90
  'stack': function (seriesType, seriesId, seriesModel, model) {
91
+ var isStack = seriesModel.get('stack') === INNER_STACK_KEYWORD;
91
92
  if (seriesType === 'line' || seriesType === 'bar') {
93
+ model.setIconStatus('stack', isStack ? 'normal' : 'emphasis');
92
94
  return zrUtil.merge({
93
95
  id: seriesId,
94
- stack: '__ec_magicType_stack__'
96
+ stack: isStack ? '' : INNER_STACK_KEYWORD
95
97
  }, model.get('option.stack') || {}, true);
96
98
  }
97
- },
98
- 'tiled': function (seriesType, seriesId, seriesModel, model) {
99
- if (seriesType === 'line' || seriesType === 'bar') {
100
- return zrUtil.merge({
101
- id: seriesId,
102
- stack: ''
103
- }, model.get('option.tiled') || {}, true);
104
- }
105
99
  }
106
100
  };
107
101
 
108
102
  var radioTypes = [
109
103
  ['line', 'bar'],
110
- ['stack', 'tiled']
104
+ ['stack']
111
105
  ];
112
106
 
113
107
  proto.onclick = function (ecModel, api, type) {
@@ -172,10 +166,21 @@ proto.onclick = function (ecModel, api, type) {
172
166
  }
173
167
  }, generateNewSeriesTypes
174
168
  );
169
+
170
+ var newTitle;
171
+ // Change title of stack
172
+ if (type === 'stack') {
173
+ var isStack = newOption.series && newOption.series[0] && newOption.series[0].stack === INNER_STACK_KEYWORD;
174
+ newTitle = isStack
175
+ ? zrUtil.merge({ stack: magicTypeLang.title.tiled }, magicTypeLang.title)
176
+ : zrUtil.clone(magicTypeLang.title);
177
+ }
178
+
175
179
  api.dispatchAction({
176
180
  type: 'changeMagicType',
177
181
  currentType: type,
178
- newOption: newOption
182
+ newOption: newOption,
183
+ newTitle: newTitle
179
184
  });
180
185
  };
181
186
 
package/src/coord/Axis.js CHANGED
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  import {each, map} from 'zrender/src/core/util';
21
- import {linearMap, getPixelPrecision} from '../util/number';
21
+ import {linearMap, getPixelPrecision, round} from '../util/number';
22
22
  import {
23
23
  createAxisTicks,
24
24
  createAxisLabels,
@@ -85,7 +85,7 @@ Axis.prototype = {
85
85
  * @return {boolean}
86
86
  */
87
87
  containData: function (data) {
88
- return this.contain(this.dataToCoord(data));
88
+ return this.scale.contain(data);
89
89
  },
90
90
 
91
91
  /**
@@ -173,7 +173,7 @@ Axis.prototype = {
173
173
  * `axis.getTicksCoords` considers `onBand`, which is used by
174
174
  * `boundaryGap:true` of category axis and splitLine and splitArea.
175
175
  * @param {Object} [opt]
176
- * @param {number} [opt.tickModel=axis.model.getModel('axisTick')]
176
+ * @param {Model} [opt.tickModel=axis.model.getModel('axisTick')]
177
177
  * @param {boolean} [opt.clamp] If `true`, the first and the last
178
178
  * tick must be at the axis end points. Otherwise, clip ticks
179
179
  * that outside the axis extent.
@@ -186,7 +186,6 @@ Axis.prototype = {
186
186
  opt = opt || {};
187
187
 
188
188
  var tickModel = opt.tickModel || this.getTickModel();
189
-
190
189
  var result = createAxisTicks(this, tickModel);
191
190
  var ticks = result.ticks;
192
191
 
@@ -198,13 +197,41 @@ Axis.prototype = {
198
197
  }, this);
199
198
 
200
199
  var alignWithLabel = tickModel.get('alignWithLabel');
200
+
201
201
  fixOnBandTicksCoords(
202
- this, ticksCoords, result.tickCategoryInterval, alignWithLabel, opt.clamp
202
+ this, ticksCoords, alignWithLabel, opt.clamp
203
203
  );
204
204
 
205
205
  return ticksCoords;
206
206
  },
207
207
 
208
+ /**
209
+ * @return {Array.<Array.<Object>>} [{ coord: ..., tickValue: ...}]
210
+ */
211
+ getMinorTicksCoords: function () {
212
+ if (this.scale.type === 'ordinal') {
213
+ // Category axis doesn't support minor ticks
214
+ return [];
215
+ }
216
+
217
+ var minorTickModel = this.model.getModel('minorTick');
218
+ var splitNumber = minorTickModel.get('splitNumber');
219
+ // Protection.
220
+ if (!(splitNumber > 0 && splitNumber < 100)) {
221
+ splitNumber = 5;
222
+ }
223
+ var minorTicks = this.scale.getMinorTicks(splitNumber);
224
+ var minorTicksCoords = map(minorTicks, function (minorTicksGroup) {
225
+ return map(minorTicksGroup, function (minorTick) {
226
+ return {
227
+ coord: this.dataToCoord(minorTick),
228
+ tickValue: minorTick
229
+ };
230
+ }, this);
231
+ }, this);
232
+ return minorTicksCoords;
233
+ },
234
+
208
235
  /**
209
236
  * @return {Array.<Object>} [{
210
237
  * formattedLabel: string,
@@ -292,7 +319,7 @@ function fixExtentWithBands(extent, nTick) {
292
319
  // splitLine/spliteArea should layout appropriately corresponding
293
320
  // to displayed labels. (So we should not use `getBandWidth` in this
294
321
  // case).
295
- function fixOnBandTicksCoords(axis, ticksCoords, tickCategoryInterval, alignWithLabel, clamp) {
322
+ function fixOnBandTicksCoords(axis, ticksCoords, alignWithLabel, clamp) {
296
323
  var ticksLen = ticksCoords.length;
297
324
 
298
325
  if (!axis.onBand || alignWithLabel || !ticksLen) {
@@ -301,26 +328,30 @@ function fixOnBandTicksCoords(axis, ticksCoords, tickCategoryInterval, alignWith
301
328
 
302
329
  var axisExtent = axis.getExtent();
303
330
  var last;
331
+ var diffSize;
304
332
  if (ticksLen === 1) {
305
333
  ticksCoords[0].coord = axisExtent[0];
306
334
  last = ticksCoords[1] = {coord: axisExtent[0]};
307
335
  }
308
336
  else {
309
- var shift = (ticksCoords[1].coord - ticksCoords[0].coord);
337
+ var crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
338
+ var shift = (ticksCoords[ticksLen - 1].coord - ticksCoords[0].coord) / crossLen;
339
+
310
340
  each(ticksCoords, function (ticksItem) {
311
341
  ticksItem.coord -= shift / 2;
312
- var tickCategoryInterval = tickCategoryInterval || 0;
313
- // Avoid split a single data item when odd interval.
314
- if (tickCategoryInterval % 2 > 0) {
315
- ticksItem.coord -= shift / ((tickCategoryInterval + 1) * 2);
316
- }
317
342
  });
318
- last = {coord: ticksCoords[ticksLen - 1].coord + shift};
343
+
344
+ var dataExtent = axis.scale.getExtent();
345
+ diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;
346
+
347
+ last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize};
348
+
319
349
  ticksCoords.push(last);
320
350
  }
321
351
 
322
352
  var inverse = axisExtent[0] > axisExtent[1];
323
353
 
354
+ // Handling clamp.
324
355
  if (littleThan(ticksCoords[0].coord, axisExtent[0])) {
325
356
  clamp ? (ticksCoords[0].coord = axisExtent[0]) : ticksCoords.shift();
326
357
  }
@@ -335,6 +366,10 @@ function fixOnBandTicksCoords(axis, ticksCoords, tickCategoryInterval, alignWith
335
366
  }
336
367
 
337
368
  function littleThan(a, b) {
369
+ // Avoid rounding error cause calculated tick coord different with extent.
370
+ // It may cause an extra unecessary tick added.
371
+ a = round(a);
372
+ b = round(b);
338
373
  return inverse ? a > b : a < b;
339
374
  }
340
375
  }
@@ -166,7 +166,7 @@ axisDefault.valueAxis = zrUtil.merge({
166
166
  // scale: false,
167
167
 
168
168
  // AxisTick and axisLabel and splitLine are caculated based on splitNumber.
169
- splitNumber: 5
169
+ splitNumber: 5,
170
170
 
171
171
  // Interval specifies the span of the ticks is mandatorily.
172
172
  // interval: null
@@ -177,6 +177,30 @@ axisDefault.valueAxis = zrUtil.merge({
177
177
  // Specify max interval when auto calculate tick interval.
178
178
  // maxInterval: null
179
179
 
180
+ minorTick: {
181
+ // Minor tick, not available for cateogry axis.
182
+ show: false,
183
+ // Split number of minor ticks. The value should be in range of (0, 100)
184
+ splitNumber: 5,
185
+ // Lenght of minor tick
186
+ length: 3,
187
+
188
+ // Same inside with axisTick
189
+
190
+ // Line style
191
+ lineStyle: {
192
+ // Default to be same with axisTick
193
+ }
194
+ },
195
+
196
+ minorSplitLine: {
197
+ show: false,
198
+
199
+ lineStyle: {
200
+ color: '#eee',
201
+ width: 1
202
+ }
203
+ }
180
204
  }, defaultOption);
181
205
 
182
206
  axisDefault.timeAxis = zrUtil.defaults({
@@ -243,12 +243,16 @@ export function calculateCategoryInterval(axis) {
243
243
  var interval = Math.max(0, Math.floor(Math.min(dw, dh)));
244
244
 
245
245
  var cache = inner(axis.model);
246
+ var axisExtent = axis.getExtent();
246
247
  var lastAutoInterval = cache.lastAutoInterval;
247
248
  var lastTickCount = cache.lastTickCount;
248
249
 
249
250
  // Use cache to keep interval stable while moving zoom window,
250
251
  // otherwise the calculated interval might jitter when the zoom
251
252
  // window size is close to the interval-changing size.
253
+ // For example, if all of the axis labels are `a, b, c, d, e, f, g`.
254
+ // The jitter will cause that sometimes the displayed labels are
255
+ // `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
252
256
  if (lastAutoInterval != null
253
257
  && lastTickCount != null
254
258
  && Math.abs(lastAutoInterval - interval) <= 1
@@ -256,6 +260,10 @@ export function calculateCategoryInterval(axis) {
256
260
  // Always choose the bigger one, otherwise the critical
257
261
  // point is not the same when zooming in or zooming out.
258
262
  && lastAutoInterval > interval
263
+ // If the axis change is caused by chart resize, the cache should not
264
+ // be used. Otherwise some hiden labels might not be shown again.
265
+ && cache.axisExtend0 === axisExtent[0]
266
+ && cache.axisExtend1 === axisExtent[1]
259
267
  ) {
260
268
  interval = lastAutoInterval;
261
269
  }
@@ -264,6 +272,8 @@ export function calculateCategoryInterval(axis) {
264
272
  else {
265
273
  cache.lastTickCount = tickCount;
266
274
  cache.lastAutoInterval = interval;
275
+ cache.axisExtend0 = axisExtent[0];
276
+ cache.axisExtend1 = axisExtent[1];
267
277
  }
268
278
 
269
279
  return interval;
@@ -22,19 +22,6 @@ import * as zrUtil from 'zrender/src/core/util';
22
22
  import BoundingRect from 'zrender/src/core/BoundingRect';
23
23
  import Cartesian from './Cartesian';
24
24
 
25
- // A helper function to calculate extent of axis.
26
- function getAxisExtentWithGap(axis) {
27
- var extent = axis.getGlobalExtent();
28
- if (axis.onBand) {
29
- // Remove extra 1px to avoid line miter in clipped edge
30
- var halfBandWidth = axis.getBandWidth() / 2 - 1;
31
- var dir = extent[1] > extent[0] ? 1 : -1;
32
- extent[0] += dir * halfBandWidth;
33
- extent[1] -= dir * halfBandWidth;
34
- }
35
- return extent;
36
- }
37
-
38
25
  function Cartesian2D(name) {
39
26
 
40
27
  Cartesian.call(this, name);
@@ -56,6 +56,8 @@ export default {
56
56
  throw new Error('Invalid geoJson format\n' + e.message);
57
57
  }
58
58
 
59
+ fixNanhai(mapName, regions);
60
+
59
61
  each(regions, function (region) {
60
62
  var regionName = region.name;
61
63
 
@@ -73,8 +75,6 @@ export default {
73
75
  }
74
76
  });
75
77
 
76
- fixNanhai(mapName, regions);
77
-
78
78
  return (inner(mapRecord).parsed = {
79
79
  regions: regions,
80
80
  boundingRect: getBoundingRect(regions)
@@ -47,10 +47,23 @@ function resizePolar(polar, polarModel, api) {
47
47
 
48
48
  var radiusAxis = polar.getRadiusAxis();
49
49
  var size = Math.min(width, height) / 2;
50
- var radius = parsePercent(polarModel.get('radius'), size);
50
+
51
+ var radius = polarModel.get('radius');
52
+ if (radius == null) {
53
+ radius = [0, '100%'];
54
+ }
55
+ else if (!zrUtil.isArray(radius)) {
56
+ // r0 = 0
57
+ radius = [0, radius];
58
+ }
59
+ radius = [
60
+ parsePercent(radius[0], size),
61
+ parsePercent(radius[1], size)
62
+ ];
63
+
51
64
  radiusAxis.inverse
52
- ? radiusAxis.setExtent(radius, 0)
53
- : radiusAxis.setExtent(0, radius);
65
+ ? radiusAxis.setExtent(radius[1], radius[0])
66
+ : radiusAxis.setExtent(radius[0], radius[1]);
54
67
  }
55
68
 
56
69
  /**
@@ -28,6 +28,7 @@ import {
28
28
  niceScaleExtent
29
29
  } from '../axisHelper';
30
30
  import CoordinateSystem from '../../CoordinateSystem';
31
+ import LogScale from '../../scale/Log';
31
32
 
32
33
  function Radar(radarModel, ecModel, api) {
33
34
 
@@ -40,7 +41,8 @@ function Radar(radarModel, ecModel, api) {
40
41
 
41
42
  this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
42
43
  var dim = 'indicator_' + idx;
43
- var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
44
+ var indicatorAxis = new IndicatorAxis(dim,
45
+ (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale());
44
46
  indicatorAxis.name = indicatorModel.get('name');
45
47
  // Inject model and axis
46
48
  indicatorAxis.model = indicatorModel;
@@ -41,6 +41,7 @@ var RadarModel = echarts.extendComponentModel({
41
41
  var scale = this.get('scale');
42
42
  var axisLine = this.get('axisLine');
43
43
  var axisTick = this.get('axisTick');
44
+ var axisType = this.get('axisType');
44
45
  var axisLabel = this.get('axisLabel');
45
46
  var nameTextStyle = this.get('name');
46
47
  var showName = this.get('name.show');
@@ -67,8 +68,9 @@ var RadarModel = echarts.extendComponentModel({
67
68
  scale: scale,
68
69
  axisLine: axisLine,
69
70
  axisTick: axisTick,
71
+ axisType: axisType,
70
72
  axisLabel: axisLabel,
71
- // Competitable with 2 and use text
73
+ // Compatible with 2 and use text
72
74
  name: indicatorOpt.text,
73
75
  nameLocation: 'end',
74
76
  nameGap: nameGap,
@@ -144,6 +146,7 @@ var RadarModel = echarts.extendComponentModel({
144
146
  ),
145
147
  axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
146
148
  axisTick: defaultsShow(valueAxisDefault.axisTick, false),
149
+ axisType: 'interval',
147
150
  splitLine: defaultsShow(valueAxisDefault.splitLine, true),
148
151
  splitArea: defaultsShow(valueAxisDefault.splitArea, true),
149
152
 
@@ -152,4 +155,4 @@ var RadarModel = echarts.extendComponentModel({
152
155
  }
153
156
  });
154
157
 
155
- export default RadarModel;
158
+ export default RadarModel;
@@ -80,9 +80,6 @@ DataDiffer.prototype = {
80
80
  initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter', this);
81
81
  initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter', this);
82
82
 
83
- // Travel by inverted order to make sure order consistency
84
- // when duplicate keys exists (consider newDataIndex.pop() below).
85
- // For performance consideration, these code below do not look neat.
86
83
  for (i = 0; i < oldArr.length; i++) {
87
84
  var key = oldDataKeyArr[i];
88
85
  var idx = newDataIndexMap[key];
@@ -94,7 +91,7 @@ DataDiffer.prototype = {
94
91
  var len = idx.length;
95
92
  if (len) {
96
93
  len === 1 && (newDataIndexMap[key] = null);
97
- idx = idx.unshift();
94
+ idx = idx.shift();
98
95
  }
99
96
  else {
100
97
  newDataIndexMap[key] = null;
@@ -0,0 +1,135 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ import * as zrUtil from 'zrender/src/core/util';
21
+
22
+ /**
23
+ * @class
24
+ * @param {Object|DataDimensionInfo} [opt] All of the fields will be shallow copied.
25
+ */
26
+ function DataDimensionInfo(opt) {
27
+ if (opt != null) {
28
+ zrUtil.extend(this, opt);
29
+ }
30
+
31
+ /**
32
+ * Dimension name.
33
+ * Mandatory.
34
+ * @type {string}
35
+ */
36
+ // this.name;
37
+
38
+ /**
39
+ * The origin name in dimsDef, see source helper.
40
+ * If displayName given, the tooltip will displayed vertically.
41
+ * Optional.
42
+ * @type {string}
43
+ */
44
+ // this.displayName;
45
+
46
+ /**
47
+ * Which coordSys dimension this dimension mapped to.
48
+ * A `coordDim` can be a "coordSysDim" that the coordSys required
49
+ * (for example, an item in `coordSysDims` of `model/referHelper#CoordSysInfo`),
50
+ * or an generated "extra coord name" if does not mapped to any "coordSysDim"
51
+ * (That is determined by whether `isExtraCoord` is `true`).
52
+ * Mandatory.
53
+ * @type {string}
54
+ */
55
+ // this.coordDim;
56
+
57
+ /**
58
+ * The index of this dimension in `series.encode[coordDim]`.
59
+ * Mandatory.
60
+ * @type {number}
61
+ */
62
+ // this.coordDimIndex;
63
+
64
+ /**
65
+ * Dimension type. The enumerable values are the key of
66
+ * `dataCtors` of `data/List`.
67
+ * Optional.
68
+ * @type {string}
69
+ */
70
+ // this.type;
71
+
72
+ /**
73
+ * This index of this dimension info in `data/List#_dimensionInfos`.
74
+ * Mandatory after added to `data/List`.
75
+ * @type {number}
76
+ */
77
+ // this.index;
78
+
79
+ /**
80
+ * The format of `otherDims` is:
81
+ * ```js
82
+ * {
83
+ * tooltip: number optional,
84
+ * label: number optional,
85
+ * itemName: number optional,
86
+ * seriesName: number optional,
87
+ * }
88
+ * ```
89
+ *
90
+ * A `series.encode` can specified these fields:
91
+ * ```js
92
+ * encode: {
93
+ * // "3, 1, 5" is the index of data dimension.
94
+ * tooltip: [3, 1, 5],
95
+ * label: [0, 3],
96
+ * ...
97
+ * }
98
+ * ```
99
+ * `otherDims` is the parse result of the `series.encode` above, like:
100
+ * ```js
101
+ * // Suppose the index of this data dimension is `3`.
102
+ * this.otherDims = {
103
+ * // `3` is at the index `0` of the `encode.tooltip`
104
+ * tooltip: 0,
105
+ * // `3` is at the index `1` of the `encode.tooltip`
106
+ * label: 1
107
+ * };
108
+ * ```
109
+ *
110
+ * This prop should never be `null`/`undefined` after initialized.
111
+ * @type {Object}
112
+ */
113
+ this.otherDims = {};
114
+
115
+ /**
116
+ * Be `true` if this dimension is not mapped to any "coordSysDim" that the
117
+ * "coordSys" required.
118
+ * Mandatory.
119
+ * @type {boolean}
120
+ */
121
+ // this.isExtraCoord;
122
+
123
+ /**
124
+ * @type {module:data/OrdinalMeta}
125
+ */
126
+ // this.ordinalMeta;
127
+
128
+ /**
129
+ * Whether to create inverted indices.
130
+ * @type {boolean}
131
+ */
132
+ // this.createInvertedIndices;
133
+ };
134
+
135
+ export default DataDimensionInfo;
package/src/data/Graph.js CHANGED
@@ -533,4 +533,4 @@ Graph.Edge = Edge;
533
533
  enableClassCheck(Node);
534
534
  enableClassCheck(Edge);
535
535
 
536
- export default Graph;
536
+ export default Graph;