Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/component/dataZoom/SliderZoomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,13 +994,25 @@ class SliderZoomView extends DataZoomView {
const viewExtend = this._getViewExtent();
const percentExtent = [0, 100];

const handleEnds = this._handleEnds = [brushShape.x, brushShape.x + brushShape.width];
const minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
// Restrict range.
sliderMove(
0,
handleEnds,
viewExtend,
0,
minMaxSpan.minSpan != null
? linearMap(minMaxSpan.minSpan, percentExtent, viewExtend, true) : null,
minMaxSpan.maxSpan != null
? linearMap(minMaxSpan.maxSpan, percentExtent, viewExtend, true) : null
);

this._range = asc([
linearMap(brushShape.x, viewExtend, percentExtent, true),
linearMap(brushShape.x + brushShape.width, viewExtend, percentExtent, true)
linearMap(handleEnds[0], viewExtend, percentExtent, true),
linearMap(handleEnds[1], viewExtend, percentExtent, true)
]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • In this sentence sliderMove(0, this._range, viewExtend, 0, minMaxSpan.minSpan, minMaxSpan.maxSpan);
    the viewExtent is pixel value while this._range is percent value. They do not match.
  • [0, 100] has been defined as a variable above const percentExtent = [0, 100];, thus should use it directly.

Follow what data zoom drag did, the complete code can be:

        const viewExtend = this._getViewExtent();
        const percentExtent = [0, 100];

        const handleEnds = this._handleEnds = [brushShape.x, brushShape.x + brushShape.width];
        const minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
        // Restrict range.
        sliderMove(
            0,
            handleEnds,
            viewExtend,
            0,
            minMaxSpan.minSpan != null
                ? linearMap(minMaxSpan.minSpan, percentExtent, viewExtend, true) : null,
            minMaxSpan.maxSpan != null
                ? linearMap(minMaxSpan.maxSpan, percentExtent, viewExtend, true) : null
        );

        this._range = asc([
            linearMap(handleEnds[0], viewExtend, percentExtent, true),
            linearMap(handleEnds[1], viewExtend, percentExtent, true)
        ]);

        this._updateView();

        this._dispatchZoomAction(false);

this._handleEnds = [brushShape.x, brushShape.x + brushShape.width];

this._updateView();

this._dispatchZoomAction(false);
Expand Down