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

Draw line annotation on top of first dataset but under second dataset #887

Closed
andy1547 opened this issue May 11, 2023 · 2 comments · Fixed by #889
Closed

Draw line annotation on top of first dataset but under second dataset #887

andy1547 opened this issue May 11, 2023 · 2 comments · Fixed by #889

Comments

@andy1547
Copy link

andy1547 commented May 11, 2023

Currently using the drawTime: beforeDatasetsDraw option to ensure the first dataset is drawn on top of the line annotation (I'm using plugin to draw a y = 0 line).

I'd like to add a second dataset that gets drawn under the line annotation, the use case is that I'm using the fill: 0 option for this dataset so the line annotation should take preference.

The z index order ASC should be:
dataset #2 (using fill up to dataset #1)
line annotation (y = 0)
dataset #1 (not filled, just a line)

Is this possible? I assume the z index option is only in relation to other annotations and nothing to do with datasets.
I'm using chart.js v4.3.0 and v2.2.1 of the plugin.

@stockiNail
Copy link
Collaborator

Is this possible? I assume the z index option is only in relation to other annotations and nothing to do with datasets.

Your assumption is correct, unfortunately for your use case. The annotations are not related to the datasets. Maybe it could be an enhancement, relating the drawTime to the dataset index on top of drawing phase.

@stockiNail
Copy link
Collaborator

@andy1547 FYI I have submitted a PR toi enable the drawtime for a specific dataset index. #889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants