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

Trendline z-index is too high #49

Open
Axword opened this issue Mar 12, 2021 · 6 comments
Open

Trendline z-index is too high #49

Axword opened this issue Mar 12, 2021 · 6 comments

Comments

@Axword
Copy link

Axword commented Mar 12, 2021

obraz

I have a problem with z-index of trendline. It covers my tooltip and there is no way of chaning z- index of it (same as for trendline). Is there anything i can do about it?

@zigomir
Copy link

zigomir commented Apr 2, 2021

@Axword

To fix it I had to register ChartTrendline before the Tooltip plugin, ie

Chart.register(
  // ...otherPlugins
  ChartTrendline,
  Tooltip,
  // ...otherPlugins
)

order matters here.

caveat: we're using Chartjs v3 & forked chartjs-plugin-trendline to make it work with Chartjs v3

@Hibrix-net
Copy link

Hibrix-net commented Apr 19, 2021

@Axword

To fix it I had to register ChartTrendline before the Tooltip plugin, ie

Chart.register(
  // ...otherPlugins
  ChartTrendline,
  Tooltip,
  // ...otherPlugins
)

order matters here.

caveat: we're using Chartjs v3 & forked chartjs-plugin-trendline to make it work with Chartjs v3

Hello,

Could you elaborate a little more the answer please? Do we first have to de-register the integrated ChartJS tooltip plugin and then re-register it after the ChartTrendline?

Thanks,

@zigomir
Copy link

zigomir commented Apr 20, 2021

I know nothing about your codebase, but in ours, changing this order helped, i.e. moving ChartTrendline before Tooltip.

Chart.register(
  // ...otherPlugins
- Tooltip,
- ChartTrendline,
+ ChartTrendline,
+ Tooltip,
  // ...otherPlugins
)

Maybe it doesn't work like this in Chartjs v2, I've never used it 🤷‍♂️

@Hibrix-net
Copy link

Hibrix-net commented Apr 20, 2021

Hi,

Thanks for your answer. So I understand you are using a custom tooltip plugin, because as far as I know there's an embedded tooltip plugin within the ChartJS core that can only be enabled/disbled but not registered/unregistered.

Am I missing something here?

I am using the VueJS ChartJS wrapper from here (that btw is using ChartJS version 2.8): https://github.com/apertureless/vue-chartjs

Not sure how to proceed, I already tried some hacks with no luck at all. Any advice will be very welcome.

Best,

@its0xFUL
Copy link

On the topic of z-index, would it be possible to add an option to draw trend line with a lower z index than the graph itself (ie. visually behind)? Can provide a PR if anyone else needs this.

Great plugin btw!

@Bobakanoosh
Copy link

Heads up for anyone else with this issue, I just copied the plugin source to my project (one file) and adjusted it to render on beforeDatasetDraw instead of afterDatasetDraw

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

No branches or pull requests

5 participants