Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataZoom inside with option pinned 'start' 'end' #20829

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/component/dataZoom/DataZoomModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,13 @@ class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends Compon
/**
* Retrieve those raw params from option, which will be cached separately,
* because they will be overwritten by normalized/calculated values in the main
* process.
* process. Get parameter 'anchor' to add option to pin the chart to 'start' or
# 'ene' while using default dataZoom
*/
function retrieveRawOption<T extends DataZoomOption>(option: T) {
const ret = {} as T;
each(
['start', 'end', 'startValue', 'endValue', 'throttle'] as const,
['start', 'end', 'startValue', 'endValue', 'throttle', 'anchor'] as const,
function (name) {
option.hasOwnProperty(name) && ((ret as any)[name] = option[name]);
}
Expand Down
11 changes: 8 additions & 3 deletions src/component/dataZoom/InsideZoomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ const getRangeHandlers: {
) / directionInfo.pixelLength * (range[1] - range[0]) + range[0];

const scale = Math.max(1 / e.scale, 0);
range[0] = (range[0] - percentPoint) * scale + percentPoint;
range[1] = (range[1] - percentPoint) * scale + percentPoint;

// add logic to pin the dataZoom to 'end' or 'start'
var anchor = this.__model?.option?.anchor || null;
if (anchor !== 'start') { // pin zoom to left side of the X axis viewBox
range[0] = (range[0] - percentPoint) * scale + percentPoint;
}
if (anchor !== 'end') { // pin zoom to the right side of the X axis viewBox
range[1] = (range[1] - percentPoint) * scale + percentPoint;
}
// Restrict range.
const minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();

Expand Down