Pie Chart - SegmentColorPath

Dear Concern,

Please let us know how to set custom color for segments using "SegmentColorPath" property in Pie Chart.

As you see in the attachement, i need segment color to same for all 'unallocated space'. i.e, i need set the segment color based on the model property value.

It would be very helpful, if you can respond as soon as possible.

Thanks & Regards,

Tirumal K

Attachment: Capture_c03a1d3c.zip

1 Reply

DS Durgadevi Selvaraj Syncfusion Team January 25, 2018 04:37 AM UTC

Hi Tirumaleswara, 
  
Thanks for contacting Syncfusion Support. 
  
You can achieve this requirement(displaying category with same color) by specifying desired color to the segment in ViewModel and access it through the property “SegmentColorPath” of chart series as like in the below code snippet, 
  
Code Snippet[XAML] 
<chart:PieSeries ItemsSource="{Binding Data}" SegmentColorPath="SegmentColor" 
                             LegendIcon="Triangle" XBindingPath="XValue" YBindingPath="YValue"> 
  
  
Code Snippet[ViewModel.cs] 
public class ViewModel 
{ 
        public ObservableCollection<Model> Data { get; set; } 
  
        public ViewModel() 
        { 
            Data = new ObservableCollection<Model>(); 
  
            Data.Add(new Model() { XValue = "Part1", YValue = 3, SegmentColor = new SolidColorBrush(Colors.LawnGreen) }); 
            Data.Add(new Model() { XValue = "UnallocatedSpace", YValue = 4, SegmentColor = new SolidColorBrush(Colors.DeepPink) }); 
            Data.Add(new Model() { XValue = "Partition5", YValue = 2, SegmentColor = new SolidColorBrush(Colors.Cyan) }); 
            Data.Add(new Model() { XValue = "UnallocatedSpace", YValue = 6.9, SegmentColor = new SolidColorBrush(Colors.DeepPink) }); 
        } 
} 
  
Please find the output screenshot below, 
 
  
The reference sample can be downloaded from below location, 
  
Also, you can refer our UG documentation link to know more about this property, 
  
Regards,  
Durgadevi S 


Loader.
Up arrow icon