Skip to content

Commit b604a9f

Browse files
committed
fix(dataZoom): fix dataZoom for single data
relates #16978
1 parent 0b863d1 commit b604a9f

2 files changed

Lines changed: 228 additions & 4 deletions

File tree

src/component/dataZoom/SliderZoomView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ class SliderZoomView extends DataZoomView {
376376
data !== this._shadowData || otherDim !== this._shadowDim
377377
|| size[0] !== oldSize[0] || size[1] !== oldSize[1]
378378
) {
379-
const thisDataExtent = data.getDataExtent(info.thisDim);
379+
const thisScaleExtent = info.thisAxis.scale.getExtent();
380380
let otherDataExtent = data.getDataExtent(otherDim);
381381
// Nice extent.
382382
const otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
@@ -389,8 +389,8 @@ class SliderZoomView extends DataZoomView {
389389

390390
const areaPoints = [[size[0], 0], [0, 0]];
391391
const linePoints: number[][] = [];
392-
const step = thisShadowExtent[1] / (data.count() - 1);
393-
const normalizationConstant = size[0] / (thisDataExtent[1] - thisDataExtent[0]);
392+
const step = thisShadowExtent[1] / (Math.max(1, data.count() - 1));
393+
const normalizationConstant = size[0] / (thisScaleExtent[1] - thisScaleExtent[0]);
394394
const isTimeAxis = info.thisAxis.type === 'time';
395395
let thisCoord = -step;
396396

@@ -407,7 +407,7 @@ class SliderZoomView extends DataZoomView {
407407
}
408408

409409
thisCoord = isTimeAxis
410-
? (+thisValue - thisDataExtent[0]) * normalizationConstant
410+
? (+thisValue - thisScaleExtent[0]) * normalizationConstant
411411
: thisCoord + step;
412412

413413
// FIXME

test/dataZoom-timeAxis.html

Lines changed: 224 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)