echarts 3.5.1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -18
- package/README.md +10 -0
- package/dist/echarts.common.js +11010 -9830
- package/dist/echarts.common.min.js +13 -13
- package/dist/echarts.js +13291 -10852
- package/dist/echarts.min.js +22 -21
- package/dist/echarts.simple.js +9904 -8990
- package/dist/echarts.simple.min.js +9 -10
- package/index.js +1 -0
- package/lib/ExtensionAPI.js +2 -4
- package/lib/chart/bar/BarView.js +141 -49
- package/lib/chart/bar/BaseBarSeries.js +2 -6
- package/lib/chart/bar.js +1 -0
- package/lib/chart/boxplot/BoxplotSeries.js +1 -1
- package/lib/chart/boxplot/boxplotLayout.js +23 -7
- package/lib/chart/candlestick/CandlestickSeries.js +3 -22
- package/lib/chart/candlestick/candlestickLayout.js +23 -7
- package/lib/chart/custom.js +442 -0
- package/lib/chart/funnel/funnelLayout.js +10 -3
- package/lib/chart/gauge/GaugeView.js +1 -1
- package/lib/chart/graph/GraphView.js +15 -9
- package/lib/chart/graph/categoryVisual.js +3 -2
- package/lib/chart/heatmap/HeatmapLayer.js +1 -1
- package/lib/chart/heatmap/HeatmapView.js +75 -73
- package/lib/chart/helper/Symbol.js +8 -31
- package/lib/chart/helper/createListFromArray.js +15 -10
- package/lib/chart/helper/labelHelper.js +48 -0
- package/lib/chart/helper/whiskerBoxCommon.js +25 -44
- package/lib/chart/map/mapDataStatistic.js +9 -8
- package/lib/chart/parallel/ParallelSeries.js +2 -0
- package/lib/chart/parallel/ParallelView.js +13 -12
- package/lib/chart/parallel/parallelVisual.js +9 -1
- package/lib/chart/pie/pieLayout.js +25 -17
- package/lib/chart/radar/RadarSeries.js +1 -1
- package/lib/chart/sankey/sankeyLayout.js +1 -1
- package/lib/chart/scatter/ScatterSeries.js +2 -3
- package/lib/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/lib/chart/themeRiver/themeRiverVisual.js +1 -1
- package/lib/chart/treemap/TreemapSeries.js +3 -3
- package/lib/chart/treemap/TreemapView.js +1 -1
- package/lib/chart/treemap/treemapLayout.js +6 -1
- package/lib/component/axis/AxisBuilder.js +53 -34
- package/lib/component/axis/ParallelAxisView.js +45 -37
- package/lib/component/axisPointer/AxisPointerModel.js +1 -1
- package/lib/component/axisPointer/BaseAxisPointer.js +20 -15
- package/lib/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/lib/component/axisPointer/PolarAxisPointer.js +10 -8
- package/lib/component/axisPointer/SingleAxisPointer.js +11 -7
- package/lib/component/axisPointer/axisTrigger.js +87 -72
- package/lib/component/axisPointer/viewHelper.js +6 -3
- package/lib/component/axisPointer.js +2 -2
- package/lib/component/brush/BrushModel.js +6 -4
- package/lib/component/brush/BrushView.js +1 -1
- package/lib/component/brush/visualEncoding.js +6 -4
- package/lib/component/calendar/CalendarView.js +5 -5
- package/lib/component/dataZoom/AxisProxy.js +76 -13
- package/lib/component/dataZoom/DataZoomModel.js +21 -5
- package/lib/component/dataZoom/InsideZoomModel.js +4 -1
- package/lib/component/dataZoom/InsideZoomView.js +17 -27
- package/lib/component/dataZoom/SliderZoomView.js +63 -26
- package/lib/component/dataZoom/roams.js +9 -4
- package/lib/component/graphic.js +13 -12
- package/lib/component/helper/BrushController.js +75 -114
- package/lib/component/helper/BrushTargetManager.js +16 -8
- package/lib/component/helper/MapDraw.js +25 -11
- package/lib/component/helper/RoamController.js +111 -139
- package/lib/component/helper/brushHelper.js +25 -213
- package/lib/component/helper/cursorHelper.js +21 -0
- package/lib/component/helper/roamHelper.js +54 -0
- package/lib/component/helper/selectableMixin.js +7 -7
- package/lib/component/helper/sliderMove.js +66 -37
- package/lib/component/legend/LegendView.js +6 -6
- package/lib/component/legend/legendAction.js +1 -1
- package/lib/component/marker/MarkAreaView.js +3 -6
- package/lib/component/marker/MarkLineView.js +3 -5
- package/lib/component/marker/MarkPointView.js +3 -5
- package/lib/component/marker/MarkerView.js +10 -12
- package/lib/component/marker/markerHelper.js +1 -1
- package/lib/component/parallel.js +94 -29
- package/lib/component/polar.js +5 -0
- package/lib/component/timeline/SliderTimelineView.js +1 -1
- package/lib/component/toolbox/feature/Brush.js +7 -0
- package/lib/component/toolbox/feature/DataZoom.js +17 -4
- package/lib/component/tooltip/TooltipView.js +92 -20
- package/lib/component/visualMap/ContinuousView.js +6 -4
- package/lib/coord/Axis.js +34 -2
- package/lib/coord/axisDefault.js +4 -1
- package/lib/coord/axisHelper.js +32 -26
- package/lib/coord/axisModelCommonMixin.js +1 -1
- package/lib/coord/calendar/Calendar.js +14 -17
- package/lib/coord/calendar/prepareCustom.js +31 -0
- package/lib/coord/cartesian/Axis2D.js +0 -12
- package/lib/coord/cartesian/Cartesian2D.js +1 -0
- package/lib/coord/cartesian/Grid.js +5 -2
- package/lib/coord/cartesian/prepareCustom.js +36 -0
- package/lib/coord/geo/Geo.js +9 -14
- package/lib/coord/geo/GeoModel.js +5 -5
- package/lib/coord/geo/geoCreator.js +3 -3
- package/lib/coord/geo/parseGeoJson.js +11 -4
- package/lib/coord/geo/prepareCustom.js +36 -0
- package/lib/coord/parallel/Parallel.js +225 -101
- package/lib/coord/parallel/ParallelModel.js +7 -1
- package/lib/coord/polar/Polar.js +2 -1
- package/lib/coord/polar/prepareCustom.js +53 -0
- package/lib/coord/single/Single.js +9 -8
- package/lib/coord/single/SingleAxis.js +0 -27
- package/lib/coord/single/prepareCustom.js +33 -0
- package/lib/data/DataDiffer.js +2 -1
- package/lib/data/Graph.js +11 -7
- package/lib/data/List.js +59 -20
- package/lib/data/helper/completeDimensions.js +184 -23
- package/lib/echarts.js +68 -36
- package/lib/helper.js +1 -8
- package/lib/layout/barGrid.js +91 -19
- package/lib/layout/barPolar.js +286 -0
- package/lib/layout/points.js +22 -16
- package/lib/model/Global.js +34 -31
- package/lib/model/Series.js +41 -29
- package/lib/model/globalDefault.js +4 -1
- package/lib/model/mixin/colorPalette.js +2 -1
- package/lib/model/mixin/textStyle.js +7 -13
- package/lib/scale/Interval.js +46 -76
- package/lib/scale/Log.js +5 -7
- package/lib/scale/Scale.js +10 -1
- package/lib/scale/Time.js +34 -12
- package/lib/scale/helper.js +93 -0
- package/lib/util/format.js +20 -9
- package/lib/util/graphic.js +70 -8
- package/lib/util/layout.js +7 -3
- package/lib/util/model.js +63 -7
- package/lib/util/number.js +59 -19
- package/lib/util/throttle.js +14 -3
- package/map/js/world.js +1 -1
- package/map/json/world.json +1 -1
- package/package.json +3 -3
- package/src/ExtensionAPI.js +2 -4
- package/src/chart/bar/BarView.js +141 -49
- package/src/chart/bar/BaseBarSeries.js +2 -6
- package/src/chart/bar.js +1 -0
- package/src/chart/boxplot/BoxplotSeries.js +1 -1
- package/src/chart/boxplot/boxplotLayout.js +23 -7
- package/src/chart/candlestick/CandlestickSeries.js +3 -22
- package/src/chart/candlestick/candlestickLayout.js +23 -7
- package/src/chart/custom.js +442 -0
- package/src/chart/funnel/funnelLayout.js +10 -4
- package/src/chart/gauge/GaugeView.js +1 -1
- package/src/chart/graph/GraphView.js +15 -9
- package/src/chart/graph/categoryVisual.js +3 -2
- package/src/chart/heatmap/HeatmapLayer.js +1 -1
- package/src/chart/heatmap/HeatmapView.js +75 -73
- package/src/chart/helper/Symbol.js +8 -31
- package/src/chart/helper/createListFromArray.js +15 -10
- package/src/chart/helper/labelHelper.js +49 -0
- package/src/chart/helper/whiskerBoxCommon.js +25 -44
- package/src/chart/map/mapDataStatistic.js +9 -8
- package/src/chart/parallel/ParallelSeries.js +2 -0
- package/src/chart/parallel/ParallelView.js +13 -12
- package/src/chart/parallel/parallelVisual.js +9 -1
- package/src/chart/pie/pieLayout.js +25 -17
- package/src/chart/radar/RadarSeries.js +1 -1
- package/src/chart/sankey/sankeyLayout.js +1 -1
- package/src/chart/scatter/ScatterSeries.js +2 -3
- package/src/chart/themeRiver/ThemeRiverSeries.js +6 -5
- package/src/chart/themeRiver/themeRiverVisual.js +1 -1
- package/src/chart/treemap/TreemapSeries.js +3 -3
- package/src/chart/treemap/TreemapView.js +1 -1
- package/src/chart/treemap/treemapLayout.js +6 -1
- package/src/component/axis/AxisBuilder.js +53 -34
- package/src/component/axis/ParallelAxisView.js +45 -37
- package/src/component/axisPointer/AxisPointerModel.js +1 -1
- package/src/component/axisPointer/BaseAxisPointer.js +20 -15
- package/src/component/axisPointer/CartesianAxisPointer.js +9 -6
- package/src/component/axisPointer/PolarAxisPointer.js +10 -8
- package/src/component/axisPointer/SingleAxisPointer.js +11 -7
- package/src/component/axisPointer/axisTrigger.js +87 -72
- package/src/component/axisPointer/viewHelper.js +6 -3
- package/src/component/axisPointer.js +2 -2
- package/src/component/brush/BrushModel.js +6 -4
- package/src/component/brush/BrushView.js +1 -1
- package/src/component/brush/visualEncoding.js +6 -4
- package/src/component/calendar/CalendarView.js +5 -5
- package/src/component/dataZoom/AxisProxy.js +76 -13
- package/src/component/dataZoom/DataZoomModel.js +21 -5
- package/src/component/dataZoom/InsideZoomModel.js +4 -1
- package/src/component/dataZoom/InsideZoomView.js +17 -27
- package/src/component/dataZoom/SliderZoomView.js +63 -26
- package/src/component/dataZoom/roams.js +9 -4
- package/src/component/graphic.js +13 -12
- package/src/component/helper/BrushController.js +75 -114
- package/src/component/helper/BrushTargetManager.js +16 -8
- package/src/component/helper/MapDraw.js +25 -11
- package/src/component/helper/RoamController.js +111 -139
- package/src/component/helper/brushHelper.js +41 -0
- package/src/component/helper/cursorHelper.js +22 -0
- package/src/component/helper/roamHelper.js +55 -0
- package/src/component/helper/selectableMixin.js +7 -7
- package/src/component/helper/sliderMove.js +66 -37
- package/src/component/legend/LegendView.js +6 -6
- package/src/component/legend/legendAction.js +1 -1
- package/src/component/marker/MarkAreaView.js +3 -6
- package/src/component/marker/MarkLineView.js +3 -5
- package/src/component/marker/MarkPointView.js +3 -5
- package/src/component/marker/MarkerView.js +10 -12
- package/src/component/marker/markerHelper.js +1 -1
- package/src/component/parallel.js +94 -29
- package/src/component/polar.js +5 -0
- package/src/component/timeline/SliderTimelineView.js +1 -1
- package/src/component/toolbox/feature/Brush.js +7 -0
- package/src/component/toolbox/feature/DataZoom.js +17 -4
- package/src/component/tooltip/TooltipView.js +92 -20
- package/src/component/visualMap/ContinuousView.js +6 -4
- package/src/coord/Axis.js +34 -2
- package/src/coord/axisDefault.js +4 -1
- package/src/coord/axisHelper.js +32 -26
- package/src/coord/axisModelCommonMixin.js +1 -1
- package/src/coord/calendar/Calendar.js +14 -17
- package/src/coord/calendar/prepareCustom.js +32 -0
- package/src/coord/cartesian/Axis2D.js +0 -12
- package/src/coord/cartesian/Cartesian2D.js +1 -0
- package/src/coord/cartesian/Grid.js +5 -2
- package/src/coord/cartesian/prepareCustom.js +37 -0
- package/src/coord/geo/Geo.js +9 -14
- package/src/coord/geo/GeoModel.js +5 -5
- package/src/coord/geo/geoCreator.js +3 -3
- package/src/coord/geo/parseGeoJson.js +11 -4
- package/src/coord/geo/prepareCustom.js +37 -0
- package/src/coord/parallel/Parallel.js +225 -101
- package/src/coord/parallel/ParallelModel.js +7 -1
- package/src/coord/polar/Polar.js +2 -1
- package/src/coord/polar/prepareCustom.js +54 -0
- package/src/coord/single/Single.js +9 -8
- package/src/coord/single/SingleAxis.js +0 -27
- package/src/coord/single/prepareCustom.js +34 -0
- package/src/data/DataDiffer.js +2 -1
- package/src/data/Graph.js +11 -7
- package/src/data/List.js +59 -20
- package/src/data/helper/completeDimensions.js +184 -23
- package/src/echarts.js +68 -36
- package/src/helper.js +1 -8
- package/src/layout/barGrid.js +91 -19
- package/src/layout/barPolar.js +287 -0
- package/src/layout/points.js +22 -16
- package/src/model/Global.js +34 -31
- package/src/model/Series.js +41 -29
- package/src/model/globalDefault.js +4 -1
- package/src/model/mixin/colorPalette.js +2 -1
- package/src/model/mixin/textStyle.js +7 -13
- package/src/scale/Interval.js +46 -76
- package/src/scale/Log.js +5 -7
- package/src/scale/Scale.js +10 -1
- package/src/scale/Time.js +34 -12
- package/src/scale/helper.js +94 -0
- package/src/util/format.js +20 -9
- package/src/util/graphic.js +70 -8
- package/src/util/layout.js +7 -3
- package/src/util/model.js +63 -7
- package/src/util/number.js +59 -19
- package/src/util/throttle.js +14 -3
- package/src/coord/cartesian/axisLabelInterval.js +0 -26
- package/theme/default.js +0 -23
- package/theme/halloween.js +0 -528
package/src/echarts.js
CHANGED
|
@@ -176,7 +176,7 @@ define(function (require) {
|
|
|
176
176
|
* @type {module:echarts/ExtensionAPI}
|
|
177
177
|
* @private
|
|
178
178
|
*/
|
|
179
|
-
this._api =
|
|
179
|
+
this._api = createExtensionAPI(this);
|
|
180
180
|
|
|
181
181
|
Eventful.call(this);
|
|
182
182
|
|
|
@@ -276,14 +276,7 @@ define(function (require) {
|
|
|
276
276
|
ecModel.init(null, null, theme, optionManager);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
|
|
280
|
-
// ugly
|
|
281
|
-
this.__lastOnlyGraphic = !!(option && option.graphic);
|
|
282
|
-
zrUtil.each(option, function (o, mainType) {
|
|
283
|
-
mainType !== 'graphic' && (this.__lastOnlyGraphic = false);
|
|
284
|
-
}, this);
|
|
285
|
-
|
|
286
|
-
this._model.setOption(option, optionPreprocessorFuncs, this.__lastOnlyGraphic);
|
|
279
|
+
this._model.setOption(option, optionPreprocessorFuncs);
|
|
287
280
|
|
|
288
281
|
if (lazyUpdate) {
|
|
289
282
|
this[OPTION_UPDATED] = {silent: silent};
|
|
@@ -809,21 +802,7 @@ define(function (require) {
|
|
|
809
802
|
|
|
810
803
|
prepareView.call(this, 'chart', ecModel);
|
|
811
804
|
|
|
812
|
-
|
|
813
|
-
// ugly
|
|
814
|
-
if (this.__lastOnlyGraphic) {
|
|
815
|
-
each(this._componentsViews, function (componentView) {
|
|
816
|
-
var componentModel = componentView.__model;
|
|
817
|
-
if (componentModel && componentModel.mainType === 'graphic') {
|
|
818
|
-
componentView.render(componentModel, ecModel, this._api, payload);
|
|
819
|
-
updateZ(componentModel, componentView);
|
|
820
|
-
}
|
|
821
|
-
}, this);
|
|
822
|
-
this.__lastOnlyGraphic = false;
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
updateMethods.update.call(this, payload);
|
|
826
|
-
}
|
|
805
|
+
updateMethods.update.call(this, payload);
|
|
827
806
|
}
|
|
828
807
|
};
|
|
829
808
|
|
|
@@ -1140,7 +1119,7 @@ define(function (require) {
|
|
|
1140
1119
|
}
|
|
1141
1120
|
|
|
1142
1121
|
// Consider: id same and type changed.
|
|
1143
|
-
var viewId = model.id + '_' + model.type;
|
|
1122
|
+
var viewId = '_ec_' + model.id + '_' + model.type;
|
|
1144
1123
|
var view = viewMap[viewId];
|
|
1145
1124
|
if (!view) {
|
|
1146
1125
|
var classType = parseClassType(model.type);
|
|
@@ -1160,10 +1139,13 @@ define(function (require) {
|
|
|
1160
1139
|
}
|
|
1161
1140
|
}
|
|
1162
1141
|
|
|
1163
|
-
model.__viewId = viewId;
|
|
1142
|
+
model.__viewId = view.__id = viewId;
|
|
1164
1143
|
view.__alive = true;
|
|
1165
|
-
view.__id = viewId;
|
|
1166
1144
|
view.__model = model;
|
|
1145
|
+
view.group.__ecComponentInfo = {
|
|
1146
|
+
mainType: model.mainType,
|
|
1147
|
+
index: model.componentIndex
|
|
1148
|
+
};
|
|
1167
1149
|
}, this);
|
|
1168
1150
|
|
|
1169
1151
|
for (var i = 0; i < viewList.length;) {
|
|
@@ -1173,6 +1155,7 @@ define(function (require) {
|
|
|
1173
1155
|
view.dispose(ecModel, this._api);
|
|
1174
1156
|
viewList.splice(i, 1);
|
|
1175
1157
|
delete viewMap[view.__id];
|
|
1158
|
+
view.__id = view.group.__ecComponentInfo = null;
|
|
1176
1159
|
}
|
|
1177
1160
|
else {
|
|
1178
1161
|
i++;
|
|
@@ -1202,7 +1185,8 @@ define(function (require) {
|
|
|
1202
1185
|
var data = series.getData();
|
|
1203
1186
|
if (stack && data.type === 'list') {
|
|
1204
1187
|
var previousStack = stackedDataMap[stack];
|
|
1205
|
-
|
|
1188
|
+
// Avoid conflict with Object.prototype
|
|
1189
|
+
if (stackedDataMap.hasOwnProperty(stack) && previousStack) {
|
|
1206
1190
|
data.stackedOn = previousStack;
|
|
1207
1191
|
}
|
|
1208
1192
|
stackedDataMap[stack] = data;
|
|
@@ -1344,6 +1328,7 @@ define(function (require) {
|
|
|
1344
1328
|
echartsProto.clear = function () {
|
|
1345
1329
|
this.setOption({ series: [] }, true);
|
|
1346
1330
|
};
|
|
1331
|
+
|
|
1347
1332
|
/**
|
|
1348
1333
|
* Dispose instance
|
|
1349
1334
|
*/
|
|
@@ -1390,6 +1375,7 @@ define(function (require) {
|
|
|
1390
1375
|
});
|
|
1391
1376
|
}
|
|
1392
1377
|
}
|
|
1378
|
+
|
|
1393
1379
|
/**
|
|
1394
1380
|
* Update chart progressive and blend.
|
|
1395
1381
|
* @param {module:echarts/model/Series|module:echarts/model/Component} model
|
|
@@ -1432,6 +1418,7 @@ define(function (require) {
|
|
|
1432
1418
|
}
|
|
1433
1419
|
});
|
|
1434
1420
|
}
|
|
1421
|
+
|
|
1435
1422
|
/**
|
|
1436
1423
|
* @param {module:echarts/model/Series|module:echarts/model/Component} model
|
|
1437
1424
|
* @param {module:echarts/view/Component|module:echarts/view/Chart} view
|
|
@@ -1447,6 +1434,26 @@ define(function (require) {
|
|
|
1447
1434
|
}
|
|
1448
1435
|
});
|
|
1449
1436
|
}
|
|
1437
|
+
|
|
1438
|
+
function createExtensionAPI(ecInstance) {
|
|
1439
|
+
var coordSysMgr = ecInstance._coordSysMgr;
|
|
1440
|
+
return zrUtil.extend(new ExtensionAPI(ecInstance), {
|
|
1441
|
+
// Inject methods
|
|
1442
|
+
getCoordinateSystems: zrUtil.bind(
|
|
1443
|
+
coordSysMgr.getCoordinateSystems, coordSysMgr
|
|
1444
|
+
),
|
|
1445
|
+
getComponentByElement: function (el) {
|
|
1446
|
+
while (el) {
|
|
1447
|
+
var modelInfo = el.__ecComponentInfo;
|
|
1448
|
+
if (modelInfo != null) {
|
|
1449
|
+
return ecInstance._model.getComponent(modelInfo.mainType, modelInfo.index);
|
|
1450
|
+
}
|
|
1451
|
+
el = el.parent;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1450
1457
|
/**
|
|
1451
1458
|
* @type {Object} key: actionType.
|
|
1452
1459
|
* @inner
|
|
@@ -1501,6 +1508,7 @@ define(function (require) {
|
|
|
1501
1508
|
var idBase = new Date() - 0;
|
|
1502
1509
|
var groupIdBase = new Date() - 0;
|
|
1503
1510
|
var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
|
|
1511
|
+
|
|
1504
1512
|
/**
|
|
1505
1513
|
* @alias module:echarts
|
|
1506
1514
|
*/
|
|
@@ -1508,9 +1516,9 @@ define(function (require) {
|
|
|
1508
1516
|
/**
|
|
1509
1517
|
* @type {number}
|
|
1510
1518
|
*/
|
|
1511
|
-
version: '3.
|
|
1519
|
+
version: '3.6.0',
|
|
1512
1520
|
dependencies: {
|
|
1513
|
-
zrender: '3.
|
|
1521
|
+
zrender: '3.5.0'
|
|
1514
1522
|
}
|
|
1515
1523
|
};
|
|
1516
1524
|
|
|
@@ -1577,9 +1585,21 @@ define(function (require) {
|
|
|
1577
1585
|
+ echarts.dependencies.zrender + '+'
|
|
1578
1586
|
);
|
|
1579
1587
|
}
|
|
1588
|
+
|
|
1580
1589
|
if (!dom) {
|
|
1581
1590
|
throw new Error('Initialize failed: invalid dom.');
|
|
1582
1591
|
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
var existInstance = echarts.getInstanceByDom(dom);
|
|
1595
|
+
if (existInstance) {
|
|
1596
|
+
if (__DEV__) {
|
|
1597
|
+
console.warn('There is a chart instance already initialized on the dom.');
|
|
1598
|
+
}
|
|
1599
|
+
return existInstance;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
if (__DEV__) {
|
|
1583
1603
|
if (zrUtil.isDom(dom)
|
|
1584
1604
|
&& dom.nodeName.toUpperCase() !== 'CANVAS'
|
|
1585
1605
|
&& (
|
|
@@ -1595,8 +1615,12 @@ define(function (require) {
|
|
|
1595
1615
|
chart.id = 'ec_' + idBase++;
|
|
1596
1616
|
instances[chart.id] = chart;
|
|
1597
1617
|
|
|
1598
|
-
dom.setAttribute
|
|
1618
|
+
if (dom.setAttribute) {
|
|
1599
1619
|
dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
dom[DOM_ATTRIBUTE_KEY] = chart.id;
|
|
1623
|
+
}
|
|
1600
1624
|
|
|
1601
1625
|
enableConnect(chart);
|
|
1602
1626
|
|
|
@@ -1644,12 +1668,13 @@ define(function (require) {
|
|
|
1644
1668
|
* @param {module:echarts~ECharts|HTMLDomElement|string} chart
|
|
1645
1669
|
*/
|
|
1646
1670
|
echarts.dispose = function (chart) {
|
|
1647
|
-
if (
|
|
1648
|
-
chart = echarts.getInstanceByDom(chart);
|
|
1649
|
-
}
|
|
1650
|
-
else if (typeof chart === 'string') {
|
|
1671
|
+
if (typeof chart === 'string') {
|
|
1651
1672
|
chart = instances[chart];
|
|
1652
1673
|
}
|
|
1674
|
+
else if (!(chart instanceof ECharts)){
|
|
1675
|
+
// Try to treat as dom
|
|
1676
|
+
chart = echarts.getInstanceByDom(chart);
|
|
1677
|
+
}
|
|
1653
1678
|
if ((chart instanceof ECharts) && !chart.isDisposed()) {
|
|
1654
1679
|
chart.dispose();
|
|
1655
1680
|
}
|
|
@@ -1660,9 +1685,16 @@ define(function (require) {
|
|
|
1660
1685
|
* @return {echarts~ECharts}
|
|
1661
1686
|
*/
|
|
1662
1687
|
echarts.getInstanceByDom = function (dom) {
|
|
1663
|
-
var key
|
|
1688
|
+
var key;
|
|
1689
|
+
if (dom.getAttribute) {
|
|
1690
|
+
key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
|
|
1691
|
+
}
|
|
1692
|
+
else {
|
|
1693
|
+
key = dom[DOM_ATTRIBUTE_KEY];
|
|
1694
|
+
}
|
|
1664
1695
|
return instances[key];
|
|
1665
1696
|
};
|
|
1697
|
+
|
|
1666
1698
|
/**
|
|
1667
1699
|
* @param {string} key
|
|
1668
1700
|
* @return {echarts~ECharts}
|
package/src/helper.js
CHANGED
|
@@ -19,14 +19,7 @@ define(function (require) {
|
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
|
|
24
|
-
* @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
|
|
25
|
-
* @param {Object} [opt]
|
|
26
|
-
* @param {Array.<string>} [opt.defaultNames] Default names to fill not necessary dimensions, like ['value']
|
|
27
|
-
* @param {string} [opt.extraPrefix] Prefix of name when filling the left dimensions.
|
|
28
|
-
* @param {number} [opt.dimCount] If not specified, guess by the first data item.
|
|
29
|
-
* @return {Array.<string>}
|
|
22
|
+
* @see {module:echarts/data/helper/completeDimensions}
|
|
30
23
|
*/
|
|
31
24
|
completeDimensions: require('./data/helper/completeDimensions'),
|
|
32
25
|
|
package/src/layout/barGrid.js
CHANGED
|
@@ -6,29 +6,96 @@ define(function(require) {
|
|
|
6
6
|
var numberUtil = require('../util/number');
|
|
7
7
|
var parsePercent = numberUtil.parsePercent;
|
|
8
8
|
|
|
9
|
+
var STACK_PREFIX = '__ec_stack_';
|
|
10
|
+
|
|
9
11
|
function getSeriesStackId(seriesModel) {
|
|
10
|
-
return seriesModel.get('stack') ||
|
|
12
|
+
return seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
function getAxisKey(axis) {
|
|
14
16
|
return axis.dim + axis.index;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param {Object} opt
|
|
21
|
+
* @param {module:echarts/coord/Axis} opt.axis Only support category axis currently.
|
|
22
|
+
* @param {number} opt.count Positive interger.
|
|
23
|
+
* @param {number} [opt.barWidth]
|
|
24
|
+
* @param {number} [opt.barMaxWidth]
|
|
25
|
+
* @param {number} [opt.barGap]
|
|
26
|
+
* @param {number} [opt.barCategoryGap]
|
|
27
|
+
* @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
|
|
28
|
+
*/
|
|
29
|
+
function getLayoutOnAxis(opt, api) {
|
|
30
|
+
var params = [];
|
|
31
|
+
var baseAxis = opt.axis;
|
|
32
|
+
var axisKey = 'axis0';
|
|
33
|
+
|
|
34
|
+
if (baseAxis.type !== 'category') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var bandWidth = baseAxis.getBandWidth();
|
|
38
|
+
|
|
39
|
+
for (var i = 0; i < opt.count || 0; i++) {
|
|
40
|
+
params.push(zrUtil.defaults({
|
|
41
|
+
bandWidth: bandWidth,
|
|
42
|
+
axisKey: axisKey,
|
|
43
|
+
stackId: STACK_PREFIX + i
|
|
44
|
+
}, opt));
|
|
45
|
+
}
|
|
46
|
+
var widthAndOffsets = doCalBarWidthAndOffset(params, api);
|
|
47
|
+
|
|
48
|
+
var result = [];
|
|
49
|
+
for (var i = 0; i < opt.count; i++) {
|
|
50
|
+
var item = widthAndOffsets[axisKey][STACK_PREFIX + i];
|
|
51
|
+
item.offsetCenter = item.offset + item.width / 2;
|
|
52
|
+
result.push(item);
|
|
53
|
+
}
|
|
20
54
|
|
|
21
|
-
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function calBarWidthAndOffset(barSeries, api) {
|
|
59
|
+
var seriesInfoList = zrUtil.map(barSeries, function (seriesModel) {
|
|
22
60
|
var data = seriesModel.getData();
|
|
23
61
|
var cartesian = seriesModel.coordinateSystem;
|
|
24
|
-
|
|
25
62
|
var baseAxis = cartesian.getBaseAxis();
|
|
26
63
|
var axisExtent = baseAxis.getExtent();
|
|
27
64
|
var bandWidth = baseAxis.type === 'category'
|
|
28
65
|
? baseAxis.getBandWidth()
|
|
29
66
|
: (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
|
|
30
67
|
|
|
31
|
-
var
|
|
68
|
+
var barWidth = parsePercent(
|
|
69
|
+
seriesModel.get('barWidth'), bandWidth
|
|
70
|
+
);
|
|
71
|
+
var barMaxWidth = parsePercent(
|
|
72
|
+
seriesModel.get('barMaxWidth'), bandWidth
|
|
73
|
+
);
|
|
74
|
+
var barGap = seriesModel.get('barGap');
|
|
75
|
+
var barCategoryGap = seriesModel.get('barCategoryGap');
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
bandWidth: bandWidth,
|
|
79
|
+
barWidth: barWidth,
|
|
80
|
+
barMaxWidth: barMaxWidth,
|
|
81
|
+
barGap: barGap,
|
|
82
|
+
barCategoryGap: barCategoryGap,
|
|
83
|
+
axisKey: getAxisKey(baseAxis),
|
|
84
|
+
stackId: getSeriesStackId(seriesModel)
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return doCalBarWidthAndOffset(seriesInfoList, api);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function doCalBarWidthAndOffset(seriesInfoList, api) {
|
|
92
|
+
// Columns info on each category axis. Key is cartesian name
|
|
93
|
+
var columnsMap = {};
|
|
94
|
+
|
|
95
|
+
zrUtil.each(seriesInfoList, function (seriesInfo, idx) {
|
|
96
|
+
var axisKey = seriesInfo.axisKey;
|
|
97
|
+
var bandWidth = seriesInfo.bandWidth;
|
|
98
|
+
var columnsOnAxis = columnsMap[axisKey] || {
|
|
32
99
|
bandWidth: bandWidth,
|
|
33
100
|
remainedWidth: bandWidth,
|
|
34
101
|
autoWidthCount: 0,
|
|
@@ -37,9 +104,9 @@ define(function(require) {
|
|
|
37
104
|
stacks: {}
|
|
38
105
|
};
|
|
39
106
|
var stacks = columnsOnAxis.stacks;
|
|
40
|
-
columnsMap[
|
|
107
|
+
columnsMap[axisKey] = columnsOnAxis;
|
|
41
108
|
|
|
42
|
-
var stackId =
|
|
109
|
+
var stackId = seriesInfo.stackId;
|
|
43
110
|
|
|
44
111
|
if (!stacks[stackId]) {
|
|
45
112
|
columnsOnAxis.autoWidthCount++;
|
|
@@ -49,29 +116,24 @@ define(function(require) {
|
|
|
49
116
|
maxWidth: 0
|
|
50
117
|
};
|
|
51
118
|
|
|
52
|
-
var barWidth = parsePercent(
|
|
53
|
-
seriesModel.get('barWidth'), bandWidth
|
|
54
|
-
);
|
|
55
|
-
var barMaxWidth = parsePercent(
|
|
56
|
-
seriesModel.get('barMaxWidth'), bandWidth
|
|
57
|
-
);
|
|
58
|
-
var barGap = seriesModel.get('barGap');
|
|
59
|
-
var barCategoryGap = seriesModel.get('barCategoryGap');
|
|
60
|
-
|
|
61
119
|
// Caution: In a single coordinate system, these barGrid attributes
|
|
62
120
|
// will be shared by series. Consider that they have default values,
|
|
63
121
|
// only the attributes set on the last series will work.
|
|
64
122
|
// Do not change this fact unless there will be a break change.
|
|
65
123
|
|
|
66
124
|
// TODO
|
|
125
|
+
var barWidth = seriesInfo.barWidth;
|
|
67
126
|
if (barWidth && !stacks[stackId].width) {
|
|
68
127
|
barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
|
|
69
128
|
stacks[stackId].width = barWidth;
|
|
70
129
|
columnsOnAxis.remainedWidth -= barWidth;
|
|
71
130
|
}
|
|
72
131
|
|
|
132
|
+
var barMaxWidth = seriesInfo.barMaxWidth;
|
|
73
133
|
barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
|
|
134
|
+
var barGap = seriesInfo.barGap;
|
|
74
135
|
(barGap != null) && (columnsOnAxis.gap = barGap);
|
|
136
|
+
var barCategoryGap = seriesInfo.barCategoryGap;
|
|
75
137
|
(barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
|
|
76
138
|
});
|
|
77
139
|
|
|
@@ -95,8 +157,11 @@ define(function(require) {
|
|
|
95
157
|
// Find if any auto calculated bar exceeded maxBarWidth
|
|
96
158
|
zrUtil.each(stacks, function (column, stack) {
|
|
97
159
|
var maxWidth = column.maxWidth;
|
|
98
|
-
if (
|
|
160
|
+
if (maxWidth && maxWidth < autoWidth) {
|
|
99
161
|
maxWidth = Math.min(maxWidth, remainedWidth);
|
|
162
|
+
if (column.width) {
|
|
163
|
+
maxWidth = Math.min(maxWidth, column.width);
|
|
164
|
+
}
|
|
100
165
|
remainedWidth -= maxWidth;
|
|
101
166
|
column.width = maxWidth;
|
|
102
167
|
autoWidthCount--;
|
|
@@ -158,6 +223,11 @@ define(function(require) {
|
|
|
158
223
|
|
|
159
224
|
ecModel.eachSeriesByType(seriesType, function (seriesModel) {
|
|
160
225
|
|
|
226
|
+
// Check series coordinate, do layout for cartesian2d only
|
|
227
|
+
if (seriesModel.coordinateSystem.type !== 'cartesian2d') {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
161
231
|
var data = seriesModel.getData();
|
|
162
232
|
var cartesian = seriesModel.coordinateSystem;
|
|
163
233
|
var baseAxis = cartesian.getBaseAxis();
|
|
@@ -244,5 +314,7 @@ define(function(require) {
|
|
|
244
314
|
}, this);
|
|
245
315
|
}
|
|
246
316
|
|
|
317
|
+
barLayoutGrid.getLayoutOnAxis = getLayoutOnAxis;
|
|
318
|
+
|
|
247
319
|
return barLayoutGrid;
|
|
248
320
|
});
|