Change color of a specify segment of fastcandleseries

Hi,
How to change the color of a specify segment by provide the index of segment in fastcandleseries?
Thanks and best regards,
Andrew

1 Reply 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team November 4, 2020 11:46 AM UTC

Hi Komatora, 
  
Greetings from Syncfusion.

We have analyzed your query and we have achieved your requirement ”Update color each segment Candle series” by inherit the candle series and update the color for each segment. Please refer the below code snippet.
 
  
And for improving the performance only we used FastCandleBitmapSeries and we can’t customize it. Hence, we have achieved used your requirement by using Candle series. 
  
[Code Snippet] 
[C#] 
public class CustomCandleSeries : CandleSeries 
     public List<SolidColorBrush> SegmentColors { get; set; } 
  
     public override void CreateSegments() 
     { 
         base.CreateSegments(); 
  
         for(int i = 0; i<Segments.Count;i++) 
         { 
             var segment = Segments[i]; 
             var canvas = segment.GetRenderedVisual() as Canvas; 
  
             if (canvas is null) return; // before ready  
  
             (canvas.Children[0] as Rectangle).Fill = SegmentColors[i]; 
         } 
     } 
 
  
[Xaml] 
<local:CustomCandleSeries x:Name="customCandleSeries"  
                          High="High" Low="Low" Open="Open" Close="Close"  
                          XBindingPath="XValue"  
                          ItemsSource="{Binding Data}" > 
</local:CustomCandleSeries> 
 
  
[C#] 
  
customCandleSeries.SegmentColors = (this.DataContext as ViewModel).SegmentColor; 
  
 
  
Also, we have prepared the sample for your reference. Please find the sample from the below link. 
  

For more details, please refer the below link.
 
Regards, 
Yuvaraj 


Marked as answer
Loader.
Up arrow icon