Skip to content

fix(dataZoom): restrict range on brushEnd#20814

Merged
100pah merged 2 commits intoapache:masterfrom
mortalYoung:fix-20807
Mar 18, 2025
Merged

fix(dataZoom): restrict range on brushEnd#20814
100pah merged 2 commits intoapache:masterfrom
mortalYoung:fix-20807

Conversation

@mortalYoung
Copy link
Copy Markdown
Contributor

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

  • minMaxSpan could restrict brushSelect

Fixed issues

fixed #20807

Details

Before: What was the problem?

2025-03-10 18-04-41 2025-03-10 18_05_03

After: How does it behave after the fixing?

2025-03-10 18-03-17 2025-03-10 18_03_47

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

@echarts-bot
Copy link
Copy Markdown

echarts-bot bot commented Mar 10, 2025

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

@github-actions
Copy link
Copy Markdown
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20814@3e741b1

linearMap(this._range[0], [0, 100], viewExtend, true),
linearMap(this._range[1], [0, 100], viewExtend, true)
];

Copy link
Copy Markdown
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);

@100pah 100pah merged commit 9ce6fe4 into apache:master Mar 18, 2025
@echarts-bot
Copy link
Copy Markdown

echarts-bot bot commented Mar 18, 2025

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

@Ovilia Ovilia added this to the 6.0.0 milestone Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] maxSpan cannot restrict the span selected via brush

3 participants