question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to draw a line behind a Point in v3.0.11-beta

See original GitHub issue

Expected Behavior

When using a mouseLine plugin I would expect that the line appears behind the dot/pointer when it is active. Screenshot 2021-03-18 at 10 37 06

Current Behavior

The drawn line appears above the pointer like so Screenshot 2021-03-18 at 09 54 01

Steps to Reproduce

I’ve got a working comparison between v2 and v3 below, all that’s really changed in the plugin is the different references to the chart object needed to draw the line.

Issue in v3 https://codepen.io/stugoo/pen/Rwozbyd

Issue not present in v2.9 https://codepen.io/stugoo/pen/WNoBVML?editors=1010

Context

I recently upgraded ChartJS to version 2.9.4 to patch the security hole. I’m also using the chartjs-annotations-plugin which is not compatible with 2.9.4, so not wanting to revert a security patch I am upgrading our application to use ChartJS v3 beta.

I had a look at doing this as a custom Chart type but I was unable to get the line to draw behind the Point as it was in v2.9.4

Environment

  • Chart.js version: 3.0.0.11.beta
  • Browser name and version: Chrome

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stugoocommented, Mar 19, 2021

@kurkle this works perfectly for my use case. Thank you so much! Awesome support and a great library, appreciate all the work you’re doing on the v3 build. Also thanks to @etimberg for your input also.

Happy to mark this issue as resolved. 😄

0reactions
kurklecommented, Mar 19, 2021

That is actually quite a lot easier solution. It will not work with semi-transparency properly, because the element is drawn multiple times, but if using solid colors, its fine.

You can redraw the active elements easily after the line:

chart.getActiveElements().forEach(el => el.element.draw(ctx));

https://codepen.io/kurkle/pen/dyOBgVm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Draw or delete a line or connector
Draw a line with connection points · On the Insert tab, in the Illustrations group, click Shapes. Insert Shapes button · Under Lines,...
Read more >
How to draw a line in the simplest way in swift
Try looking into UIBezierPath, it will help you a lot for drawing lines. Here is documentation. Here is an example: override func drawRect(rect:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found