User (Legacy) Posted June 5, 2003 Report Share Posted June 5, 2003 I have having a problem where when ever I run the following commands: myChart.AxisX.Min = 0; myChart.AxisX.Max = (int) maxquery.Parameters["@Max"].Value; Left=myChart.AxisX.ValueToPixel(myChart.AxisX.Min); Width=myChart.AxisX.ValueToPixel(myChart.AxisX.Min)- Left Left always comes out to be -500 when it should be arround 55. and Width comes out to be 0 This problem also happens on the Y Axis. I am trying to use this to calculate where to place my annotations. The problem seems to get worse when the calculation is done and the chart is hidden. Link to comment Share on other sites More sharing options...
Software FX Posted June 8, 2003 Report Share Posted June 8, 2003 For performance reasons, all scaling calculations are delayed 'till drawing time so that they are one only once. The UpdateSize method forces this calculation to take place, this will ensure that the scaling values returned are in accordance to what he chart is going to draw, of course these scaling will change if the chart changes size or any property affecting scaling is changed. Annotation object provide and Attach method that allows you to link them to a "logical" position making it unnecessary to make Value-to-pixel conversions. As for your code: Left=myChart.AxisX.ValueToPixel(myChart.AxisX.Min); Width=myChart.AxisX.ValueToPixel(myChart.AxisX.Min)- Left With is always going to be zero, I guess you wanted to do: Left=myChart.AxisX.ValueToPixel(myChart.AxisX.Min); Width=myChart.AxisX.ValueToPixel(myChart.AxisX.Max)- Left I would strongly recommend for using the Attach method instead, this will simplify your code a lot and will provide you with automatic repositioning of objects when he scaling changes (for example when the chart is printed). -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.