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.

ColumnSeries chart color

Thread ID:

Created:

Updated:

Platform:

Replies:

119662 Jul 20,2015 09:45 AM Jul 21,2015 02:24 AM Windows Phone 1
loading
Tags: Chart
William
Asked On July 20, 2015 09:45 AM

Hi

I need to implenment a chart that if the value is possitive the bar color should be green, if the value is negative the color should be red, here is the data model:

    class DataModel
    {
        public DateTime DataDate { get; set; }
        public float DataValue{ get; set; }
        public Color Foregroud
        {
            get
            {
                if (DataValue> 0)
                    return Colors.Green;
                else
                    return Colors.Red;
            }
        }
    }

and here is the xaml:

        <Charts:SfChart x:Name="cMainIO" Grid.Row="1">
            <Charts:SfChart.Behaviors>
                <Charts:ChartZoomPanBehavior/>
            </Charts:SfChart.Behaviors>
            <Charts:SfChart.PrimaryAxis>
                <Charts:CategoryAxis x:Name="Primaryx" LabelFormat="MM/dd" />
            </Charts:SfChart.PrimaryAxis>
            <!--SecondaryAxis with range customization-->
            <Charts:SfChart.SecondaryAxis>
                <Charts:NumericalAxis RangePadding="Round" StartRangeFromZero="False" />
            </Charts:SfChart.SecondaryAxis>
            <Charts:ColumnSeries ItemsSource="{Binding}" XBindingPath="DataDate" YBindingPath="DataValue" Interior="{Binding Foregroud, Mode=OneWay}" />
        </Charts:SfChart>

When I run the app the color of bars are still blue,

How to fix it?

Rachel A [Syncfusion]
Replied On July 21, 2015 02:24 AM

Hi William,

Thank you for contacting Syncfusion support.

Query: How to implement a chart that if the value is positive the bar color should be green, if the value is negative the color should be red?

We can achieve your requirement using CustomTemplate property in ColumnSeries which allows customize the series.

Please find the output image as shown below.



We have prepared sample for you reference and please find the sample in the below location.

Sample: ColumnSeriesInterior

Please refer the below documentation for more information.

Link: http://help.syncfusion.com/ug/wpf/Documents/customizeseries.htm

Please let us know if you require any further assistance.

Thanks,
Rachel. 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.

;