RadCarthesianChart Grid Background not set

2 posts, 0 answers
  1. Waut
    Waut avatar
    9 posts
    Member since:
    Jan 2013

    Posted 19 Sep 2013 Link to this post

    Hello

    I'm trying to set the background for my chart to a specific backgroundcolor. But I don't want the whole chart to be that color, just the grid itself. But if I set that background, the color doesn't change.

    <telerik:RadCartesianChart.Grid>
     <telerik:CartesianChartGrid MajorLinesVisibility="X" MajorXLineStyle="{StaticResource StripLinesStyle}" Background="#D8D3D0"/>
     </telerik:RadCartesianChart.Grid>


    Also I was trying to set the color of the axis, and I couldn't find that option. Attached is an image of what I'm trying to make, not minding the graphs itself ;)

    Thanks
    Waut
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 20 Sep 2013 Link to this post

    Hi Waut,

    Most of the chart elements are derived from classes from the WPF framework like Control or FrameworkElement which have large number properties/methods/events, many of which are are not applicable to the problem domain of the particular chart element. In many cases ChartView classes define their own members, or/and the framework members do not work.

    To your questions:
    1. To set a background, you need to set the Background property of the chart, instead of the chart grid. 
    2. To set the axis color, you need to use the ElementBrush property. If you need to change the axis label color, you need use the LabelTemplate property.

    Here's an example:
    <telerik:RadCartesianChart x:Name="chart" Background="#D8D3D0">
        <telerik:RadCartesianChart.Grid>
            <telerik:CartesianChartGrid MajorLinesVisibility="X"
            MajorXLineStyle="{StaticResource StripLinesStyle}" />
        </telerik:RadCartesianChart.Grid>
        <telerik:LinearAxis ElementBrush="Blue">
            <telerik:LinearAxis.LabelTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" Foreground="Orange"/>
                </DataTemplate>
            </telerik:LinearAxis.LabelTemplate>
        </telerik:LinearAxis>


    Regards,
    Petar Kirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top