How to change the series color in the OLAP Chart?
This article explains how to change the series color in a Syncfusion WPF OLAP Chart. By applying a custom brush to the chart segments Interior, you can control the appearance of series and enhance the visual distinction between data points.
Customizing series colors is useful for branding, improving readability, or emphasizing specific data trends in analytical dashboards.
Follow these steps to change the series color in the WPF OLAP Chart:
Step 1: Configure the OLAP Data Manager
Initialize the OlapDataManager, set the OLAP report, and attach the Loaded event to apply the series color customization after the chart loads. For more information, refer this getting started documentation.
public MainWindow()
{
InitializeComponent();
this.olapChart.OlapDataManager =
new Syncfusion.Olap.Manager.OlapDataManager(
"Data Source=https://bi.syncfusion.com/olap/msmdpump.dll;" +
"Initial Catalog=Adventure Works DW 2008 SE;");
this.olapChart.OlapDataManager.SetCurrentReport(SampleReport());
this.olapChart.Loaded += OlapChart_Loaded;
}
Public Sub New()
InitializeComponent()
Me.olapChart.OlapDataManager =
New Syncfusion.Olap.Manager.OlapDataManager(
"Data Source=https://bi.syncfusion.com/olap/msmdpump.dll;" &
"Initial Catalog=Adventure Works DW 2008 SE;")
Me.olapChart.OlapDataManager.SetCurrentReport(SampleReport())
AddHandler Me.olapChart.Loaded, AddressOf OlapChart_Loaded
End Sub
Step 2: Apply a Custom Color to the Series
In the Loaded event, create a SolidColorBrush and assign it to the Interior property of each chart segment across all series.
void OlapChart_Loaded(object sender, RoutedEventArgs e)
{
SolidColorBrush solidColorBrush = new SolidColorBrush
{
Color = Color.FromArgb(255, 0, 0, 255) // Blue color
};
foreach (var series in this.olapChart.Series)
{
foreach (var segment in series.Segments)
{
segment.Interior = solidColorBrush;
}
}
}
Private Sub OlapChart_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim solidColorBrush As New SolidColorBrush()
solidColorBrush.Color = Color.FromArgb(255, 0, 0, 255)
For Each series In Me.olapChart.Series
For Each segment In series.Segments
segment.Interior = solidColorBrush
Next
Next
End Sub
Output
Conclusion
I hope you enjoyed learning how to change the series color in the WPF OLAP Chart.
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!