Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend series colors wrong when pointColorMapper used #114

Closed
jfox454 opened this issue Apr 19, 2020 · 5 comments
Closed

Legend series colors wrong when pointColorMapper used #114

jfox454 opened this issue Apr 19, 2020 · 5 comments

Comments

@jfox454
Copy link

jfox454 commented Apr 19, 2020

When the pointColorMapper is used to change the color of a series, the Legend color is not updated and still appears to use the Color Palette colors.

@SriramKiranSenthilkumar
Copy link
Contributor

Hi @jfox454 ,

Greetings from Syncfusion. We have analyzed your scenario at our end. As of now, the default behavior in cartesian chart is when the point color mapper is used, it doesn’t change the legend color. The circular and triangular chart only have that kind of feature. Can you provide us more information on what type of chart widget are you using? So, that we can provide a solution for your requirement at earlier.

Thanks,

Sriram Kiran

@jfox454
Copy link
Author

jfox454 commented Apr 21, 2020

Hi @SriramKiranSenthilkumar ,
I am using the SfCartesianChart widget.
Thanks
Jack

@SriramKiranSenthilkumar
Copy link
Contributor

Hi @jfox454 ,

As of now, in the cartesian chart widget, the legend colour can't be changed according to the point colour mapper values, since the legend is created for the series only and not for the individual data points of that series. So, this is the default behaviour of the legend in the cartesian chart widget.

Thanks,
Sriram Kiran.

@jfox454
Copy link
Author

jfox454 commented Apr 23, 2020

Are there any plans to update this behaviour so that the legend color is set by the point color mapper for a cartesian chart?

My preference would be to use the point color mapper rather than having to adjust the color palette for each chart.

@SriramKiranSenthilkumar
Copy link
Contributor

Hi @jfox454 ,

No, the legend colour in the cartesian chart is currently set according to the series colour palette prescribed in the chart. This is the default behaviour of the legend as mentioned earlier. It cannot be changed according to the point colour mapper values of the data points because for every individual series in the chart, a single legend is created. For example, we have created a simple sample and provided the screenshot below to explain the behaviour. We have provided two series in the chart in which one series has point colour mapper values mapped for the data points and another series with no pointColorMapper values mapped and with legend enabled for both the series. You can see that for each series in the chart one legend is created. So, it is not possible to map the point colour for the series legend which has point colour mapper mapped to individual data points.

Screenshot:

image

The sample for reference can be found below
sample.zip

You can customize the legend colour for each series individually using the onLegendItemRender event available in the chart. Please refer the below code snippet to achieve it.

SfCartesianChart(
          onLegendItemRender: (LegendRenderArgs args) {
            if(args.seriesIndex == 1) {
              args.color = Colors.yellow;
            }
          },
)

For further reference on onLegendItemRender event, please check the user guide below
https://help.syncfusion.com/flutter/cartesian-charts/callbacks#onlegenditemrender

Thanks,
Sriram Kiran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants