How to apply gradient color for OLAP Chart series in WPF?
This article explains how to apply gradient colors to series in a Syncfusion WPF OLAP Chart. By using a LinearGradientBrush and can assign it to the series segments Interior to enhance the visual appearance of chart series and improve data differentiation.
Applying gradient fills is useful when highlighting trends or adding visual appeal to analytical dashboards.
Follow these steps to apply gradient colors to OLAP Chart series:
Step 1: Hook the Loaded Event
Register the Loaded event of the OlapChart to apply gradient styling after the chart has been rendered. For more information, refer this getting started documentation
this.olapChart.Loaded += OlapChart_Loaded;
AddHandler Me.olapChart.Loaded, AddressOf OlapChart_Loaded
Step 2: Create and Apply a LinearGradientBrush
In the Loaded event, create a LinearGradientBrush and assign it to each segment of every chart series using the Interior property.
void OlapChart_Loaded (object sender, RoutedEventArgs e)
{
LinearGradientBrush linearGradientBrush =
new LinearGradientBrush(Colors.Red, Colors.Blue, 45.0);
foreach (var series in olapChart.OlapChartArea.Series)
{
foreach (var segment in series.Segments)
{
segment.Interior = linearGradientBrush;
}
}
}
Private Sub OlapChart_Loaded (ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim linearGradientBrush As New LinearGradientBrush(Colors.Red, Colors.Blue, 45.0)
For Each series In olapChart.OlapChartArea.Series
For Each segment In series.Segments
segment.Interior = linearGradientBrush
Next
Next
End Sub
Output
Conclusion
I hope you enjoyed learning how to apply gradient colors to OLAP Chart series in WPF.
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!