100pah commented on code in PR #20814:
URL: https://github.com/apache/echarts/pull/20814#discussion_r2000450075
##########
src/component/dataZoom/SliderZoomView.ts:
##########
@@ -999,7 +999,15 @@ class SliderZoomView extends DataZoomView {
linearMap(brushShape.x + brushShape.width, viewExtend,
percentExtent, true)
]);
- this._handleEnds = [brushShape.x, brushShape.x + brushShape.width];
+ // Restrict range.
+ const minMaxSpan =
this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
+
+ sliderMove(0, this._range, viewExtend, 0, minMaxSpan.minSpan,
minMaxSpan.maxSpan);
+
+ this._handleEnds = [
+ linearMap(this._range[0], [0, 100], viewExtend, true),
+ linearMap(this._range[1], [0, 100], viewExtend, true)
+ ];
Review Comment:
- 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:
```js
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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]