How to define the fill color for each datapoint in WPF Chart (SfChart)?
Description
The WPF SfChart provides an option to assign custom fill colors to each data point in a chart series in a specified order using the ColorModel property. You can define your own custom color palette for the series by setting the CustomBrushes collection as shown in the below code example.
C#
Viewmodel view = new Viewmodel(); ColumnSeries columnSeries = new ColumnSeries(); columnSeries.ItemsSource = view.SneakersDetail; columnSeries.XBindingPath = "Brand"; columnSeries.YBindingPath = "No_Of_Items"; columnSeries.Palette = ChartColorPalette.Custom; //Adding colorModel to the series ChartColorModel colorModel = new ChartColorModel(); foreach (var item in view.SneakersDetail) view.SeriesColor.Add(item.SegmentColor); colorModel.CustomBrushes = view.SeriesColor; columnSeries.ColorModel = colorModel;
Output
Conclusion
I hope you enjoyed learning about how to vary the custom shapes in WPF Chart.
You can refer to our WPF Chart feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Chart documentation 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!