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.
Unfortunately, activation email could not send to your email. Please try again.

Set color of LineSeries depends on data

Thread ID:

Created:

Updated:

Platform:

Replies:

120799 Oct 15,2015 10:05 AM Oct 19,2015 11:00 AM Windows Phone 3
loading
Tags: SfChart
William
Asked On October 15, 2015 10:05 AM

I want the color of lineseries depends on the data value, if current value >0, the color should be green, if the current value <0, the color should be red.
How to implement?

Santhiya Arulsamy [Syncfusion]
Replied On October 16, 2015 09:02 AM

Hi William,

Thanks for contacting Syncfusion support.

We have achieved your requirement by using the custom palette feature. We have prepared the sample based on your requirement.

Sample: LineSeries_120799

Please refer the below links for further information.

Documentation: http://help.syncfusion.com/wp8/sfchart/styling-and-customization

KB : https: //www.syncfusion.com/kb/5126/how-to-define-the-fill-color-for-each-datapoint-from-itemssource

Thanks,

Santhiya A

William
Replied On October 16, 2015 09:48 AM

Hi Santhiya

Thanks for support, I found such code in your sample:

            for (int i = 0; i < viewModel.DataPoint.Count; i++)
            {
                if (viewModel.DataPoint[i].YData > 0)
                    chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Colors.Green));
                else
                    chart.Series[0].ColorModel.CustomBrushes.Add(new SolidColorBrush(Colors.Red));
            }

Is that the only way to set color dynamically? Is there any easier way? like use Data binding the SolidColorBrush in XAML?

Santhiya Arulsamy [Syncfusion]
Replied On October 19, 2015 11:00 AM

Hi William,

We had achieved your requirement by using data binding in the ChartSeries ColorModel property. We have modified the sample based on your requirement.

Please find the sample from the below link.
LineSeries_120799_(2)

Thanks,

Santhiya A.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;