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

chartgradientstop not updating color set to DynamicResource

I have the following XAML as part of a SfChart


<chart:areaseries.colormodel>

<chart:chartcolormodel palette="Custom">

<chart:chartcolormodel.customgradientcolors>

<chart:chartgradientcolor startpoint="0.5,1" endpoint="0.5,0">

<chart:chartgradientcolor.gradientstops>

<chart:chartgradientstop offset=".1" color="{DynamicResource PageSecondaryBackgroundColor}">

<chart:chartgradientstop offset="1" color="{DynamicResource ColorLightBlue}">

</chart:chartgradientstop></chart:chartgradientstop></chart:chartgradientcolor.gradientstops>

</chart:chartgradientcolor>

</chart:chartcolormodel.customgradientcolors>

</chart:chartcolormodel>

</chart:areaseries.colormodel>


The color of the chartgradientstop is set to a DynamicResource. If the DynamicResource is changed during runtime (switching between dark and light mode) the color property doesn't update. All other properties linked to a DynamicResource updates as expected. Maybe someone forgot to wire the binding of the color property?


6 Replies

VT Vimala Thirumalai Kumar Syncfusion Team November 16, 2022 07:11 AM UTC

Hi Jens Woeste,

We would like to let you know that we can achieve your requirement by setting DynamicResource to the CustomGradientColors property of the ChartColorModel. Please find the code snippet and example sample in the attachment for your reference.

<chart:SfChart.Resources>

                    <chart:ChartGradientColorCollection x:Key="gradient">

                        <chart:ChartGradientColor  StartPoint="0.5,1" EndPoint="0.5, 0">

                            <chart:ChartGradientColor.GradientStops>

                                <chart:ChartGradientStop Color="Aqua" Offset= "0"/>

                                <chart:ChartGradientStop Color="#1976D2" Offset= "1"/>

                            </chart:ChartGradientColor.GradientStops>

                        </chart:ChartGradientColor>

                    </chart:ChartGradientColorCollection>

 

                    <chart:ChartGradientColorCollection x:Key="gradient1">

                        <chart:ChartGradientColor  StartPoint="0.5,1" EndPoint="0.5, 0">

                            <chart:ChartGradientColor.GradientStops>

                                <chart:ChartGradientStop Color="Red" Offset= "0"/>

                                <chart:ChartGradientStop Color="Orange" Offset= "1"/>

                            </chart:ChartGradientColor.GradientStops>

                        </chart:ChartGradientColor>

                    </chart:ChartGradientColorCollection>

 </chart:SfChart.Resources>

 

      <chart:AreaSeries.ColorModel>

              <chart:ChartColorModel Palette="Custom" CustomGradientColors="{DynamicResource gradient}"/>

      </chart:AreaSeries.ColorModel>


Regards,

Vimala Thirumalai Kumar.


Attachment: ChartSample_bac72546.zip


JW Jens Woeste November 16, 2022 11:34 AM UTC

It doesn't work.


Another illustration:

add the following to your xaml:

<ContentPage.Resources>

        <ResourceDictionary>

            <Color x:Key="DarkStop">Yellow</Color>

            <Color x:Key="LightStop">Red</Color>

            <Color x:Key="StopColor">Red</Color>

        </ResourceDictionary>

  </ContentPage.Resources>


Now modify the XAML to use DynamicResource StopColor

<chart:ChartGradientColor.GradientStops>

                                <chart:ChartGradientStop Color="{DynamicResource StopColor}" Offset= "0.1"/>

                                <chart:ChartGradientStop Color="#1976D2" Offset= "1"/>

 </chart:ChartGradientColor.GradientStops>


and modify the code behind:

private void Button_Clicked(object sender, EventArgs e)

        {

            //chart.Resources["gradient"] = chart.Resources["gradient1"];

            if(Resources["StopColor"] == Resources["DarkStop"])

                Resources["StopColor"] = Resources["LightStop"];

            else

                Resources["StopColor"] = Resources["DarkStop"];

        }


It seems like the ChartGradientStop property is not bound correctly (INotifyPropertyChanged).

This example works for other color properties.


Thanks


Jens



RR Raja Ramalingam Syncfusion Team December 9, 2022 11:46 AM UTC

Hi Jens Woeste,

Sorry for the inconvenience.

We have confirmed the reported problem as an issue. Please find the feedback report in the below link, and the fix for the reported issue will be included in our upcoming weekly NuGet release, which is expected to roll on December 13, 2022. We will let you know once it gets rolled out.

Feedback: https://www.syncfusion.com/feedback/39331/the-chart-gradient-stops-rendering-incorrectly-and-does-not-respond-to

Note: The provided feedback link is private, and you need to login to view this feedback.


Regards,

Raja.



RR Raja Ramalingam Syncfusion Team December 14, 2022 06:22 AM UTC

Hi Jens Woeste,

Sorry for the inconvenience. Due to some technical issues, we were unable to provide the fix on the December 13th weekly NuGet.

We have prepared the custom NuGet package for the issue reported at the Color property of the ChartGradientStop class, and the patch for this fix can be downloaded from the following location: We have created the patch with Essential Studio version 20.3.0.56.


Please find the patch setup from the below link:

https://syncfusion.com/Installs/support/patch/20.3.0.56/1015592/T423866/SyncfusionPatch_20.3.0.56_1015592_12132022081806046_T423866.zip


Please find the NuGet from the below location:

https://syncfusion.com/Installs/support/patch/20.3.0.56/1015592/T423866/SyncfusionNuget_20.3.0.56_1015592_12132022081806046_T423866.zip


Disclaimer:

Please note that we have created this patch for version 20.3.0.56 specifically to resolve the issue reported in this incident. If you have received other patches for the same version for other products, please apply all patches in the order received.


Please clear the NuGet cache, before using the latest one.

https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache


The fix for the reported issue will be included in our upcoming Volume 4 release, which is expected to roll out on December 16, 2022.


Regards,

Raja.



RR Raja Ramalingam Syncfusion Team December 22, 2022 11:59 AM UTC

Hi Jens Woeste,

We are glad to announce that our Essential Studio 2022 Volume 4 release v20.4.0.38 has been rolled out with the fix for the ChartGradientStop color property dynamic update issue, is available for download under the following link.

https://www.syncfusion.com/forums/179561/essential-studio-2022-volume-4-main-release-v20-4-0-38-is-available-for-download


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Raja.



RR Raja Ramalingam Syncfusion Team January 19, 2023 08:34 AM UTC

Hi Jens Woeste,


We would like to let you know that our latest weekly NuGet, version 20.4.0.43 is now available for download at https://www.nuget.org, This version contains the fix for the issue of 'ChartGradientStop color property not updated with dynamic resource' you have reported.

We highly recommend clearing your cache before using the latest release, you can find a guide on how to do this at https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache

We appreciate your support and thank you for your patience during this process. If you need any further assistance, please do not hesitate to reach out to us.


Regards,

Raja.


Loader.
Live Chat Icon For mobile
Up arrow icon