I created a form that displays a chart using the Microsoft DataVisualization.Charting.Chart (I am using version 4 of the .NET framework). I also draw some annotations on the chart, and to find them I need to know about the axes of the chart.
Code
myChart.ChartAreas[0].AxisX.ValueToPixelPosition(location)
gives a NullReferenceException . The graph is definitely created, and I can set the AxisX properties - for example, myChart.ChartAreas[0].AxisX.Maximum = 1 works fine.
Having folded the exception message, it seems that the problem is with the GetLinearPosition method, which is something internal to the Chart control:
at System.Windows.Forms.DataVisualization.Charting.Axis.GetLinearPosition(Double axisValue) at System.Windows.Forms.DataVisualization.Charting.Axis.GetPosition(Double axisValue) at System.Windows.Forms.DataVisualization.Charting.Axis.ValueToPixelPosition(Double axisValue)
Does anyone have the insight to get me to start this fix? Thanks in advance!
source share