How to reset the OlapChart to initial state in WPF?
This article explains how to reset a Syncfusion WPF OLAP Chart to its initial state at runtime. By clearing the Series, Categorical, and Slicer elements from the OLAP report and rebinding the data, you can restore the chart to its default configuration.
This approach is useful when you need to discard user-applied filters, drill-downs, or dynamic changes and return the chart to its original view.
Follow these steps to reset the WPF OLAP Chart at runtime:
Step 1: Handle the Reset Button Click Event
Create a button in the UI and handle its Click event. Within this event, clear the OLAP report elements and rebind the chart. For more information, refer this getting started documentation
Step 2: Clear OLAP Report Elements and Rebind the Chart
private void Button_Reset_Click(object sender, RoutedEventArgs e)
{
this.olapChart.OlapDataManager.CurrentReport.SeriesElements.Clear();
this.olapChart.OlapDataManager.CurrentReport.CategoricalElements.Clear();
this.olapChart.OlapDataManager.CurrentReport.SlicerElements.Clear();
this.olapChart.DataBind();
}
Private Sub Button_Reset_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Me.olapChart.OlapDataManager.CurrentReport.SeriesElements.Clear()
Me.olapChart.OlapDataManager.CurrentReport.CategoricalElements.Clear()
Me.olapChart.OlapDataManager.CurrentReport.SlicerElements.Clear()
Me.olapChart.DataBind()
End Sub
Output
Before reset:
After reset:
Conclusion
I hope you enjoyed learning how to reset the WPF OLAP Chart to its initial state at runtime.
You can refer to our WPF OlapChart featuretour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF OLAP Chart demo to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!