From dc344386e96448235094608d25107a939d7a4ee9 Mon Sep 17 00:00:00 2001 From: lang Date: Mon, 22 Feb 2016 13:34:55 +0800 Subject: [PATCH] Line and area dynamic toggling. Fix #2625 --- src/chart/line/LineView.js | 26 +++++++++++++++++++------- src/coord/single/AxisModel.js | 3 +-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/chart/line/LineView.js b/src/chart/line/LineView.js index 09b161c57..00911a95c 100644 --- a/src/chart/line/LineView.js +++ b/src/chart/line/LineView.js @@ -235,17 +235,29 @@ define(function(require) { ) { showSymbol && symbolDraw.updateData(data, isSymbolIgnore); - polyline = this._newPolyline(group, points, coordSys, hasAnimation); + polyline = this._newPolyline(points, coordSys, hasAnimation); if (isAreaChart) { polygon = this._newPolygon( - group, points, - stackedOnPoints, + points, stackedOnPoints, coordSys, hasAnimation ); } lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel)); } else { + if (isAreaChart && !polygon) { + // If areaStyle is added + polygon = this._newPolygon( + points, stackedOnPoints, + coordSys, hasAnimation + ); + } + else if (polygon && !isAreaChart) { + // If areaStyle is removed + lineGroup.remove(polygon); + polygon = this._polygon = null; + } + // Update clipPath if (hasAnimation) { lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel)); @@ -393,11 +405,11 @@ define(function(require) { * @param {Array.>} points * @private */ - _newPolyline: function (group, points) { + _newPolyline: function (points) { var polyline = this._polyline; // Remove previous created polyline if (polyline) { - group.remove(polyline); + this._lineGroup.remove(polyline); } polyline = new polyHelper.Polyline({ @@ -421,11 +433,11 @@ define(function(require) { * @param {Array.>} points * @private */ - _newPolygon: function (group, points, stackedOnPoints) { + _newPolygon: function (points, stackedOnPoints) { var polygon = this._polygon; // Remove previous created polygon if (polygon) { - group.remove(polygon); + this._lineGroup.remove(polygon); } polygon = new polyHelper.Polygon({ diff --git a/src/coord/single/AxisModel.js b/src/coord/single/AxisModel.js index 44e58debe..bec5fb1cd 100644 --- a/src/coord/single/AxisModel.js +++ b/src/coord/single/AxisModel.js @@ -34,8 +34,7 @@ define(function (require) { position: 'bottom', orient: 'horizontal', - - singleIndex: 0, + // singleIndex: 0, axisLine: { show: true, -- GitLab