echarts 4.5.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 (154) hide show
  1. package/dist/echarts-en.common.js +1790 -774
  2. package/dist/echarts-en.common.min.js +1 -1
  3. package/dist/echarts-en.js +2029 -849
  4. package/dist/echarts-en.js.map +1 -1
  5. package/dist/echarts-en.min.js +1 -1
  6. package/dist/echarts-en.simple.js +1676 -691
  7. package/dist/echarts-en.simple.min.js +1 -1
  8. package/dist/echarts.common.js +1790 -774
  9. package/dist/echarts.common.min.js +1 -1
  10. package/dist/echarts.js +2029 -849
  11. package/dist/echarts.js.map +1 -1
  12. package/dist/echarts.min.js +1 -1
  13. package/dist/echarts.simple.js +1676 -691
  14. package/dist/echarts.simple.min.js +1 -1
  15. package/lib/chart/bar/BarView.js +11 -1
  16. package/lib/chart/bar/BaseBarSeries.js +3 -1
  17. package/lib/chart/effectScatter/EffectScatterSeries.js +3 -1
  18. package/lib/chart/funnel/FunnelSeries.js +15 -5
  19. package/lib/chart/gauge/GaugeSeries.js +0 -2
  20. package/lib/chart/graph/GraphSeries.js +9 -4
  21. package/lib/chart/graph/GraphView.js +28 -8
  22. package/lib/chart/heatmap/HeatmapView.js +4 -4
  23. package/lib/chart/helper/createListFromArray.js +14 -8
  24. package/lib/chart/helper/whiskerBoxCommon.js +22 -16
  25. package/lib/chart/line/LineSeries.js +3 -1
  26. package/lib/chart/line/LineView.js +8 -2
  27. package/lib/chart/map/MapSeries.js +8 -1
  28. package/lib/chart/pie/PieSeries.js +27 -6
  29. package/lib/chart/pie/PieView.js +1 -1
  30. package/lib/chart/pie/labelLayout.js +102 -19
  31. package/lib/chart/pie/pieLayout.js +19 -7
  32. package/lib/chart/radar/RadarSeries.js +3 -3
  33. package/lib/chart/sankey/SankeyView.js +28 -9
  34. package/lib/chart/scatter/ScatterSeries.js +3 -1
  35. package/lib/chart/themeRiver/ThemeRiverSeries.js +3 -3
  36. package/lib/chart/tree/TreeSeries.js +15 -1
  37. package/lib/component/axis/AngleAxisView.js +64 -7
  38. package/lib/component/axis/AxisBuilder.js +63 -24
  39. package/lib/component/axis/CartesianAxisView.js +55 -11
  40. package/lib/component/axis/RadiusAxisView.js +36 -4
  41. package/lib/component/dataZoom/SliderZoomView.js +4 -10
  42. package/lib/component/helper/BrushController.js +33 -43
  43. package/lib/component/legend/LegendModel.js +3 -3
  44. package/lib/component/legend/LegendView.js +17 -13
  45. package/lib/component/toolbox/ToolboxView.js +5 -1
  46. package/lib/component/toolbox/feature/MagicType.js +19 -14
  47. package/lib/coord/Axis.js +30 -2
  48. package/lib/coord/axisDefault.js +21 -2
  49. package/lib/data/DataDimensionInfo.js +157 -0
  50. package/lib/data/List.js +25 -19
  51. package/lib/data/Tree.js +2 -1
  52. package/lib/data/helper/completeDimensions.js +43 -32
  53. package/lib/data/helper/createDimensions.js +2 -0
  54. package/lib/data/helper/sourceHelper.js +214 -114
  55. package/lib/echarts.js +2 -2
  56. package/lib/layout/barGrid.js +2 -3
  57. package/lib/model/Series.js +3 -3
  58. package/lib/model/referHelper.js +40 -12
  59. package/lib/scale/Interval.js +87 -2
  60. package/lib/scale/Log.js +9 -2
  61. package/lib/scale/helper.js +1 -43
  62. package/lib/theme/dark.js +3 -0
  63. package/lib/util/graphic.js +1 -2
  64. package/lib/visual/LegendVisualProvider.js +75 -0
  65. package/lib/visual/dataColor.js +2 -12
  66. package/lib/visual/seriesColor.js +15 -7
  67. package/map/json/province/tianjin.json +1 -1
  68. package/package.json +3 -2
  69. package/src/chart/bar/BarView.js +12 -2
  70. package/src/chart/bar/BaseBarSeries.js +1 -1
  71. package/src/chart/effectScatter/EffectScatterSeries.js +1 -1
  72. package/src/chart/funnel/FunnelSeries.js +11 -4
  73. package/src/chart/gauge/GaugeSeries.js +0 -1
  74. package/src/chart/graph/GraphSeries.js +8 -3
  75. package/src/chart/graph/GraphView.js +26 -8
  76. package/src/chart/heatmap/HeatmapView.js +4 -4
  77. package/src/chart/helper/createListFromArray.js +13 -8
  78. package/src/chart/helper/whiskerBoxCommon.js +21 -16
  79. package/src/chart/line/LineSeries.js +1 -1
  80. package/src/chart/line/LineView.js +6 -1
  81. package/src/chart/map/MapSeries.js +5 -1
  82. package/src/chart/pie/PieSeries.js +26 -5
  83. package/src/chart/pie/PieView.js +1 -1
  84. package/src/chart/pie/labelLayout.js +114 -22
  85. package/src/chart/pie/pieLayout.js +20 -7
  86. package/src/chart/radar/RadarSeries.js +5 -3
  87. package/src/chart/sankey/SankeyView.js +26 -9
  88. package/src/chart/scatter/ScatterSeries.js +1 -1
  89. package/src/chart/themeRiver/ThemeRiverSeries.js +4 -3
  90. package/src/chart/tree/TreeSeries.js +12 -1
  91. package/src/component/axis/AngleAxisView.js +75 -7
  92. package/src/component/axis/AxisBuilder.js +78 -33
  93. package/src/component/axis/CartesianAxisView.js +58 -11
  94. package/src/component/axis/RadiusAxisView.js +37 -4
  95. package/src/component/dataZoom/SliderZoomView.js +4 -9
  96. package/src/component/helper/BrushController.js +40 -47
  97. package/src/component/legend/LegendModel.js +3 -3
  98. package/src/component/legend/LegendView.js +18 -12
  99. package/src/component/toolbox/ToolboxView.js +5 -0
  100. package/src/component/toolbox/feature/MagicType.js +18 -13
  101. package/src/coord/Axis.js +29 -2
  102. package/src/coord/axisDefault.js +25 -1
  103. package/src/data/DataDimensionInfo.js +135 -0
  104. package/src/data/List.js +29 -16
  105. package/src/data/Tree.js +3 -1
  106. package/src/data/helper/completeDimensions.js +49 -30
  107. package/src/data/helper/createDimensions.js +2 -0
  108. package/src/data/helper/sourceHelper.js +216 -124
  109. package/src/echarts.js +2 -2
  110. package/src/layout/barGrid.js +6 -3
  111. package/src/model/Series.js +3 -3
  112. package/src/model/referHelper.js +34 -11
  113. package/src/scale/Interval.js +84 -4
  114. package/src/scale/Log.js +9 -2
  115. package/src/scale/helper.js +1 -39
  116. package/src/theme/dark.js +3 -0
  117. package/src/util/graphic.js +1 -2
  118. package/src/visual/LegendVisualProvider.js +55 -0
  119. package/src/visual/dataColor.js +0 -13
  120. package/src/visual/seriesColor.js +13 -7
  121. package/theme/azul.js +163 -0
  122. package/theme/bee-inspired.js +178 -0
  123. package/theme/blue.js +178 -0
  124. package/theme/caravan.js +178 -0
  125. package/theme/carp.js +163 -0
  126. package/theme/cool.js +180 -0
  127. package/theme/dark-blue.js +168 -0
  128. package/theme/dark-bold.js +168 -0
  129. package/theme/dark-digerati.js +168 -0
  130. package/theme/dark-fresh-cut.js +168 -0
  131. package/theme/dark-mushroom.js +168 -0
  132. package/theme/dark.js +69 -62
  133. package/theme/eduardo.js +178 -0
  134. package/theme/forest.js +163 -0
  135. package/theme/fresh-cut.js +163 -0
  136. package/theme/fruit.js +178 -0
  137. package/theme/gray.js +220 -0
  138. package/theme/green.js +222 -0
  139. package/theme/helianthus.js +263 -0
  140. package/theme/infographic.js +72 -57
  141. package/theme/inspired.js +163 -0
  142. package/theme/jazz.js +163 -0
  143. package/theme/london.js +163 -0
  144. package/theme/macarons.js +80 -57
  145. package/theme/macarons2.js +251 -0
  146. package/theme/mint.js +155 -0
  147. package/theme/red-velvet.js +163 -0
  148. package/theme/red.js +225 -0
  149. package/theme/roma.js +55 -22
  150. package/theme/royal.js +163 -0
  151. package/theme/sakura.js +140 -0
  152. package/theme/shine.js +52 -45
  153. package/theme/tech-blue.js +180 -0
  154. package/theme/vintage.js +37 -23
