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.

Change the line color

Thread ID:

Created:

Updated:

Platform:

Replies:

117406 Oct 14,2014 02:44 PM Oct 15,2014 07:38 AM WPF 1
loading
Tags: SfChart
Dustin Davis
Asked On October 14, 2014 02:44 PM

I'm trying to change the line color on a line chart. I've tried everything I could find in the documentation, but the color remains the same. Same thing with the background and grid lines as well. They stay the same color. 

<UserControl x:Class="ScrollingChart"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Syncfusion="http://schemas.syncfusion.com/wpf"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>

        <Syncfusion:SfChart x:Name="Chart" Background="White" Margin="5,5,5,5">


            <Syncfusion:SfChart.PrimaryAxis>
                <Syncfusion:CategoryAxis x:Name="XAxis" ActualRangeChanged="XAxis_ActualRangeChanged" />
            </Syncfusion:SfChart.PrimaryAxis>

            <Syncfusion:SfChart.SecondaryAxis>
                <Syncfusion:NumericalAxis/>
            </Syncfusion:SfChart.SecondaryAxis>

            <Syncfusion:LineSeries ScrollViewer.CanContentScroll="True" x:Name="XLineSeries"
                ItemsSource="{Binding Data}" 
                XBindingPath="Text"
                YBindingPath="Value">
            </Syncfusion:LineSeries>
        </Syncfusion:SfChart >
    </Grid>
</UserControl>


Mohammed Azarudeen [Syncfusion]
Replied On October 15, 2014 07:38 AM

Hi Dustin,

Query: I'm trying to change the line color on a line chart

We have analyzed your requirement and you can achieve your requirement by setting the property Interior for LineSeries as shown in the below code snippet.

Code Snippet [XAML]:

            <chart:LineSeries Interior="Violet" XBindingPath="Text" YBindingPath="Value" ItemsSource="{Binding Data}"></chart:LineSeries>

 Query: Same thing with the background and grid lines as well. They stay the same color

You can achieve your requirement to set the background for the chart area by setting the property AreaBackground for the chart and you also can able to set the color for gridlines by setting the property MajorGridLineStyle for the axes  as shown in the below code snippet.

Code Snippet [XAML]:

<chart:SfChart x:Name="chart" AreaBackground="BlanchedAlmond">

          <chart:SfChart.PrimaryAxis>

                <chart:CategoryAxis  MajorGridLineStyle="{StaticResource gridLineStyle}"></chart:CategoryAxis>

          </chart:SfChart.PrimaryAxis> 

        </chart:SfChart>

We have prepared a sample based on this and please find the attached sample.

Please let us know if you have any queries.

Thanks,

Mohammed Azarudeen.

 


Attachment: LineSeriesInterior_fe14c2a4.zip

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.

;