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
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.
Hey, have you tried to do the sum before loading the chart, I mean, you pass all the data to the chart from a data source, which at the end could be seen as an array, meaning that you can loop it.
When I need that kind of functionality, I do all the calculations by code, looping and adding, in that way, when you pass the data to the chart you already have the total, so you only pass to the chat the label.
Can you put part of you code to load the chart to help you a little more.
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
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.
I am really losing my hair on this one. I have been looking for the past 2 days through the documentation and the forum but can not get it done.I would really appreciate your help.
Thanks a lot in advance