in

Software FX Community

Discuss and find help for all Software FX products.

Tooltips for the X axis

Last post 07-27-2009 5:45 PM by RandyJ. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-02-2009 4:25 PM

    Tooltips for the X axis

     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

    Filed under: ,
  • 07-02-2009 4:48 PM In reply to

    Re: Tooltips for the X axis

    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.

  • 07-06-2009 8:49 AM In reply to

    Re: Tooltips for the X axis

    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[i].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

    Filed under: ,
  • 07-27-2009 5:45 PM In reply to

    Re: Tooltips for the X axis

    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

     

Page 1 of 1 (4 items)
Copyright 2008 Software FX, Inc.