I am trying to draw a line at y = 20, using some sample code I saw for a bar chart, however, e.Grid["X"] is always null.
How do I solve this?
{
//gets the X and Y axis
IAdvanceAxis y = (IAdvanceAxis)e.Grid["Y"];
//checks if axis exist
//figures out the coordinate to draw
//a line at y=100
int yVal = (int)y.Map(target);
int xEnd = (int)x.Map(50);
e.SceneGraph.Add(l);
}
#endregion
if you're using a Composite Chart, you might need to reference the axes using an expression like
this.ultraChart1.CompositeChart.ChartLayers[0].ChartLayer.Grid["X"]
It's actually just a LineChart, not a composite chart.
come to think of it, the only time i've seen that occur is when the data is invalid and no chart is being rendered. what happens if you handle the exception?
Could it be calling fill scene before any data had arrived? When I first start, the graph has no data/series, later data is added
Non-composite charts with no data won't have any axes and FillSceneGraph event will fire since the chart still has to render the main chart box, the warning message, etc. However, it will fire again when the data is supplied to the chart. In fact, it will fire every time the chart is refreshed. Can you perhaps provide a sample project or steps to reproduce this?
Ah, thanks, that was it. It worked the second time through, I hadn't realized it fired more than once. Appreciate it.