Legend color Doesn't Match Chart Colors

When I set a custom color for pointColorMapper, the colors correctly reflect on the chart; however, the legends never follow the custom colors. 

Legend colors reflect the default colors (as if I never set any color for the chart and I'm using the default chart's color)



Seems like a bug to me.
I saw a similar post for a different platform here as well. 




Attachment: Sybncfusion_screenshot_ff1c3d64.zip

1 Reply 1 reply marked as answer

DD Dharanidharan Dharmasivam Syncfusion Team November 13, 2020 01:16 PM UTC

Hi Sam, 
  
Greetings from Syncfusion. We have analyzed your requirement. We would like to let you know that when custom color is applied using pointColorMapper, then those color will not be applied to legend and this is our default behavior. You can apply the custom color to legend using the onLegendItemRender event. Find the code snippet to accomplish this. 
  
SfCartesianChart( 
    onLegendItemRender: (LegendRenderArgs args){ 
              if(args.seriesIndex == 0){ 
                args.color = Color.fromRGBO(1, 96, 100, 1); 
              } else { 
                args.color = Color.fromRGBO(239, 108, 0,1); 
              } 
            }, 
) 
 
  
Sample for reference can be found below. 
  
For more information on the callbacks in chart, find the user guide below. 
  
Thanks, 
Dharani. 


Marked as answer
Loader.
Up arrow icon