Hello .I am trying to sum the value of a column chart and then show the sum in a label, I am using the ChartDrawItem but can not seem to make it work. My Label1.text always shows 0, while when I use the debug, I can see that my total is incrementing.
protected void UltraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) {Box box = e.Primitive as Box; if (box == null){ return;}
if (box.DataPoint == null){ return;} Convert.ToDouble(box.Value);}
total+=Convert.ToDouble(box.Value);
protected void UltraChart1_PreRender(object sender, EventArgs e) {Label1.Text =Convert.ToString(Convert.ToDouble(Label1.Text) + Convert.ToDouble(box.Value));}
When I do a debug, it looks like it first goes the prerender event and then to the ChartDrawItem. event Which does not make sense to me.Thanksregards
ChartDrawItem will be called inside the Render phase, so I think PreRender is too early to make this change.
you could either try using the Loaded event of the chart, or perhaps substitute a FillSceneGraph handler for your ChartDrawItem handler. in FillSceneGraph, you can loop through the whole scene, and you would have your total by the end of that loop.
Hi David, thanks for answering,So I tried to use the LoadEvent of the chart but it did not work and if I debug the web-application it goes first to the LoadEvent and then to theChart DrawItem.Also when I use the chartdrawItem, I can see that my total is incrementing, so my issue is not to get the total but to DISPLAY it somewherel.Also I tried the FillSceneGraph event but I have the same problem it cannot display any value out of it.
I made this sample to test it:protected void UltraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e){Label1.Text = "This is an example";}
And my label does not get the text.
Would you have any other suggestions?Thanks again
you could get the FillSceneGraph/ChartDrawItem events to be raised earlier by calling the chart's SaveTo method.
other than that, I don't think there is a way to get data calculated at that point into another ASP.NET control like a label. you could create a Text primitive and add it to the chart's SceneGraph, though.