@@ -246,7 +246,6 @@ function doCalBarWidthAndOffset(seriesInfoList) {
246
246
  // only the attributes set on the last series will work.
247
247
  // Do not change this fact unless there will be a break change.
248
248
 
249
- // TODO
250
249
  var barWidth = seriesInfo.barWidth;
251
250
  if (barWidth && !stacks[stackId].width) {
252
251
  // See #6312, do not restrict width.
@@ -286,6 +285,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
286
285
  zrUtil.each(stacks, function (column) {
287
286
  var maxWidth = column.maxWidth;
288
287
  var minWidth = column.minWidth;
288
+
289
289
  if (!column.width) {
290
290
  var finalWidth = autoWidth;
291
291
  if (maxWidth && maxWidth < finalWidth) {
@@ -301,7 +301,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
301
301
  }
302
302
  if (finalWidth !== autoWidth) {
303
303
  column.width = finalWidth;
304
- remainedWidth -= finalWidth;
304
+ remainedWidth -= finalWidth + barGapPercent * finalWidth;
305
305
  autoWidthCount--;
306
306
  }
307
307
  }
@@ -318,7 +318,7 @@ function doCalBarWidthAndOffset(seriesInfoList) {
318
318
  finalWidth = Math.max(finalWidth, minWidth);
319
319
  }
320
320
  column.width = finalWidth;
321
- remainedWidth -= finalWidth;
321
+ remainedWidth -= finalWidth + barGapPercent * finalWidth;
322
322
  autoWidthCount--;
323
323
  }
324
324
  });
@@ -326,8 +326,10 @@ function doCalBarWidthAndOffset(seriesInfoList) {
326
326
  // Recalculate width again
327
327
  autoWidth = (remainedWidth - categoryGap)
328
328
  / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
329
+
329
330
  autoWidth = Math.max(autoWidth, 0);
330
331
 
332
+
331
333
  var widthSum = 0;
332
334
  var lastColumn;
333
335
  zrUtil.each(stacks, function (column, idx) {
@@ -470,6 +472,7 @@ export function layout(seriesType, ecModel) {
470
472
  }
471
473
  stacked && (lastStackCoords[stackId][baseValue][sign] += height);
472
474
  }
475
+
473
476
  data.setItemLayout(idx, {
474
477
  x: x,
475
478
  y: y,
@@ -62,11 +62,11 @@ var SeriesModel = ComponentModel.extend({
62
62
  defaultOption: null,
63
63
 
64
64
  /**
65
- * Data provided for legend
66
- * @type {Function}
65
+ * legend visual provider to the legend component
66
+ * @type {Object}
67
67
  */
68
68
  // PENDING
69
- legendDataProvider: null,
69
+ legendVisualProvider: null,
70
70
 
71
71
  /**
72
72
  * Access path of color for visual
@@ -30,7 +30,8 @@ import {__DEV__} from '../config';
30
30
  import {createHashMap, retrieve, each} from 'zrender/src/core/util';
31
31
 
32
32
  /**
33
- * @return {Object} For example:
33
+ * @class
34
+ * For example:
34
35
  * {
35
36
  * coordSysName: 'cartesian2d',
36
37
  * coordSysDims: ['x', 'y', ...],
@@ -42,19 +43,41 @@ import {createHashMap, retrieve, each} from 'zrender/src/core/util';
42
43
  * x: xAxisModel,
43
44
  * y: undefined
44
45
  * }),
45
- * // It also indicate that whether there is category axis.
46
+ * // The index of the first category axis in `coordSysDims`.
47
+ * // `null/undefined` means no category axis exists.
46
48
  * firstCategoryDimIndex: 1,
47
49
  * // To replace user specified encode.
48
50
  * }
49
51
  */
50
- export function getCoordSysDefineBySeries(seriesModel) {
52
+ function CoordSysInfo(coordSysName) {
53
+ /**
54
+ * @type {string}
55
+ */
56
+ this.coordSysName = coordSysName;
57
+ /**
58
+ * @type {Array.<string>}
59
+ */
60
+ this.coordSysDims = [];
61
+ /**
62
+ * @type {module:zrender/core/util#HashMap}
63
+ */
64
+ this.axisMap = createHashMap();
65
+ /**
66
+ * @type {module:zrender/core/util#HashMap}
67
+ */
68
+ this.categoryAxisMap = createHashMap();
69
+ /**
70
+ * @type {number}
71
+ */
72
+ this.firstCategoryDimIndex = null;
73
+ }
74
+
75
+ /**
76
+ * @return {module:model/referHelper#CoordSysInfo}
77
+ */
78
+ export function getCoordSysInfoBySeries(seriesModel) {
51
79
  var coordSysName = seriesModel.get('coordinateSystem');
52
- var result = {
53
- coordSysName: coordSysName,
54
- coordSysDims: [],
55
- axisMap: createHashMap(),
56
- categoryAxisMap: createHashMap()
57
- };
80
+ var result = new CoordSysInfo(coordSysName);
58
81
  var fetch = fetchers[coordSysName];
59
82
  if (fetch) {
60
83
  fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
@@ -95,7 +118,7 @@ var fetchers = {
95
118
  }
96
119
  if (isCategory(yAxisModel)) {
97
120
  categoryAxisMap.set('y', yAxisModel);
98
- result.firstCategoryDimIndex = 1;
121
+ result.firstCategoryDimIndex == null & (result.firstCategoryDimIndex = 1);
99
122
  }
100
123
  },
101
124
 
@@ -141,7 +164,7 @@ var fetchers = {
141
164
  }
142
165
  if (isCategory(angleAxisModel)) {
143
166
  categoryAxisMap.set('angle', angleAxisModel);
144
- result.firstCategoryDimIndex = 1;
167
+ result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
145
168
  }
146
169
  },
147
170
 
@@ -81,12 +81,92 @@ var IntervalScale = Scale.extend({
81
81
  },
82
82
 
83
83
  /**
84
+ * @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
84
85
  * @return {Array.<number>}
85
86
  */
86
- getTicks: function () {
87
- return helper.intervalScaleGetTicks(
88
- this._interval, this._extent, this._niceExtent, this._intervalPrecision
89
- );
87
+ getTicks: function (expandToNicedExtent) {
88
+ var interval = this._interval;
89
+ var extent = this._extent;
90
+ var niceTickExtent = this._niceExtent;
91
+ var intervalPrecision = this._intervalPrecision;
92
+
93
+ var ticks = [];
94
+ // If interval is 0, return [];
95
+ if (!interval) {
96
+ return ticks;
97
+ }
98
+
99
+ // Consider this case: using dataZoom toolbox, zoom and zoom.
100
+ var safeLimit = 10000;
101
+
102
+ if (extent[0] < niceTickExtent[0]) {
103
+ if (expandToNicedExtent) {
104
+ ticks.push(roundNumber(niceTickExtent[0] - interval));
105
+ }
106
+ else {
107
+ ticks.push(extent[0]);
108
+ }
109
+ }
110
+ var tick = niceTickExtent[0];
111
+
112
+ while (tick <= niceTickExtent[1]) {
113
+ ticks.push(tick);
114
+ // Avoid rounding error
115
+ tick = roundNumber(tick + interval, intervalPrecision);
116
+ if (tick === ticks[ticks.length - 1]) {
117
+ // Consider out of safe float point, e.g.,
118
+ // -3711126.9907707 + 2e-10 === -3711126.9907707
119
+ break;
120
+ }
121
+ if (ticks.length > safeLimit) {
122
+ return [];
123
+ }
124
+ }
125
+ // Consider this case: the last item of ticks is smaller
126
+ // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
127
+ var lastNiceTick = ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1];
128
+ if (extent[1] > lastNiceTick) {
129
+ if (expandToNicedExtent) {
130
+ ticks.push(lastNiceTick + interval);
131
+ }
132
+ else {
133
+ ticks.push(extent[1]);
134
+ }
135
+ }
136
+
137
+ return ticks;
138
+ },
139
+
140
+ /**
141
+ * @param {number} [splitNumber=5]
142
+ * @return {Array.<Array.<number>>}
143
+ */
144
+ getMinorTicks: function (splitNumber) {
145
+ var ticks = this.getTicks(true);
146
+ var minorTicks = [];
147
+ var extent = this.getExtent();
148
+
149
+ for (var i = 1; i < ticks.length; i++) {
150
+ var nextTick = ticks[i];
151
+ var prevTick = ticks[i - 1];
152
+ var count = 0;
153
+ var minorTicksGroup = [];
154
+ var interval = nextTick - prevTick;
155
+ var minorInterval = interval / splitNumber;
156
+
157
+ while (count < splitNumber - 1) {
158
+ var minorTick = numberUtil.round(prevTick + (count + 1) * minorInterval);
159
+
160
+ // For the first and last interval. The count may be less than splitNumber.
161
+ if (minorTick > extent[0] && minorTick < extent[1]) {
162
+ minorTicksGroup.push(minorTick);
163
+ }
164
+ count++;
165
+ }
166
+ minorTicks.push(minorTicksGroup);
167
+ }
168
+
169
+ return minorTicks;
90
170
  },
91
171
 
92
172
  /**
package/src/scale/Log.js CHANGED
@@ -53,14 +53,15 @@ var LogScale = Scale.extend({
53
53
  },
54
54
 
55
55
  /**
56
+ * @param {boolean} [expandToNicedExtent=false] If expand the ticks to niced extent.
56
57
  * @return {Array.<number>}
57
58
  */
58
- getTicks: function () {
59
+ getTicks: function (expandToNicedExtent) {
59
60
  var originalScale = this._originalScale;
60
61
  var extent = this._extent;
61
62
  var originalExtent = originalScale.getExtent();
62
63
 
63
- return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
64
+ return zrUtil.map(intervalScaleProto.getTicks.call(this, expandToNicedExtent), function (val) {
64
65
  var powVal = numberUtil.round(mathPow(this.base, val));
65
66
 
66
67
  // Fix #4158
@@ -75,6 +76,12 @@ var LogScale = Scale.extend({
75
76
  }, this);
76
77
  },
77
78
 
79
+ /**
80
+ * @param {number} splitNumber
81
+ * @return {Array.<Array.<number>>}
82
+ */
83
+ getMinorTicks: intervalScaleProto.getMinorTicks,
84
+
78
85
  /**
79
86
  * @param {number} val
80
87
  * @return {string}
@@ -79,42 +79,4 @@ export function fixExtent(niceTickExtent, extent) {
79
79
  if (niceTickExtent[0] > niceTickExtent[1]) {
80
80
  niceTickExtent[0] = niceTickExtent[1];
81
81
  }
82
- }
83
-
84
- export function intervalScaleGetTicks(interval, extent, niceTickExtent, intervalPrecision) {
85
- var ticks = [];
86
-
87
- // If interval is 0, return [];
88
- if (!interval) {
89
- return ticks;
90
- }
91
-
92
- // Consider this case: using dataZoom toolbox, zoom and zoom.
93
- var safeLimit = 10000;
94
-
95
- if (extent[0] < niceTickExtent[0]) {
96
- ticks.push(extent[0]);
97
- }
98
- var tick = niceTickExtent[0];
99
-
100
- while (tick <= niceTickExtent[1]) {
101
- ticks.push(tick);
102
- // Avoid rounding error
103
- tick = roundNumber(tick + interval, intervalPrecision);
104
- if (tick === ticks[ticks.length - 1]) {
105
- // Consider out of safe float point, e.g.,
106
- // -3711126.9907707 + 2e-10 === -3711126.9907707
107
- break;
108
- }
109
- if (ticks.length > safeLimit) {
110
- return [];
111
- }
112
- }
113
- // Consider this case: the last item of ticks is smaller
114
- // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
115
- if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceTickExtent[1])) {
116
- ticks.push(extent[1]);
117
- }
118
-
119
- return ticks;
120
- }
82
+ }
package/src/theme/dark.js CHANGED
@@ -63,6 +63,9 @@ var theme = {
63
63
  },
64
64
  crossStyle: {
65
65
  color: contrastColor
66
+ },
67
+ label: {
68
+ color: '#000'
66
69
  }
67
70
  }
68
71
  },
@@ -1071,8 +1071,7 @@ function rollbackDefaultTextStyle(style) {
1071
1071
  }
1072
1072
 
1073
1073
  export function getFont(opt, ecModel) {
1074
- // ecModel or default text style model.
1075
- var gTextStyleModel = ecModel || ecModel.getModel('textStyle');
1074
+ var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
1076
1075
  return zrUtil.trim([
1077
1076
  // FIXME in node-canvas fontWeight is before fontStyle
1078
1077
  opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '',
@@ -0,0 +1,55 @@
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
+
21
+ /**
22
+ * LegendVisualProvider is an bridge that pick encoded color from data and
23
+ * provide to the legend component.
24
+ * @param {Function} getDataWithEncodedVisual Function to get data after filtered. It stores all the encoding info
25
+ * @param {Function} getRawData Function to get raw data before filtered.
26
+ */
27
+ function LegendVisualProvider(getDataWithEncodedVisual, getRawData) {
28
+ this.getAllNames = function () {
29
+ var rawData = getRawData();
30
+ // We find the name from the raw data. In case it's filtered by the legend component.
31
+ // Normally, the name can be found in rawData, but can't be found in filtered data will display as gray.
32
+ return rawData.mapArray(rawData.getName);
33
+ };
34
+
35
+ this.containName = function (name) {
36
+ var rawData = getRawData();
37
+ return rawData.indexOfName(name) >= 0;
38
+ };
39
+
40
+ this.indexOfName = function (name) {
41
+ // Only get data when necessary.
42
+ // Because LegendVisualProvider constructor may be new in the stage that data is not prepared yet.
43
+ // Invoking Series#getData immediately will throw an error.
44
+ var dataWithEncodedVisual = getDataWithEncodedVisual();
45
+ return dataWithEncodedVisual.indexOfName(name);
46
+ };
47
+
48
+ this.getItemVisual = function (dataIndex, key) {
49
+ // Get encoded visual properties from final filtered data.
50
+ var dataWithEncodedVisual = getDataWithEncodedVisual();
51
+ return dataWithEncodedVisual.getItemVisual(dataIndex, key);
52
+ };
53
+ }
54
+
55
+ export default LegendVisualProvider;
@@ -68,33 +68,20 @@ export default function (seriesType) {
68
68
  dataAll.getName(rawIdx) || (rawIdx + ''), seriesModel.__paletteScope,
69
69
  dataAll.count()
70
70
  );
71
- // Legend may use the visual info in data before processed
72
- dataAll.setItemVisual(rawIdx, 'color', color);
73
-
74
71
  // Data is not filtered
75
72
  if (filteredIdx != null) {
76
73
  data.setItemVisual(filteredIdx, 'color', color);
77
74
  }
78
75
  }
79
- else {
80
- // Set data all color for legend
81
- dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
82
- }
83
76
 
84
77
  if (!singleDataBorderColor) {
85
78
  var borderColor = itemModel.get('itemStyle.borderColor');
86
- // Legend may use the visual info in data before processed
87
- dataAll.setItemVisual(rawIdx, 'borderColor', borderColor);
88
79
 
89
80
  // Data is not filtered
90
81
  if (filteredIdx != null) {
91
82
  data.setItemVisual(filteredIdx, 'borderColor', borderColor);
92
83
  }
93
84
  }
94
- else {
95
- // Set data all borderColor for legend
96
- dataAll.setItemVisual(rawIdx, 'borderColor', singleDataBorderColor);
97
- }
98
85
  });
99
86
  }
100
87
  };
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import Gradient from 'zrender/src/graphic/Gradient';
21
+ import {isFunction} from 'zrender/src/core/util';
21
22
 
22
23
  export default {
23
24
  createOnAllSeries: true,
@@ -25,25 +26,30 @@ export default {
25
26
  reset: function (seriesModel, ecModel) {
26
27
  var data = seriesModel.getData();
27
28
  var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.color').split('.');
28
- var color = seriesModel.get(colorAccessPath) // Set in itemStyle
29
- || seriesModel.getColorFromPalette(
29
+ // Set in itemStyle
30
+ var color = seriesModel.get(colorAccessPath);
31
+ var colorCallback = (isFunction(color) && !(color instanceof Gradient))
32
+ ? color : null;
33
+ // Default color
34
+ if (!color || colorCallback) {
35
+ color = seriesModel.getColorFromPalette(
30
36
  // TODO series count changed.
31
37
  seriesModel.name, null, ecModel.getSeriesCount()
32
- ); // Default color
38
+ );
39
+ }
33
40
 
34
- // FIXME Set color function or use the platte color
35
41
  data.setVisual('color', color);
36
-
42
+
37
43
  var borderColorAccessPath = (seriesModel.visualBorderColorAccessPath || 'itemStyle.borderColor').split('.');
38
44
  var borderColor = seriesModel.get(borderColorAccessPath);
39
45
  data.setVisual('borderColor', borderColor);
40
46
 
41
47
  // Only visible series has each data be visual encoded
42
48
  if (!ecModel.isSeriesFiltered(seriesModel)) {
43
- if (typeof color === 'function' && !(color instanceof Gradient)) {
49
+ if (colorCallback) {
44
50
  data.each(function (idx) {
45
51
  data.setItemVisual(
46
- idx, 'color', color(seriesModel.getDataParams(idx))
52
+ idx, 'color', colorCallback(seriesModel.getDataParams(idx))
47
53
  );
48
54
  });
49
55
  }
package/theme/azul.js ADDED
@@ -0,0 +1,163 @@
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
+ (function(root, factory) {
21
+ if (typeof define === 'function' && define.amd) {
22
+ // AMD. Register as an anonymous module.
23
+ define(['exports', 'echarts'], factory);
24
+ } else if (
25
+ typeof exports === 'object' &&
26
+ typeof exports.nodeName !== 'string'
27
+ ) {
28
+ // CommonJS
29
+ factory(exports, require('echarts'));
30
+ } else {
31
+ // Browser globals
32
+ factory({}, root.echarts);
33
+ }
34
+ })(this, function(exports, echarts) {
35
+ var log = function(msg) {
36
+ if (typeof console !== 'undefined') {
37
+ console && console.error && console.error(msg);
38
+ }
39
+ };
40
+ if (!echarts) {
41
+ log('ECharts is not Loaded');
42
+ return;
43
+ }
44
+
45
+ var colorPalette = [
46
+ '#f2385a',
47
+ '#f5a503',
48
+ '#4ad9d9',
49
+ '#f7879c',
50
+ '#c1d7a8',
51
+ '#4dffd2',
52
+ '#fccfd7',
53
+ '#d5f6f6'
54
+ ];
55
+
56
+ var theme = {
57
+ color: colorPalette,
58
+
59
+ title: {
60
+ textStyle: {
61
+ fontWeight: 'normal',
62
+ color: '#f2385a'
63
+ }
64
+ },
65
+
66
+ visualMap: {
67
+ color: ['#f2385a', '#f5a503']
68
+ },
69
+
70
+ toolbox: {
71
+ color: ['#f2385a', '#f2385a', '#f2385a', '#f2385a']
72
+ },
73
+
74
+ tooltip: {
75
+ backgroundColor: 'rgba(0,0,0,0.5)',
76
+ axisPointer: {
77
+ // Axis indicator, coordinate trigger effective
78
+ type: 'line', // The default is a straight line: 'line' | 'shadow'
79
+ lineStyle: {
80
+ // Straight line indicator style settings
81
+ color: '#f2385a',
82
+ type: 'dashed'
83
+ },
84
+ crossStyle: {
85
+ color: '#f2385a'
86
+ },
87
+ shadowStyle: {
88
+ // Shadow indicator style settings
89
+ color: 'rgba(200,200,200,0.3)'
90
+ }
91
+ }
92
+ },
93
+
94
+ // Area scaling controller
95
+ dataZoom: {
96
+ dataBackgroundColor: '#eee', // Data background color
97
+ fillerColor: 'rgba(200,200,200,0.2)', // Fill the color
98
+ handleColor: '#f2385a' // Handle color
99
+ },
100
+
101
+ timeline: {
102
+ lineStyle: {
103
+ color: '#f2385a'
104
+ },
105
+ controlStyle: {
106
+ color: '#f2385a',
107
+ borderColor: '#f2385a'
108
+ }
109
+ },
110
+
111
+ candlestick: {
112
+ itemStyle: {
113
+ color: '#f2385a',
114
+ color0: '#f5a503'
115
+ },
116
+ lineStyle: {
117
+ width: 1,
118
+ color: '#f2385a',
119
+ color0: '#f5a503'
120
+ },
121
+ areaStyle: {
122
+ color: '#c1d7a8',
123
+ color0: '#4ad9d9'
124
+ }
125
+ },
126
+
127
+ map: {
128
+ itemStyle: {
129
+ color: '#f2385a'
130
+ },
131
+ areaStyle: {
132
+ color: '#ddd'
133
+ },
134
+ label: {
135
+ color: '#c12e34'
136
+ }
137
+ },
138
+
139
+ graph: {
140
+ itemStyle: {
141
+ color: '#f2385a'
142
+ },
143
+ linkStyle: {
144
+ color: '#f2385a'
145
+ }
146
+ },
147
+
148
+ gauge: {
149
+ axisLine: {
150
+ lineStyle: {
151
+ color: [
152
+ [0.2, '#f5a503'],
153
+ [0.8, '#f2385a'],
154
+ [1, '#c1d7a8']
155
+ ],
156
+ width: 8
157
+ }
158
+ }
159
+ }
160
+ };
161
+
162
+ echarts.registerTheme('azul', theme);
163
+ });