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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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 );
}