The SetGraphBorder... functions work in Normalized Graph Coordinates (0.0 to 1.0), not Working Coordinates, which are the same as the scale used for the axes.
The Device (or pixel) Coordinate bounds of a text object can be retrieved (AFTER the object is drawn) using the text objects BoundingBox property. The device coordinates can be converted to normalized graph coordinates using the PhysicalCoordinates.ConvertDimension method.
Dimension textdevdim = new Dimension(yAxisLab1.BoundingBox.Width, yAxisLab1.BoundingBox.Height);
Dimension textnormdim = pTransform1.ConvertDimension(ChartObj.NORM_GRAPH_POS, textdevdim, ChartObj.DEV_POS);
double textnormwidth = textnormdim.Width;
Or you can just get the text objects bounding box width, and divide it by the ChartView width.
double textdevwidth = yAxisLab1.BoundingBox.Width; double textnormwidth = textdevwidth / chartVu.Width;
The results should be the same, give or take some rounding error.
|