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

[Feature] Allow callback functions to access the scale extents #20035

Open
mlvn23 opened this issue Jun 15, 2024 · 1 comment
Open

[Feature] Allow callback functions to access the scale extents #20035

mlvn23 opened this issue Jun 15, 2024 · 1 comment
Labels
en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature. waiting-for: author

Comments

@mlvn23
Copy link

mlvn23 commented Jun 15, 2024

What problem does this feature solve?

I'm working on an OHLC/Candlestick chart, and it looks like I need to use the category axis to avoid the gaps. I wanted to implement a custom xAxis tick and labeler so that the ticks are demarcated, not based on random dates/times produced by the no label overlap algo, but on major logical points like start of the month, start of the year, start of the hour, etc like these:

image
image

For me to implement a sophisticated labeler / ticker function, I need to know what is the current data that's show in the chart. There's no API for this as far as I know, and I had to resort to a hack like this:

let [startIdx, endIdx] = myChart._chartsViews[0].__model.coordinateSystem._axes.x.scale._extent;

I did try the datazoomEvent, but the labeler / ticker function fires first, so I can't use it.

What does the proposed API look like?

I'm proposing to add an extra object parameter in the callback function of axisTick.interval and axisLabel.interval that includes information that helps in creating sophisticated ticker / labelers:

(index:number, value: string, params: Object) => boolean

Same goes for axisLabel.formatter:

(value: string, index: number, params: Object) => string

The params Object will include information that would let us derive which span of data is currently shown.

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Jun 15, 2024
@mlvn23 mlvn23 changed the title [Feature] Allow callback functions to access the scala extents [Feature] Allow callback functions to access the scale extents Jun 18, 2024
@Ovilia
Copy link
Contributor

Ovilia commented Jun 18, 2024

See if this PR helps: #19919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature. waiting-for: author
Projects
None yet
Development

No branches or pull requests

2 participants