brijess75 Posted July 2, 2009 Report Share Posted July 2, 2009 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 Quote Link to comment Share on other sites More sharing options...
rocioZ Posted July 2, 2009 Report Share Posted July 2, 2009 Please try the following lines of code: chart1.ToolTips = true ; const string maskString = "Value: " + "%v" + "\nThis is my text "; chart1.ToolTipFormat = maskString; Hope this helps. Quote Link to comment Share on other sites More sharing options...
brijess75 Posted July 6, 2009 Author Report Share Posted July 6, 2009 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: 1310132015191510 For each of these X Axis Labels, the tooltip will be like this: 1310-my line1320-your line1519-his line1510-her line Is there a way to do this? Thanks, Brijess Quote Link to comment Share on other sites More sharing options...
RandyJ Posted July 27, 2009 Report Share Posted July 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.