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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set color of LineSeries depends on data

Thread ID:

Created:

Updated:

Platform:

Replies:

120799 Oct 15,2015 02:05 PM UTC Oct 19,2015 03:00 PM UTC Windows Phone 3
loading
Tags: SfChart
William
Asked On October 15, 2015 02:05 PM UTC

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 01:02 PM UTC

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 01:48 PM UTC

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 03:00 PM UTC

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.

Warning Icon 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.Close Icon

;