Cartesian Chart Only Shows 1 Value

2 posts, 1 answers
  1. Alfredo
    Alfredo avatar
    3 posts
    Member since:
    Dec 2013

    Posted 19 Dec 2013 Link to this post

    I have a problem working with a LineSeries in a RadCartesianChart: my binding series has 10 values, but the chart only shows 1 of them.

    What could be the problem in my code?

    XAML:
    <telerik:RadCartesianChart x:Name="chPrueba" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="972" Height="477">
     
                <telerik:RadCartesianChart.Grid>
                    <telerik:CartesianChartGrid
                                        MajorLinesVisibility="XY"
                                        StripLinesVisibility="Y"
                                        MajorXLineDashArray="10, 5"
                                        MajorXLinesRenderMode="All">
                        <telerik:CartesianChartGrid.YStripeBrushes>
                            <SolidColorBrush Color="#FFDFDFDF" Opacity="0.3" />
                            <SolidColorBrush Color="Transparent" />
                        </telerik:CartesianChartGrid.YStripeBrushes>
                    </telerik:CartesianChartGrid>
                </telerik:RadCartesianChart.Grid>
     
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis
                                        Minimum="0"
                                        Maximum="100"  />
                </telerik:RadCartesianChart.VerticalAxis>
     
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:CategoricalAxis LabelOffset="0" LastLabelVisibility="Visible"
                                             LineThickness="1" MajorTickOffset="0" MajorTickInterval="1"
                                             PlotMode="BetweenTicks" TickThickness="1" ZIndex="0" LabelFitMode="Rotate"/>
                </telerik:RadCartesianChart.HorizontalAxis>
     
                <telerik:LineSeries x:Name="chLineSeries" CategoryBinding="fecha" ValueBinding="valor" AllowSelect="True" Stroke="#FF0DAE0D"/>
     
                <telerik:RadCartesianChart.Behaviors>
                    <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True"/>
                </telerik:RadCartesianChart.Behaviors>
     
     
            </telerik:RadCartesianChart>


    Data Class:
    public class vAbortos
        {
            public Double valor { get; set; }
            public String fecha {get; set;}
     
            public vAbortos()
            {
            }
        }

    Creating the data and loading it to the chart:
    public void WindowLoaded()
            {
                List<vAbortos> valores = new List<vAbortos> { };
     
                Random rnd = new Random();
                DateTime fc = new DateTime(2013, 12, 1);
                for (int i = 0; i <= 9; i++)
                {
                    vAbortos ab = new vAbortos();
                    ab.fecha = fc.AddDays(1).ToShortDateString();
                    fc.AddDays(1);
                    ab.valor = rnd.NextDouble() * 10;
     
                    valores.Add(ab);
                }
     
                this.chPrueba.Series[0].ItemsSource = valores;
     
                (chPrueba.VerticalAxis as LinearAxis).Minimum = 0;
                (chPrueba.VerticalAxis as LinearAxis).Maximum = 15;
            }



  2. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 24 Dec 2013 Link to this post

    Hi Alfredo,

    Thank you for contacting us on that matter and providing us with detailed information about your scenario. I managed to track the behavior that you report down. The reason for that rendering is the fact that you actually create all your points with the same category. Hence, the reported layout is expected.

    The reason for this is the DateTime.AddDays()  method. Please note that it returns a new instance with the added day. It does not change the already created DateTime instance.

    Please make sure that the category that you set are different and try the RadCartesianChart control again.

    Regards,
    Pavel R. Pavlov
    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