Menu

Show Point Values

Help
Fuzzy
2005-04-24
2012-09-19
  • Fuzzy

    Fuzzy - 2005-04-24

    I am charting a curve (polynomial) an would like to have the point values display automatically for each of the X,Y Coordinates along the curve. By right clicking on the graph, I can get these values to display. However, I have been unsucessful in trying to add these points as text values.

    Any suggessions?

     
    • John Champion

      John Champion - 2005-04-25

      Here's some code that adds point labels to the individual points. You can format the points anyway you like, but in this case it just uses the default PointPair.ToString() formatting. The assumes that your values are in a PointPairList called "list".

      ... All the curve & pane setup stuff goes here ...

      myPane.AxisChange( this.CreateGraphics() );
      // make the labels offset from the point by 1% of scale range
      float xOffset = (float) ( myPane.XAxis.Max - myPane.XAxis.Min ) * 0.01f;
      float yOffset = (float) ( myPane.YAxis.Max - myPane.YAxis.Min ) * 0.01f;

      foreach ( PointPair pt in list )
      {
      string label = pt.ToString();
      TextItem text = new TextItem( label, (float) pt.X + xOffset, (float) pt.Y + yOffset,
      CoordType.AxisXYScale, AlignH.Left, AlignV.Bottom );
      text.FontSpec.Border.IsVisible = false;
      myPane.GraphItemList.Add( text );
      }

      John
      
       

Log in to post a comment.