We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

custom brushes

How can I bind the CustomBrushes of a pie chart to a collection of brushes that are populated programmatically?

 

In other words, in the code behind, I want to be able to dynamically construct a collection of brushes, and then have those bound to the chart's color model similar to this:

<chart:ChartColorModel CustomBrushes="{Binding MyBrushes}" />


6 Replies

SS Sheik Syed Abthaheer M Syncfusion Team May 23, 2013 11:29 AM UTC

Hi Powers,

Thanks for using Syncfusion products.

We have analyzed your query and you can able to bind the collection of custom brushes in Chart series color model. We have prepared the sample based on your requirement. Please download it from the given below location.

Please let us know if you have any queries.

Regards,

M. Sheik



WinRTPieColorModelDemo_6567a8f4.zip


RS Rob Skoon July 1, 2013 07:54 PM UTC

I'm unable to download this sample due to the website being under maintenance, but am seeing a similar failure.  I am trying to do the following from code behind though to repro the problem:

ChartColorModel palette = new ChartColorModel();   

palette.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)));
palette.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)));
palette.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)));
palette.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 0, 255)));
palette.CustomBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 255, 255)));

sfChartPieType.Palette = ChartColorPalette.Custom;
sfChartPieType.ColorModel = palette;

Am I missing / thinking about how this works wrong?




SS Sheik Syed Abthaheer M Syncfusion Team July 2, 2013 11:13 AM UTC

Hi Rob,

Thanks for using Syncfusion products.

We have analyzed your query and we are unable to reproduce any issue at our end. Also we would like to inform you that the line of given code is the right way for applying CustomBrush to the ChartSeries. We have prepared the sample by using the same line of code based on your update. Please download the sample from the given below location.

Please let us know if you have any queries.

Regards,
M. Sheik


WinRTPieChatColorModelDemo_c85cb69c.zip


RS Rob Skoon July 2, 2013 06:13 PM UTC

OK...  that works.  You were setting the custom palette on the series, not the chart itself. 


So that works and solves my problem for a PieChart that only has one series, where are you supposed to set it on a LineChart that has multiple series?



SS Sheik Syed Abthaheer M Syncfusion Team July 4, 2013 08:46 AM UTC

Hi Rob,

Thanks for your update.

We request to set Custom palette on Chart in order to apply Custom brush in Multiple Series as shown in the given below code snippet.

Code Snippet[C#]:
 _chart.Palette = ChartColorPalette.Custom;
  _chart.ColorModel = palette;

We have prepared the sample based on your requirement. Please download the sample in the given below location.

Sample :

Note: If you want to apply Custom Brushes for different Segment of  Series then we need to set Custom Palette on ChartSeries(like Accumulation Chart types).
Otherwise if you want to apply Custom Brushes for different Series of a Chart then we need to set Custom Palette on Chart. In case of accumulation series like Pie Chart, Palette can be applied for different segments only.

Please let us know if you have any queries.

Regards,
M. Sheik


LineChartColorModelDemo_9a63f34d.zip


RS Rob Skoon July 8, 2013 11:42 PM UTC

Thanks


Loader.
Live Chat Icon For mobile
Up arrow icon