Skip to content

Commit

Permalink
Merge pull request #37 from antvis/feat-startOnZero
Browse files Browse the repository at this point in the history
feat: add startOnZero property for geom.
  • Loading branch information
dxq613 committed Jan 4, 2018
2 parents 00e47f0 + cd6fc7e commit a200e7b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/geom/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ class Geom extends Base {

attrOptions: {},

sortable: false
sortable: false,
/**
* 图形的底边是否从 0 开始,默认为 0,即从 0 开始,
* 否则从最小值开始
* @type {Boolean}
*/
startOnZero: true
};
}

Expand Down Expand Up @@ -529,18 +535,19 @@ class Geom extends Base {

/**
* @protected
* 如果y轴的最小值小于0则返回0,否则返回最小值
* @return {Number} y轴上的最小值
*/
getYMinValue() {
const yScale = this.getYScale();
const min = yScale.min;
let value;
if (min >= 0) {
value = min;

if (this.get('startOnZero')) {
value = min >= 0 ? min : 0;
} else {
value = 0;
value = min;
}

return value;
}

Expand Down

0 comments on commit a200e7b

Please sign in to comment.