Programming User Interaction > Returning Coordinate Values > Converting Data Coordinates to Pixel Coordinates |
To convert from data coordinates to screen pixel coordinates, call the DataCoordToCoord method. For example, the following code obtains the pixel coordinates corresponding to the data coordinates (5.1, 10.2):
Dim PixelX As Long
Dim PixelY As Long
With Chart2D1.ChartGroups(1)
.DataCoordToCoord 5.1, 10.2, PixelX, PixelY
End With
' PixelX and PixelY now contain the pixel coordinate value
If the data coordinate is out of the visible range of the chart, both of the pixel X- and Y-coordinates are set to -1.