chartjs tooltips are overlapped by the labels

0
0

Here is a thing, I have a chartJs pie chart and the labels  are overlapping the tool tips. It kinda does work like on screenshots in attachments. The chart is behind the labels otherwise you can’t click the labels. Because of that the tool tip is below them too. But are there any options how to avoid such behavior?

 

Attachment
  • You must to post comments
0
0

Hi Dmitry,

You’ll need to convert the mouse coordinates to be relative to the parent control.  I’m attaching a small sample demonstrating both: a chart inside a panel and a chart without any panel.

To convert the coordinates it would look something like this:

private void chartJS1_Click(object sender, EventArgs e) {

        if (this.myLabel.Bounds.Contains(this.myPanel.PointToClient(Control.MousePosition))) {

                AlertBox.Show("Clicked the label!");
        }
}

Let me know if this helps or you need more clarification!

Best,

Levie

Attachment
  • Dmitry Shevchenko
    Thanks a lot, it helped. The only thing is that now I am struggling on how to make mouse be displayed as pointer for the labels.
  • Levie (ITG)
    I’m glad it helped! I’m not sure I understand what you’re trying to achieve, could you elaborate? Thanks, Levie
  • You must to post comments
0
0

The problem is that Control.MousePosition catches the coordinates that are related to the body of the page. Meanwhile, the labels have coordinates that are related to their Parent, that is chart. Are there any options how to fix this?

  • You must to post comments
0
0

Hi Dmitry,

An easy solution in your case would be to put the labels behind the chart (or panels with labels in them), set the chart’s BackColor opacity setting to 0, and add a click event to your chart with something like the following:

if (this.myLabel.Bounds.Contains(Control.MousePosition))
{
                AlertBox.Show("Clicked the label!");
}

 

If this doesn’t work for you, we can potentially look at other solutions!

Does this help?

Best,

Levie

  • Dmitry Shevchenko
    The problem is that Control.MousePosition catches the coordinates that are related to the body of the page. Meanwhile, the labels have coordinates that are related to their Parent, that is chart. Are there any options how to fix this?
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.