Jump to content
Software FX Community

Tooltips for the X axis


brijess75
 Share

Recommended Posts

 I was wondering if there is a way to make the tooltip for axisX different from the label that is displayed.  I found a way to do it using the KeyLabels option, but I do not want the information added to the legend like this option does.  I am labeling axisX with numbers (like "2510") and when the user hovers over the label, I would like the tooltip that pops up to show "2510-This is my text".  Is there a way to do this and if so, how?

 

Thanks,brijess

Link to comment
Share on other sites

Thank you very much for your response. What you provided does work, but for the data point tooltips, not the X Axis.  I already have tooltips setup for the data points using the code below.

string tooltipText = "";
tooltipText = Convert.ToString(r.ItemArray[0]);
tooltipText += "\r\n" + Convert.ToString(t.Columns.ColumnName);
tooltipText += "\r\n" + Convert.ToString(value);
chartFX.Points[iRow, i - 1].Text = tooltipText;
chartFX.ToolTipFormat = "%L";

 

What I need is a way to have my tooltips on my data points as well as tooltips for the Labels on my X Axis.  When the user hovers over the label on the X Axis, they should see a tooltip consisting of a unique number, a dash and the name for that unique number while the actual label on the X Axis will only show the unique number.  For instance, my chart will have X Axis labels of the following:

1310
1320
1519
1510

For each of these X Axis Labels, the tooltip will be like this:

1310-my line
1320-your line
1519-his line
1510-her line

Is there a way to do this?

Thanks,

Brijess

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

Unfortunately, a built-in feature to specify a different tooltip for axis labels is not included. However as a workaround you can achieve the expected behavior by using the GetTip and MouseMove events.

What you should do is simply store X and Y in the MouseMove event and then, during GetTip call HitTest with these values to determine the closest label. The following code snippet illustrates how to do this:

private int m_lastMouseX,m_lastMouseY;private void chart1_MouseMove (object sender,HitTestEventArgs e){  m_lastMouseX = e.X;  m_lastMouseY = e.Y;}

private void chart1_GetTip (object sender,GetTipEventArgs e) {  HitTestEventArgs a = chart1.HitTest(m_lastMouseX,m_lastMouseY);  if ((a.HitType == HitType.Axis) && (a.Object == chart1.AxisX)) {   int closestLabel = (int) Math.Round(a.Value);   e.Text = "Long Label " + closestLabel.ToString();  }}

Regards,

RandyJ

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...