The two methods that convert either data coordinates or data indices into pixel coordinates are the DataIndexToCoord and DataCoordToCoord methods of the ChartGroup object. The DataIndexToCoord method takes a series and point index and returns the client coordinates of the specified data point. The DataCoordToCoord method takes a set of data coordinates and returns a pixel coordinate. These methods are quite similar to the other conversion methods.
DataIndexToCoord Method
The DataIndexToCoord method takes four parameters, and returns a pixel coordinate as seen in the following example:
Dim CoordX, CoordY As Integer
C1Chart1.ChartGroups.Group0.
DataIndexToCoord(ChartSeries, ChartPoint, CoordX, CoordY)
Debug.WriteLine("X Chart Coordinate: " & CoordX.ToString())
Debug.WriteLine("Y Chart Coordinate: " & CoordY.ToString())
•C#
int CoordX=0, CoordY=0;
c1Chart1.ChartGroups.Group0.
DataIndexToCoord(ChartSeries, ChartPoint, ref CoordX, ref CoordY);
Debug.Writeline("X Chart Coordinate: " + CoordX.ToString());
Debug.Writeline("Y Chart Coordinate: " + CoordY.ToString());
DataCoordToCoord Method
The DataCoordToCoord method takes four parameters, and returns a pixel coordinate as seen in the following example:
Dim CoordX, CoordY As Integer
C1Chart1.ChartGroups.Group0._
DataCoordToCoord(DataCordX, DataCoordY, CoordX, CoordY)
Debug.WriteLine("X Chart Coordinate: " & CoordX.ToString())
Debug.WriteLine("Y Chart Coordinate: " & CoordY.ToString())
•C#
int CoordX=0, CoordY=0;
c1Chart1.ChartGroups.Group0.
DataCoordToCoord(DataCordX, DataCoordY, ref CoordX, ref CoordY);
ConsoleDebug.Writeline("X Chart Coordinate: " + CoordX.ToString());
ConsoleDebug.Writeline("Y Chart Coordinate: " + CoordY.ToString());
Sample Project Available
For a complete sample using the DataCoordToCoord method, see the PropGrid or the FExplorer samples located on http://helpcentral.componentone.com/Samples.aspx.