提交 d15a9d9e 编写于 作者: L lang

Axis position adjustment

上级 ed21055f
......@@ -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
}
});
......
......@@ -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),
......
......@@ -9,6 +9,7 @@
html, body, #main {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<div id="main"></div>
......@@ -133,7 +134,6 @@
{
name : '降雨量(mm)',
type : 'value',
position: 'right',
inverse: true
}
],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册