This documentation is archived and is not being maintained.

Chart.Calculate Event

 

Occurs after the Chart control plots new or changed data.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

event ChartEvents_CalculateEventHandler Calculate

The following code example creates a Chart with a handler for the Calculate event that displays a message box when the source data of the chart changes.

private void DisplayWhenCalculated()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");
    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.Calculate +=
        new Excel.ChartEvents_CalculateEventHandler(
        chart1_Calculate);

    // This will raise the Calculate event.
    this.Range["A1"].Value2 = 11;
}

void chart1_Calculate()
{
    MessageBox.Show("The chart plotted new data.");
}
Return to top
Show: