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
@@ -67,6 +67,7 @@ function getAxisKey(axis) {
67
67
  * @param {number} opt.count Positive interger.
68
68
  * @param {number} [opt.barWidth]
69
69
  * @param {number} [opt.barMaxWidth]
70
+ * @param {number} [opt.barMinWidth]
70
71
  * @param {number} [opt.barGap]
71
72
  * @param {number} [opt.barCategoryGap]
72
73
  * @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
@@ -114,23 +115,116 @@ function prepareLayoutBarSeries(seriesType, ecModel) {
114
115
  });
115
116
  return seriesModels;
116
117
  }
118
+ /**
119
+ * Map from (baseAxis.dim + '_' + baseAxis.index) to min gap of two adjacent
120
+ * values.
121
+ * This works for time axes, value axes, and log axes.
122
+ * For a single time axis, return value is in the form like
123
+ * {'x_0': [1000000]}.
124
+ * The value of 1000000 is in milliseconds.
125
+ */
126
+
127
+
128
+ function getValueAxesMinGaps(barSeries) {
129
+ /**
130
+ * Map from axis.index to values.
131
+ * For a single time axis, axisValues is in the form like
132
+ * {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
133
+ * Items in axisValues[x], e.g. 1495555200000, are time values of all
134
+ * series.
135
+ */
136
+ var axisValues = {};
137
+ zrUtil.each(barSeries, function (seriesModel) {
138
+ var cartesian = seriesModel.coordinateSystem;
139
+ var baseAxis = cartesian.getBaseAxis();
140
+
141
+ if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
142
+ return;
143
+ }
144
+
145
+ var data = seriesModel.getData();
146
+ var key = baseAxis.dim + '_' + baseAxis.index;
147
+ var dim = data.mapDimension(baseAxis.dim);
148
+
149
+ for (var i = 0, cnt = data.count(); i < cnt; ++i) {
150
+ var value = data.get(dim, i);
151
+
152
+ if (!axisValues[key]) {
153
+ // No previous data for the axis
154
+ axisValues[key] = [value];
155
+ } else {
156
+ // No value in previous series
157
+ axisValues[key].push(value);
158
+ } // Ignore duplicated time values in the same axis
159
+
160
+ }
161
+ });
162
+ var axisMinGaps = [];
163
+
164
+ for (var key in axisValues) {
165
+ if (axisValues.hasOwnProperty(key)) {
166
+ var valuesInAxis = axisValues[key];
167
+
168
+ if (valuesInAxis) {
169
+ // Sort axis values into ascending order to calculate gaps
170
+ valuesInAxis.sort(function (a, b) {
171
+ return a - b;
172
+ });
173
+ var min = null;
174
+
175
+ for (var j = 1; j < valuesInAxis.length; ++j) {
176
+ var delta = valuesInAxis[j] - valuesInAxis[j - 1];
177
+
178
+ if (delta > 0) {
179
+ // Ignore 0 delta because they are of the same axis value
180
+ min = min === null ? delta : Math.min(min, delta);
181
+ }
182
+ } // Set to null if only have one data
183
+
184
+
185
+ axisMinGaps[key] = min;
186
+ }
187
+ }
188
+ }
189
+
190
+ return axisMinGaps;
191
+ }
117
192
 
