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
close icon

Change the line color

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>


1 Reply

MA Mohammed Azarudeen Syncfusion Team October 15, 2014 11:38 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon