Support for minor grid lines in ChartView?

5 posts, 1 answers
  1. Don
    Don avatar
    4 posts
    Member since:
    May 2013

    Posted 10 Jun 2013 Link to this post

    How do I display minor gridlines in a ChartView?  The data is displayed in a standard cartesian grid with an X and Y axis.
  2. Answer
    Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 12 Jun 2013 Link to this post

    Hi Donald,

    Currently, we do not support minor ticks, thus, the same applies for minor gridlines.

    I can offer you the following workaround using CustomGridLines as part of the Annotations feature (demo and help topic) of ChartView.

    First of all, you need to have explicitly set Minimum, Maximum, and MajorStep of the axis:
    <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis Maximum="100"
                                  Minimum="0"
                                  MajorStep="20"/>
    </telerik:RadCartesianChart.VerticalAxis>

    Then, you can generate the custom grid lines in the constructor of the window:
    public MainWindow()
            {
                InitializeComponent();
                var chartVerticalAxis = (this.chart.VerticalAxis as LinearAxis);
                var min = chartVerticalAxis.Minimum;
                var max = chartVerticalAxis.Maximum;
                var majorStep = chartVerticalAxis.MajorStep;
                var minorOffset = majorStep / 2;
     
                for (double i = minorOffset; i < max; i += majorStep)
                {
                    chart.Annotations.Add(new CartesianGridLineAnnotation() { Value = i, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1, Axis = chartVerticalAxis});
                }
            }

    I hope that this will server you well.

    Regards, Rosko
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Don
    Don avatar
    4 posts
    Member since:
    May 2013

    Posted 12 Jun 2013 Link to this post

    Thanks.  Works for me. :)
  5. Saurabh
    Saurabh avatar
    10 posts
    Member since:
    Mar 2012

    Posted 04 Aug 2014 Link to this post

    I see this is still a non-implemented feature at Q2 2014 release. How and when are you planning to implement minor grid lines in Chart view? Also, the current workaround will be very tedious if I have to do it for live like in your example - http://demos.telerik.com/silverlight/#ChartView/LiveData. (I know that is link to a silverlight demo)
  6. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 07 Aug 2014 Link to this post

    Hi Saurabh,

    I already answered your question in the Creating Custom Major Lines  when using LogarithmicAxis forum.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready