提交 a237e151 编写于 作者: L lang

Axis coord clamp, axis scale

上级 9acf8388
......@@ -8,9 +8,8 @@ define(function(require) {
type: 'bar',
getInitialData: function (option, ecModel) {
var list = List.fromArray(option.data, 1, this);
return list;
getInitialData: function (option) {
return List.fromArray(option.data, 1, this);
},
defaultOption: {
......
define(function (require) {
});
\ No newline at end of file
......@@ -79,7 +79,8 @@ define(function(require) {
lineCap: 'round',
lineType: lineType
},
z: axisModel.get('z')
z: axisModel.get('z'),
silent: true
}));
},
......@@ -164,7 +165,9 @@ define(function(require) {
style: {
stroke: tickColor,
lineWidth: tickLineWidth
}
},
silent: true,
z: axisModel.get('z')
});
this.group.add(tickEl);
},
......@@ -294,7 +297,9 @@ define(function(require) {
textBaseline: labelTextBaseline
},
rotation: labelRotate * Math.PI / 180,
origin: [x, y]
origin: [x, y],
silent: true,
z: axisModel.get('z')
});
if (needsCheckTextSpace && !labelRotate) {
......@@ -387,7 +392,8 @@ define(function(require) {
lineType: lineType,
lineWidth: lineWidth
},
silent: true
silent: true,
z: axisModel.get('z')
}));
}
},
......@@ -460,7 +466,8 @@ define(function(require) {
style: {
fill: areaColors[i % areaColors.length]
},
silent: true
silent: true,
z: axisModel.get('z')
}));
}
}
......
......@@ -57,21 +57,23 @@ define(function (require) {
/**
* Map a data to coord. Data is the rank if it has a ordinal scale
* @param {number} data
* @param {boolean} clamp
* @return {number}
*/
dataToCoord: function (data) {
dataToCoord: function (data, clamp) {
data = this.scale.normalize(data);
return linearMap(data, [0, 1], this._coordExtent);
return linearMap(data, [0, 1], this._coordExtent, clamp);
},
/**
* Map a coord to data. Data is the rank if it has a ordinal scale
* @param {number} coord
* @param {boolean} clamp
* @return {number}
*/
coordToData: function (coord) {
var t = linearMap(coord, this._coordExtent, [0, 1]);
coordToData: function (coord, clamp) {
var t = linearMap(coord, this._coordExtent, [0, 1], clamp);
return this.scale.scale(t);
},
......
......@@ -7,7 +7,7 @@ define(function(require) {
valueAxis: {
show: true,
zlevel: 0, // 一级层叠
z: 10, // 二级层叠
z: 0, // 二级层叠
gridIndex: 0,
position: 'left', // 位置
name: '', // 坐标轴名字,默认为空
......@@ -65,7 +65,7 @@ define(function(require) {
categoryAxis: {
show: true,
zlevel: 0, // 一级层叠
z: 10, // 二级层叠
z: 0, // 二级层叠
gridIndex: 0,
position: 'bottom', // 位置
name: '', // 坐标轴名字,默认为空
......
......@@ -62,6 +62,7 @@ define(function(require, factory) {
var gridY2 = parsePercent(gridModel.get('y2'), viewportHeight);
var gridWidth = parsePercent(gridModel.get('width'), viewportWidth);
var gridHeight = parsePercent(gridModel.get('height'), viewportHeight);
if (isNaN(gridWidth)) {
gridWidth = viewportWidth - gridX2 - gridX;
}
......@@ -123,7 +124,7 @@ define(function(require, factory) {
zrUtil.each(this._axesList, function (axis) {
var otherAxis = axis.otherAxis;
if (axis.onZero && otherAxis.type !== 'category') {
axis.otherCoord = otherAxis.dataToCoord(0);
axis.otherCoord = otherAxis.dataToCoord(0, true);
}
});
},
......@@ -235,7 +236,9 @@ define(function(require, factory) {
axisData = axisDataMap[cartesian.name] = {
x: [],
y: [],
cartesian: cartesian
cartesian: cartesian,
xModel: ecModel.getComponent('xAxis', xAxisIndex),
yModel: ecModel.getComponent('yAxis', yAxisIndex)
};
}
......@@ -264,9 +267,15 @@ define(function(require, factory) {
var xAxis = cartesian.getAxis('x');
var yAxis = cartesian.getAxis('y');
if (axisData.x.length) {
if (axisData.xModel.get('scale')) {
axisData.x.push(0);
}
xAxis.scale.setExtentFromData(axisData.x);
}
if (axisData.y.length) {
if (axisData.yModel.get('scale')) {
axisData.y.push(0);
}
yAxis.scale.setExtentFromData(axisData.y);
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册