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

Inserting into ChartSeriesCollection doesn't update color

Hi,
I'm updating a SfChart that has its Series bound to a ChartSeriesCollection, this works fine when I Add() to the collection, but when I choose to Insert() then the colors of the series are not updated correctly.  For example, if I insert a number of new series at index 0 then they all appear in the first color of the palette.

The reason I'm using Insert is that the series data are calculated in multiple threads and can complete in different orders, so I use Insert to ensure they appear in the correct order.  The Add() or Insert() is done inside a Dispatcher.Invoke() and uses locks to ensure this is not a race condition bug.

Is there anything I can do without resetting the entire collection to get this to update correctly?
Many thanks.

3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team December 21, 2016 10:54 AM UTC

Hi Matt, 
  
Thanks for contacting Syncfusion support. 
  
We have analyzed the reported query. We have achieved your requirement by using GetBrush() of ChartColorModel. We have prepared a demo sample based on your requirement and it can be downloaded from below location, 
  
Sample: ChartColor 
  
Regards, 
Devi 
  





MJ Matt Jones December 21, 2016 11:24 AM UTC

That's great, that solved my problem!
I ended up updating the Interior property for all series in the collection, every time I insert a new series.  This then retained the same colour for each series, regardless of the order they are added/inserted.
Many thanks


DA Devi Aruna Maharasi Murugan Syncfusion Team December 22, 2016 12:05 PM UTC

Hi Matt, 
  
Thanks for your update. 
  
Please let us know, if you need any further assistance on this. 
  
Regards, 
Devi  


Loader.
Live Chat Icon For mobile
Up arrow icon