提交 66125488 编写于 作者: L lang

Fix bug when ordinal scale only has one data

上级 4ed2b265
......@@ -101,7 +101,6 @@ define(function (require) {
var group = this.group;
this._data.each(function (dataItem) {
var el = dataItem.__el;
el.stopAnimation();
el.animateTo({
scale: [0, 0]
}, 200, 'cubicOut', function () {
......
......@@ -39,14 +39,6 @@ define(function(require) {
// Initialization animation
if (!this._data) {
var removeClipPath = zrUtil.bind(group.removeClipPath, group);
var clipPath = isCoordinateSystemPolar
? this._createPolarClipShape(coordinateSystem, api, removeClipPath)
: this._createGridClipShape(coordinateSystem, api, removeClipPath);
group.setClipPath(clipPath);
var polyline = new api.Polyline({
shape: {
points: points
......@@ -59,6 +51,14 @@ define(function(require) {
)
});
var removeClipPath = zrUtil.bind(polyline.removeClipPath, polyline);
var clipPath = isCoordinateSystemPolar
? this._createPolarClipShape(coordinateSystem, api, removeClipPath)
: this._createGridClipShape(coordinateSystem, api, removeClipPath);
polyline.setClipPath(clipPath);
group.add(polyline);
this._polyline = polyline;
......
......@@ -161,15 +161,15 @@ define(function (require) {
getBands: function () {
var extent = this._extent;
var bands = [];
var len = this.scale.count() + 1;
var len = this.scale.count();
var start = extent[0];
var end = extent[1];
var size = end - start;
for (var i = 1; i <= len; i++) {
for (var i = 0; i < len; i++) {
bands.push([
size * (i - 1) / len + start,
size * i / len + start
size * i / len + start,
size * (i + 1) / len + start
]);
}
return bands;
......
......@@ -5,6 +5,7 @@
* http://en.wikipedia.org/wiki/Level_of_measurement
*/
// FIXME only one data
define(function (require) {
/**
......@@ -37,6 +38,10 @@ define(function (require) {
*/
normalize: function (val) {
var extent = this._extent;
// Only one data
if (extent[1] === extent[0]) {
return extent[0];
}
return (val - extent[0]) / (extent[1] - extent[0]);
},
......@@ -112,7 +117,7 @@ define(function (require) {
* @return {number}
*/
count: function () {
return this._extent[1] - this._extent[0];
return this._extent[1] - this._extent[0] + 1;
},
/**
......
......@@ -22,7 +22,7 @@ define(function (require) {
var sub = domain[1] - domain[0];
if (sub === 0) {
return val;
return domain[0];
}
var t = (val - domain[0]) / sub;
if (clamp) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册