This is a migrated thread and some comments may be shown as answers.

Gridlines not working?

1 Answer 197 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 10 Oct 2012, 08:37 PM
I have the following chart set up where I would like to display gridlines:

<telerik:RadCartesianChart Grid.Row="1">
    <telerik:RadCartesianChart.Behaviors>
        <telerik:ChartTrackBallBehavior />
        <telerik:ChartPanAndZoomBehavior ZoomMode="Horizontal" />
    </telerik:RadCartesianChart.Behaviors>
    <telerik:LineSeries ItemsSource="{Binding PraGasProductionChartPoints}"
                        CategoryBinding="Date"
                        ValueBinding="Value">
        <telerik:LineSeries.HorizontalAxis>
            <telerik:DateTimeContinuousAxis  Minimum="{Binding MinimumChartDate}"
                                                Maximum="{Binding MaximumChartDate}"
                                                LabelStyle="{StaticResource labelFontStyle}"
                                                MajorStepUnit="Year"
                                                MajorStep="3"
                                                LabelFormat="yyyy"
                                                />
        </telerik:LineSeries.HorizontalAxis>
        <telerik:LineSeries.VerticalAxis>
            <telerik:LinearAxis LabelFormat="#,#" />
        </telerik:LineSeries.VerticalAxis>
    </telerik:LineSeries>
    <telerik:RadCartesianChart.Grid>
        <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
    </telerik:RadCartesianChart.Grid>
</telerik:RadCartesianChart>

My chart displays fine but I don't get any gridlines to show up on the chart. I assume I'm doing some basic thing wrong. Please help.

Thanks,
Mike 

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 15 Oct 2012, 07:51 AM
Hello Michael,

The problem is that you haven't set the axes of the RadCartesianChart. Instead only the LineSeries have a reference to the axes you have defined. The ChartView Grid needs a reference to the chart's axes, in order to be rendered.

Moving the definitions of the axes from the LineSeries.Vertical/HorizontalAxis to RadCartesianChart.Vertical/HorizontalAxis should solve your problem.

The Vertical/HorizontalAxis properties of the CartesianSeries are only used when you want to have additional axes. This help topic explains how to use them.

Here is a modified version of your code: 
<telerik:RadCartesianChart>          
    <telerik:RadCartesianChart.Behaviors>
        <telerik:ChartTrackBallBehavior />
        <telerik:ChartPanAndZoomBehavior ZoomMode="Horizontal" />
    </telerik:RadCartesianChart.Behaviors>
              
    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:DateTimeContinuousAxis  Minimum="{Binding MinimumChartDate}"
                              Maximum="{Binding MaximumChartDate}"
                              MajorStepUnit="Year"
                              MajorStep="3"
                              LabelFormat="yyyy" />
    </telerik:RadCartesianChart.HorizontalAxis>
              
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis LabelFormat="#,#" />
    </telerik:RadCartesianChart.VerticalAxis>
              
        <telerik:LineSeries
                     ItemsSource="{Binding PraGasProductionChartPoints}"
                     CategoryBinding="Date"
                     ValueBinding="Value"/>
              
    <telerik:RadCartesianChart.Grid>
        <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
    </telerik:RadCartesianChart.Grid>
</telerik:RadCartesianChart>


All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Michael
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or