Skip to content

Commit

Permalink
fix(radar): optimize ticks calculation when min/max is not defined.
Browse files Browse the repository at this point in the history
Fix value may excced min caused by #11841
  • Loading branch information
pissang committed Feb 20, 2020
1 parent 91ee3b5 commit 5d93759
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/coord/radar/Radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Radar.prototype.update = function (ecModel, api) {
var fixedMax = axisModel.getMax();
var interval = scale.getInterval();


if (fixedMin != null && fixedMax != null) {
// User set min, max, divide to get new interval
scale.setExtent(+fixedMin, +fixedMax);
Expand Down Expand Up @@ -230,13 +231,10 @@ Radar.prototype.update = function (ecModel, api) {
if (nicedSplitNumber > splitNumber) {
interval = increaseInterval(interval);
}
// PENDING
var center = Math.ceil((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
var halfSplitNumber = Math.round(splitNumber / 2);
scale.setExtent(
numberUtil.round(center - halfSplitNumber * interval),
numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
);
// TODO
var max = Math.ceil(rawExtent[1] / interval) * interval;
var min = numberUtil.round(max - interval * splitNumber);
scale.setExtent(min, max);
scale.setInterval(interval);
}
});
Expand Down

0 comments on commit 5d93759

Please sign in to comment.