ComponentOne Chart for .NET (2.0) Search HelpCentral 

Converting Data Points into Pixel Coordinates

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:

·      Visual Basic

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());

·      Delphi

var

  CoordX, CoordY: Integer;

 

begin

  C1Chart1.ChartGroups.Group0.

     DataIndexToCoord(ChartSeries, ChartPoint, CoordX, CoordY);

 

  Debug.Writeline('X Chart Coordinate: ' + CoordX.ToString());

  Debug.Writeline('Y Chart Coordinate: ' + CoordY.ToString());

end;

DataCoordToCoord Method

The DataCoordToCoord method takes four parameters, and returns a pixel coordinate as seen in the following example:

·      Visual Basic

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());

·      Delphi

var

  CoordX, CoordY: Integer;

 

begin

  C1Chart1.ChartGroups.Group0.

    DataCoordToCoord(DataCordX, DataCoordY, ref CoordX, ref CoordY);

 

  Debug.Writeline('X Chart Coordinate: ' + CoordX.ToString());

  Debug.Writeline('Y Chart Coordinate: ' + CoordY.ToString());

end;

For a complete sample using this method, see PropGrid or the FExplorer samples located on http://helpcentral.componentone.com/ProductResources.aspx.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.