Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
Sum Values in ColumnChart
posted

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.

Thanks
regards

Parents
  • 28496
    Offline posted

    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.

Reply Children