diff --git a/src/coord/cartesian/AxisModel.js b/src/coord/cartesian/AxisModel.js index 11df64f57b5d941c03f9bb1cd1f45c579c3d07f7..52e156453e74cc5148d7d16914bc3e923d44c2a7 100644 --- a/src/coord/cartesian/AxisModel.js +++ b/src/coord/cartesian/AxisModel.js @@ -50,9 +50,7 @@ define(function(require) { defaultOption: { type: 'category', - gridIndex: 0, - - position: 'bottom' + gridIndex: 0 } }); @@ -71,9 +69,7 @@ define(function(require) { defaultOption: { type: 'value', - gridIndex: 0, - - position: 'left' + gridIndex: 0 } }); diff --git a/src/coord/cartesian/Grid.js b/src/coord/cartesian/Grid.js index 977ee1a676c8f357eb40ae690d06b8d4525f8588..9bcd7968c816975a993f5e98948f0f14023c3277 100644 --- a/src/coord/cartesian/Grid.js +++ b/src/coord/cartesian/Grid.js @@ -116,8 +116,12 @@ define(function(require, factory) { * @private */ gridProto._initCartesian = function (gridModel, ecModel, api) { - var leftUsed = false; - var bottomUsed = false; + var axisPositionUsed = { + left: false, + right: false, + top: false, + bottom: false + }; var axesMap = { x: {}, @@ -189,9 +193,26 @@ define(function(require, factory) { return; } - var axisPosition = axisType === 'x' - ? axisModel.get('position') || (bottomUsed ? 'top' : 'bottom') - : axisModel.get('position') || (leftUsed ? 'right' : 'left'); + var axisPosition = axisModel.get('position'); + if (axisType === 'x') { + // Fix position + if (axisPosition !== 'top' || axisPosition !== 'bottom') { + axisPosition = 'bottom'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'top' ? 'bottom' : 'top'; + } + } + else { + // Fix position + if (axisPosition !== 'left' || axisPosition !== 'right') { + axisPosition = 'left'; + } + if (axisPositionUsed[axisPosition]) { + axisPosition = axisPosition === 'left' ? 'right' : 'left'; + } + } + axisPositionUsed[axisPosition] = true; var axis = new Axis2D( axisType, axisHelper.createScaleByModel(axisModel), diff --git a/test/area2.html b/test/area2.html index ead0b180ac2f86c15be8de20a4004875ef0eae5c..73beb6807c72a9544beb4533b33e97275f730a80 100644 --- a/test/area2.html +++ b/test/area2.html @@ -9,6 +9,7 @@ html, body, #main { width: 100%; height: 100%; + margin: 0; }
@@ -133,7 +134,6 @@ { name : '降雨量(mm)', type : 'value', - position: 'right', inverse: true } ],