提交 d15a9d9e 编写于 作者: L lang

Axis position adjustment

上级 ed21055f
...@@ -50,9 +50,7 @@ define(function(require) { ...@@ -50,9 +50,7 @@ define(function(require) {
defaultOption: { defaultOption: {
type: 'category', type: 'category',
gridIndex: 0, gridIndex: 0
position: 'bottom'
} }
}); });
...@@ -71,9 +69,7 @@ define(function(require) { ...@@ -71,9 +69,7 @@ define(function(require) {
defaultOption: { defaultOption: {
type: 'value', type: 'value',
gridIndex: 0, gridIndex: 0
position: 'left'
} }
}); });
......
...@@ -116,8 +116,12 @@ define(function(require, factory) { ...@@ -116,8 +116,12 @@ define(function(require, factory) {
* @private * @private
*/ */
gridProto._initCartesian = function (gridModel, ecModel, api) { gridProto._initCartesian = function (gridModel, ecModel, api) {
var leftUsed = false; var axisPositionUsed = {
var bottomUsed = false; left: false,
right: false,
top: false,
bottom: false
};
var axesMap = { var axesMap = {
x: {}, x: {},
...@@ -189,9 +193,26 @@ define(function(require, factory) { ...@@ -189,9 +193,26 @@ define(function(require, factory) {
return; return;
} }
var axisPosition = axisType === 'x' var axisPosition = axisModel.get('position');
? axisModel.get('position') || (bottomUsed ? 'top' : 'bottom') if (axisType === 'x') {
: axisModel.get('position') || (leftUsed ? 'right' : 'left'); // 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( var axis = new Axis2D(
axisType, axisHelper.createScaleByModel(axisModel), axisType, axisHelper.createScaleByModel(axisModel),
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
html, body, #main { html, body, #main {
width: 100%; width: 100%;
height: 100%; height: 100%;
margin: 0;
} }
</style> </style>
<div id="main"></div> <div id="main"></div>
...@@ -133,7 +134,6 @@ ...@@ -133,7 +134,6 @@
{ {
name : '降雨量(mm)', name : '降雨量(mm)',
type : 'value', type : 'value',
position: 'right',
inverse: true inverse: true
} }
], ],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册