提交 86031591 编写于 作者: P pah100

fix: (1) time scale none pointer when legend. (2) modify grid no data show: 0 is on left bottom

上级 03614c01
......@@ -165,18 +165,20 @@ define(function (require) {
var extent = this._extent;
// If extent start and end are same, expand them
if (extent[0] === extent[1]) {
if (extent[0] !== 0) {
// Expand extent
var expandSize = extent[0] / 2 || 1;
var expandSize = extent[0] / 2;
extent[0] -= expandSize;
extent[1] += expandSize;
}
else {
extent[1] = 1;
}
}
// If there are no data and extent are [Infinity, -Infinity]
if (extent[1] === -Infinity && extent[0] === Infinity) {
extent[0] = 0;
extent[1] = 1;
extent[0] = -1;
this._niceExtent = [-1, 1];
this._interval = 0.5;
return;
}
this.niceTicks(approxTickNum, fixMin, fixMax);
......
......@@ -14,6 +14,7 @@ define(function (require) {
var mathCeil = Math.ceil;
var mathFloor = Math.floor;
var ONE_DAY = 3600000 * 24;
// FIXME 公用?
var bisect = function (a, x, lo, hi) {
......@@ -93,6 +94,35 @@ define(function (require) {
return format(stepLvl[0], date);
},
// Overwrite
niceExtent: function (approxTickNum, fixMin, fixMax) {
var extent = this._extent;
// If extent start and end are same, expand them
if (extent[0] === extent[1]) {
// Expand extent
extent[0] -= ONE_DAY;
extent[1] += ONE_DAY;
}
// If there are no data and extent are [Infinity, -Infinity]
if (extent[1] === -Infinity && extent[0] === Infinity) {
var d = new Date();
extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
extent[0] = extent[1] - ONE_DAY;
}
this.niceTicks(approxTickNum, fixMin, fixMax);
// var extent = this._extent;
var interval = this._interval;
if (!fixMin) {
extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
}
if (!fixMax) {
extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
}
},
// Overwrite
niceTicks: function (approxTickNum) {
approxTickNum = approxTickNum || 10;
......@@ -142,12 +172,12 @@ define(function (require) {
['hh:mm\nMM-dd',2, 3600000 * 2], // 2h
['hh:mm\nMM-dd',6, 3600000 * 6], // 6h
['hh:mm\nMM-dd',12, 3600000 * 12], // 12h
['MM-dd\nyyyy', 1, 3600000 * 24], // 1d
['week', 7, 3600000 * 24 * 7], // 7d
['month', 1, 3600000 * 24 * 31], // 1M
['quarter', 3, 3600000 * 24 * 380 / 4], // 3M
['half-year', 6, 3600000 * 24 * 380 / 2], // 6M
['year', 1, 3600000 * 24 * 380] // 1Y
['MM-dd\nyyyy', 1, ONE_DAY], // 1d
['week', 7, ONE_DAY * 7], // 7d
['month', 1, ONE_DAY * 31], // 1M
['quarter', 3, ONE_DAY * 380 / 4], // 3M
['half-year', 6, ONE_DAY * 380 / 2], // 6M
['year', 1, ONE_DAY * 380] // 1Y
];
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册