118
193
  function makeColumnLayout(barSeries) {
194
+ var axisMinGaps = getValueAxesMinGaps(barSeries);
119
195
  var seriesInfoList = [];
120
196
  zrUtil.each(barSeries, function (seriesModel) {
121
- var data = seriesModel.getData();
122
197
  var cartesian = seriesModel.coordinateSystem;
123
198
  var baseAxis = cartesian.getBaseAxis();
124
199
  var axisExtent = baseAxis.getExtent();
125
- var bandWidth = baseAxis.type === 'category' ? baseAxis.getBandWidth() : Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
200
+ var bandWidth;
201
+
202
+ if (baseAxis.type === 'category') {
203
+ bandWidth = baseAxis.getBandWidth();
204
+ } else if (baseAxis.type === 'value' || baseAxis.type === 'time') {
205
+ var key = baseAxis.dim + '_' + baseAxis.index;
206
+ var minGap = axisMinGaps[key];
207
+ var extentSpan = Math.abs(axisExtent[1] - axisExtent[0]);
208
+ var scale = baseAxis.scale.getExtent();
209
+ var scaleSpan = Math.abs(scale[1] - scale[0]);
210
+ bandWidth = minGap ? extentSpan / scaleSpan * minGap : extentSpan; // When there is only one data value
211
+ } else {
212
+ var data = seriesModel.getData();
213
+ bandWidth = Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
214
+ }
215
+
126
216
  var barWidth = parsePercent(seriesModel.get('barWidth'), bandWidth);
127
217
  var barMaxWidth = parsePercent(seriesModel.get('barMaxWidth'), bandWidth);
218
+ var barMinWidth = parsePercent( // barMinWidth by default is 1 in cartesian. Because in value axis,
219
+ // the auto-calculated bar width might be less than 1.
220
+ seriesModel.get('barMinWidth') || 1, bandWidth);
128
221
  var barGap = seriesModel.get('barGap');
129
222
  var barCategoryGap = seriesModel.get('barCategoryGap');
130
223
  seriesInfoList.push({
131
224
  bandWidth: bandWidth,
132
225
  barWidth: barWidth,
133
226
  barMaxWidth: barMaxWidth,
227
+ barMinWidth: barMinWidth,
134
228
  barGap: barGap,
135
229
  barCategoryGap: barCategoryGap,
136
230
  axisKey: getAxisKey(baseAxis),
@@ -169,7 +263,6 @@ function doCalBarWidthAndOffset(seriesInfoList) {
169
263
  // will be shared by series. Consider that they have default values,
170
264
  // only the attributes set on the last series will work.
171
265
  // Do not change this fact unless there will be a break change.
172
- // TODO
173
266
 
174
267
  var barWidth = seriesInfo.barWidth;
175
268
 
@@ -182,6 +275,8 @@ function doCalBarWidthAndOffset(seriesInfoList) {
182
275
 
183
276
  var barMaxWidth = seriesInfo.barMaxWidth;
184
277
  barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
278
+ var barMinWidth = seriesInfo.barMinWidth;
279
+ barMinWidth && (stacks[stackId].minWidth = barMinWidth);
185
280
  var barGap = seriesInfo.barGap;
186
281
  barGap != null && (columnsOnAxis.gap = barGap);
187
282
  var barCategoryGap = seriesInfo.barCategoryGap;
@@ -199,18 +294,48 @@ function doCalBarWidthAndOffset(seriesInfoList) {
199
294
  var autoWidth = (remainedWidth - categoryGap) / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
200
295
  autoWidth = Math.max(autoWidth, 0); // Find if any auto calculated bar exceeded maxBarWidth
201
296
 
202
- zrUtil.each(stacks, function (column, stack) {
297
+ zrUtil.each(stacks, function (column) {
203
298
  var maxWidth = column.maxWidth;
299
+ var minWidth = column.minWidth;
300
+
301
+ if (!column.width) {
302
+ var finalWidth = autoWidth;
303
+
304
+ if (maxWidth && maxWidth < finalWidth) {
305
+ finalWidth = Math.min(maxWidth, remainedWidth);
306
+ } // `minWidth` has higher priority. `minWidth` decide that wheter the
307
+ // bar is able to be visible. So `minWidth` should not be restricted
308
+ // by `maxWidth` or `remainedWidth` (which is from `bandWidth`). In
309
+ // the extreme cases for `value` axis, bars are allowed to overlap
310
+ // with each other if `minWidth` specified.
311
+
312
+
313
+ if (minWidth && minWidth > finalWidth) {
314
+ finalWidth = minWidth;
315
+ }
316
+
317
+ if (finalWidth !== autoWidth) {
318
+ column.width = finalWidth;
319
+ remainedWidth -= finalWidth + barGapPercent * finalWidth;
320
+ autoWidthCount--;
321
+ }
322
+ } else {
323
+ // `barMinWidth/barMaxWidth` has higher priority than `barWidth`, as
324
+ // CSS does. Becuase barWidth can be a percent value, where
325
+ // `barMaxWidth` can be used to restrict the final width.
326
+ var finalWidth = column.width;
327
+
328
+ if (maxWidth) {
329
+ finalWidth = Math.min(finalWidth, maxWidth);
330
+ } // `minWidth` has higher priority, as described above
204
331
 
205
- if (maxWidth && maxWidth < autoWidth) {
206
- maxWidth = Math.min(maxWidth, remainedWidth);
207
332
 
208
- if (column.width) {
209
- maxWidth = Math.min(maxWidth, column.width);
333
+ if (minWidth) {
334
+ finalWidth = Math.max(finalWidth, minWidth);
210
335
  }
211
336
 
212
- remainedWidth -= maxWidth;
213
- column.width = maxWidth;
337
+ column.width = finalWidth;
338
+ remainedWidth -= finalWidth + barGapPercent * finalWidth;
214
339
  autoWidthCount--;
215
340
  }
216
341
  }); // Recalculate width again
@@ -438,7 +563,7 @@ function isInLargeMode(seriesModel) {
438
563
 
439
564
 
440
565
  function getValueAxisStart(baseAxis, valueAxis, stacked) {
441
- return valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
566
+ return valueAxis.toGlobalCoord(valueAxis.dataToCoord(valueAxis.type === 'log' ? 1 : 0));
442
567
  }
443
568
 
444
569
  exports.getLayoutOnAxis = getLayoutOnAxis;
@@ -90,6 +90,7 @@ function barLayoutPolar(seriesType, ecModel, api) {
90
90
  var stacked = isDimensionStacked(data, valueDim
91
91
  /*, baseDim*/
92
92
  );
93
+ var clampLayout = baseAxis.dim !== 'radius' || !seriesModel.get('roundCap', true);
93
94
  var valueAxisStart = valueAxis.getExtent()[0];
94
95
 
95
96
  for (var idx = 0, len = data.count(); idx < len; idx++) {
@@ -139,8 +140,7 @@ function barLayoutPolar(seriesType, ecModel, api) {
139
140
  stacked && (lastStackCoords[stackId][baseValue][sign] = r);
140
141
  } // tangential sector
141
142
  else {
142
- // angleAxis must be clamped.
143
- var angleSpan = valueAxis.dataToAngle(value, true) - valueAxisStart;
143
+ var angleSpan = valueAxis.dataToAngle(value, clampLayout) - valueAxisStart;
144
144
  var radius = baseAxis.dataToRadius(baseValue);
145
145
 
146
146
  if (Math.abs(angleSpan) < barMinAngle) {
@@ -222,7 +222,7 @@ var GlobalModel = Model.extend({
222
222
  } else {
223
223
  var ComponentModelClass = ComponentModel.getClass(mainType, resultItem.keyInfo.subType, true);
224
224
 
225
- if (componentModel && componentModel instanceof ComponentModelClass) {
225
+ if (componentModel && componentModel.constructor === ComponentModelClass) {
226
226
  componentModel.name = resultItem.keyInfo.name; // componentModel.settingTask && componentModel.settingTask.dirty();
227
227
 
228
228
  componentModel.mergeOption(newCptOption, this);
@@ -95,11 +95,11 @@ var SeriesModel = ComponentModel.extend({
95
95
  defaultOption: null,
96
96
 
97
97
  /**
98
- * Data provided for legend
99
- * @type {Function}
98
+ * legend visual provider to the legend component
99
+ * @type {Object}
100
100
  */
101
101
  // PENDING
102
- legendDataProvider: null,
102
+ legendVisualProvider: null,
103
103
 
104
104
  /**
105
105
  * Access path of color for visual
@@ -56,7 +56,8 @@ var each = _util.each;
56
56
  // check: "modelHelper" of tooltip and "BrushTargetManager".
57
57
 
58
58
  /**
59
- * @return {Object} For example:
59
+ * @class
60
+ * For example:
60
61
  * {
61
62
  * coordSysName: 'cartesian2d',
62
63
  * coordSysDims: ['x', 'y', ...],
@@ -68,19 +69,46 @@ var each = _util.each;
68
69
  * x: xAxisModel,
69
70
  * y: undefined
70
71
  * }),
71
- * // It also indicate that whether there is category axis.
72
+ * // The index of the first category axis in `coordSysDims`.
73
+ * // `null/undefined` means no category axis exists.
72
74
  * firstCategoryDimIndex: 1,
73
75
  * // To replace user specified encode.
74
76
  * }
75
77
  */
76
- function getCoordSysDefineBySeries(seriesModel) {
78
+ function CoordSysInfo(coordSysName) {
79
+ /**
80
+ * @type {string}
81
+ */
82
+ this.coordSysName = coordSysName;
83
+ /**
84
+ * @type {Array.<string>}
85
+ */
86
+
87
+ this.coordSysDims = [];
88
+ /**
89
+ * @type {module:zrender/core/util#HashMap}
90
+ */
91
+
92
+ this.axisMap = createHashMap();
93
+ /**
94
+ * @type {module:zrender/core/util#HashMap}
95
+ */
96
+
97
+ this.categoryAxisMap = createHashMap();
98
+ /**
99
+ * @type {number}
100
+ */
101
+
102
+ this.firstCategoryDimIndex = null;
103
+ }
104
+ /**
105
+ * @return {module:model/referHelper#CoordSysInfo}
106
+ */
107
+
108
+
109
+ function getCoordSysInfoBySeries(seriesModel) {
77
110
  var coordSysName = seriesModel.get('coordinateSystem');
78
- var result = {
79
- coordSysName: coordSysName,
80
- coordSysDims: [],
81
- axisMap: createHashMap(),
82
- categoryAxisMap: createHashMap()
83
- };
111
+ var result = new CoordSysInfo(coordSysName);
84
112
  var fetch = fetchers[coordSysName];
85
113
 
86
114
  if (fetch) {
@@ -104,7 +132,7 @@ var fetchers = {
104
132
 
105
133
  if (isCategory(yAxisModel)) {
106
134
  categoryAxisMap.set('y', yAxisModel);
107
- result.firstCategoryDimIndex = 1;
135
+ result.firstCategoryDimIndex == null & (result.firstCategoryDimIndex = 1);
108
136
  }
109
137
  },
110
138
  singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
@@ -132,7 +160,7 @@ var fetchers = {
132
160
 
133
161
  if (isCategory(angleAxisModel)) {
134
162
  categoryAxisMap.set('angle', angleAxisModel);
135
- result.firstCategoryDimIndex = 1;
163
+ result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
136
164
  }
137
165
  },
138
166
  geo: function (seriesModel, result, axisMap, categoryAxisMap) {
@@ -159,4 +187,4 @@ function isCategory(axisModel) {
159
187
  return axisModel.get('type') === 'category';
160
188
  }
161
189
 
162
- exports.getCoordSysDefineBySeries = getCoordSysDefineBySeries;
190
+ exports.getCoordSysInfoBySeries = getCoordSysInfoBySeries;
@@ -97,10 +97,95 @@ var IntervalScale = Scale.extend({
97
97
  },
98
98
 
99
99
  /**
100
+ * @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
100
101
  * @return {Array.<number>}
101
102
  */
102
- getTicks: function () {
103
- return helper.intervalScaleGetTicks(this._interval, this._extent, this._niceExtent, this._intervalPrecision);
103
+ getTicks: function (expandToNicedExtent) {
104
+ var interval = this._interval;
105
+ var extent = this._extent;
106
+ var niceTickExtent = this._niceExtent;
107
+ var intervalPrecision = this._intervalPrecision;
108
+ var ticks = []; // If interval is 0, return [];
109
+
110
+ if (!interval) {
111
+ return ticks;
112
+ } // Consider this case: using dataZoom toolbox, zoom and zoom.
113
+
114
+
115
+ var safeLimit = 10000;
116
+
117
+ if (extent[0] < niceTickExtent[0]) {
118
+ if (expandToNicedExtent) {
119
+ ticks.push(roundNumber(niceTickExtent[0] - interval));
120
+ } else {
121
+ ticks.push(extent[0]);
122
+ }
123
+ }
124
+
125
+ var tick = niceTickExtent[0];
126
+
127
+ while (tick <= niceTickExtent[1]) {
128
+ ticks.push(tick); // Avoid rounding error
129
+
130
+ tick = roundNumber(tick + interval, intervalPrecision);
131
+
132
+ if (tick === ticks[ticks.length - 1]) {
133
+ // Consider out of safe float point, e.g.,
134
+ // -3711126.9907707 + 2e-10 === -3711126.9907707
135
+ break;
136
+ }
137
+
138
+ if (ticks.length > safeLimit) {
139
+ return [];
140
+ }
141
+ } // Consider this case: the last item of ticks is smaller
142
+ // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
143
+
144
+
145
+ var lastNiceTick = ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1];
146
+
147
+ if (extent[1] > lastNiceTick) {
148
+ if (expandToNicedExtent) {
149
+ ticks.push(lastNiceTick + interval);
150
+ } else {
151
+ ticks.push(extent[1]);
152
+ }
153
+ }
154
+
155
+ return ticks;
156
+ },
157
+
158
+ /**
159
+ * @param {number} [splitNumber=5]
160
+ * @return {Array.<Array.<number>>}
161
+ */
162
+ getMinorTicks: function (splitNumber) {
163
+ var ticks = this.getTicks(true);
164
+ var minorTicks = [];
165
+ var extent = this.getExtent();
166
+
167
+ for (var i = 1; i < ticks.length; i++) {
168
+ var nextTick = ticks[i];
169
+ var prevTick = ticks[i - 1];
170
+ var count = 0;
171
+ var minorTicksGroup = [];
172
+ var interval = nextTick - prevTick;
173
+ var minorInterval = interval / splitNumber;
174
+
175
+ while (count < splitNumber - 1) {
176
+ var minorTick = numberUtil.round(prevTick + (count + 1) * minorInterval); // For the first and last interval. The count may be less than splitNumber.
177
+
178
+ if (minorTick > extent[0] && minorTick < extent[1]) {
179
+ minorTicksGroup.push(minorTick);
180
+ }
181
+
182
+ count++;
183
+ }
184
+
185
+ minorTicks.push(minorTicksGroup);
186
+ }
187
+
188
+ return minorTicks;
104
189
  },
105
190
 
106
191
  /**
package/lib/scale/Log.js CHANGED
@@ -67,13 +67,14 @@ var LogScale = Scale.extend({
67
67
  },
68
68
 
69
69
  /**
70
+ * @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
70
71
  * @return {Array.<number>}
71
72
  */
72
- getTicks: function () {
73
+ getTicks: function (expandToNicedExtent) {
73
74
  var originalScale = this._originalScale;
74
75
  var extent = this._extent;
75
76
  var originalExtent = originalScale.getExtent();
76
- return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
77
+ return zrUtil.map(intervalScaleProto.getTicks.call(this, expandToNicedExtent), function (val) {
77
78
  var powVal = numberUtil.round(mathPow(this.base, val)); // Fix #4158
78
79
 
79
80
  powVal = val === extent[0] && originalScale.__fixMin ? fixRoundingError(powVal, originalExtent[0]) : powVal;
@@ -82,6 +83,12 @@ var LogScale = Scale.extend({
82
83
  }, this);
83
84
  },
84
85
 
86
+ /**
87
+ * @param {number} splitNumber
88
+ * @return {Array.<Array.<number>>}
89
+ */
90
+ getMinorTicks: intervalScaleProto.getMinorTicks,
91
+
85
92
  /**
86
93
  * @param {number} val
87
94
  * @return {string}
@@ -99,48 +99,6 @@ function fixExtent(niceTickExtent, extent) {
99
99
  }
100
100
  }
101
101
 
102
- function intervalScaleGetTicks(interval, extent, niceTickExtent, intervalPrecision) {
103
- var ticks = []; // If interval is 0, return [];
104
-
105
- if (!interval) {
106
- return ticks;
107
- } // Consider this case: using dataZoom toolbox, zoom and zoom.
108
-
109
-
110
- var safeLimit = 10000;
111
-
112
- if (extent[0] < niceTickExtent[0]) {
113
- ticks.push(extent[0]);
114
- }
115
-
116
- var tick = niceTickExtent[0];
117
-
118
- while (tick <= niceTickExtent[1]) {
119
- ticks.push(tick); // Avoid rounding error
120
-
121
- tick = roundNumber(tick + interval, intervalPrecision);
122
-
123
- if (tick === ticks[ticks.length - 1]) {
124
- // Consider out of safe float point, e.g.,
125
- // -3711126.9907707 + 2e-10 === -3711126.9907707
126
- break;
127
- }
128
-
129
- if (ticks.length > safeLimit) {
130
- return [];
131
- }
132
- } // Consider this case: the last item of ticks is smaller
133
- // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
134
-
135
-
136
- if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
137
- ticks.push(extent[1]);
138
- }
139
-
140
- return ticks;
141
- }
142
-
143
102
  exports.intervalScaleNiceTicks = intervalScaleNiceTicks;
144
103
  exports.getIntervalPrecision = getIntervalPrecision;
145
- exports.fixExtent = fixExtent;
146
- exports.intervalScaleGetTicks = intervalScaleGetTicks;
104
+ exports.fixExtent = fixExtent;
package/lib/theme/dark.js CHANGED
@@ -80,6 +80,9 @@ var theme = {
80
80
  },
81
81
  crossStyle: {
82
82
  color: contrastColor
83
+ },
84
+ label: {
85
+ color: '#000'
83
86
  }
84
87
  }
85
88
  },
@@ -1125,8 +1125,7 @@ function rollbackDefaultTextStyle(style) {
1125
1125
  }
1126
1126
 
1127
1127
  function getFont(opt, ecModel) {
1128
- // ecModel or default text style model.
1129
- var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
1128
+ var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
1130
1129
  return zrUtil.trim([// FIXME in node-canvas fontWeight is before fontStyle
1131
1130
  opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '', opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '', (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px', opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'].join(' '));
1132
1131
  }
@@ -401,9 +401,32 @@ function parseDate(value) {
401
401
  function quantity(val) {
402
402
  return Math.pow(10, quantityExponent(val));
403
403
  }
404
+ /**
405
+ * Exponent of the quantity of a number
406
+ * e.g., 1234 equals to 1.234*10^3, so quantityExponent(1234) is 3
407
+ *
408
+ * @param {number} val non-negative value
409
+ * @return {number}
410
+ */
411
+
404
412
 
405
413
  function quantityExponent(val) {
406
- return Math.floor(Math.log(val) / Math.LN10);
414
+ if (val === 0) {
415
+ return 0;
416
+ }
417
+
418
+ var exp = Math.floor(Math.log(val) / Math.LN10);
419
+ /**
420
+ * exp is expected to be the rounded-down result of the base-10 log of val.
421
+ * But due to the precision loss with Math.log(val), we need to restore it
422
+ * using 10^exp to make sure we can get val back from exp. #11249
423
+ */
424
+
425
+ if (val / Math.pow(10, exp) >= 10) {
426
+ exp++;
427
+ }
428
+
429
+ return exp;
407
430
  }
408
431
  /**
409
432
  * find a “nice” number approximately equal to x. Round the number if round = true,
@@ -556,6 +579,7 @@ exports.remRadian = remRadian;
556
579
  exports.isRadianAroundZero = isRadianAroundZero;
557
580
  exports.parseDate = parseDate;
558
581
  exports.quantity = quantity;
582
+ exports.quantityExponent = quantityExponent;
559
583
  exports.nice = nice;
560
584
  exports.quantile = quantile;
561
585
  exports.reformIntervals = reformIntervals;
@@ -0,0 +1,93 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+ var _graphic = require("../graphic");
22
+
23
+ var extendShape = _graphic.extendShape;
24
+
25
+ /*
26
+ * Licensed to the Apache Software Foundation (ASF) under one
27
+ * or more contributor license agreements. See the NOTICE file
28
+ * distributed with this work for additional information
29
+ * regarding copyright ownership. The ASF licenses this file
30
+ * to you under the Apache License, Version 2.0 (the
31
+ * "License"); you may not use this file except in compliance
32
+ * with the License. You may obtain a copy of the License at
33
+ *
34
+ * http://www.apache.org/licenses/LICENSE-2.0
35
+ *
36
+ * Unless required by applicable law or agreed to in writing,
37
+ * software distributed under the License is distributed on an
38
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
39
+ * KIND, either express or implied. See the License for the
40
+ * specific language governing permissions and limitations
41
+ * under the License.
42
+ */
43
+
44
+ /**
45
+ * Sausage: similar to sector, but have half circle on both sides
46
+ * @public
47
+ */
48
+ var _default = extendShape({
49
+ type: 'sausage',
50
+ shape: {
51
+ cx: 0,
52
+ cy: 0,
53
+ r0: 0,
54
+ r: 0,
55
+ startAngle: 0,
56
+ endAngle: Math.PI * 2,
57
+ clockwise: true
58
+ },
59
+ buildPath: function (ctx, shape) {
60
+ var x = shape.cx;
61
+ var y = shape.cy;
62
+ var r0 = Math.max(shape.r0 || 0, 0);
63
+ var r = Math.max(shape.r, 0);
64
+ var dr = (r - r0) * 0.5;
65
+ var rCenter = r0 + dr;
66
+ var startAngle = shape.startAngle;
67
+ var endAngle = shape.endAngle;
68
+ var clockwise = shape.clockwise;
69
+ var unitStartX = Math.cos(startAngle);
70
+ var unitStartY = Math.sin(startAngle);
71
+ var unitEndX = Math.cos(endAngle);
72
+ var unitEndY = Math.sin(endAngle);
73
+ var lessThanCircle = clockwise ? endAngle - startAngle < Math.PI * 2 : startAngle - endAngle < Math.PI * 2;
74
+
75
+ if (lessThanCircle) {
76
+ ctx.moveTo(unitStartX * r0 + x, unitStartY * r0 + y);
77
+ ctx.arc(unitStartX * rCenter + x, unitStartY * rCenter + y, dr, -Math.PI + startAngle, startAngle, !clockwise);
78
+ }
79
+
80
+ ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
81
+ ctx.moveTo(unitEndX * r + x, unitEndY * r + y);
82
+ ctx.arc(unitEndX * rCenter + x, unitEndY * rCenter + y, dr, endAngle - Math.PI * 2, endAngle - Math.PI, !clockwise);
83
+
84
+ if (r0 !== 0) {
85
+ ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
86
+ ctx.moveTo(unitStartX * r0 + x, unitEndY * r0 + y);
87
+ }
88
+
89
+ ctx.closePath();
90
+ }
91
+ });
92
+
93
+ module.exports = _default;