Issues with Chart Gridlines showing up

3 posts, 1 answers
  1. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 Link to this post

    Hi,

    I'm seeing some issues where the Chart's XY gridlines do not always show up.

    When I have a DateTimeCategoricalAxis as the horizontal axis (set on the chart via setHorizontalAxis) and a vertical axis set on chart as well, only the horizontal gridlines seem to show up.

    Here is a screenshot: https://www.dropbox.com/s/ko73sqhv81n72e1/2.png

    I am setting the gridlines on the chart as follows:

    CartesianChartGrid grid = new CartesianChartGrid(_context);
            grid.setMajorXLinesRenderMode(GridLineRenderMode.INNER);
            grid.setMajorYLinesRenderMode(GridLineRenderMode.INNER);
            grid.setMajorXLineDashArray(new float[] {1, 8});
            grid.setMajorYLineDashArray(new float[] {1, 8});
            grid.setLineColor(Color.WHITE);
            grid.setMajorLinesVisibility(GridLineVisibility.XY);
            _chart.setGrid(grid);

    Now the second problem I am seeing is that I tried removing the code to set vertical axis on the chart directly, and instead I set the vertical axis on a AreaSeries first and then add that AreaSeries to the chart.  I am following the 'Indicators' sample code which does the same thing and does not set vertical axis directly on the chart.  The chart renders fine but now neither horizontal nor vertical gridlines show up anymore.  I tried moving the above code (for setting the grid) to different places but no luck.

    Any idea what is wrong?  For repro you can try to enable XY gridlines on the 'Indicators' sample code






  2. Mike
    Mike avatar
    17 posts
    Member since:
    Jun 2012

    Posted 09 Jul 2014 in reply to Mike Link to this post

    After trying some different approaches, I can get the X gridlines working, but not both X and Y:

            // Enable Grid
            CartesianChartGrid grid = new CartesianChartGrid(_context);
            _chart.setGrid(grid);
            grid.setMajorXLineDashArray(new float[] {1, 8});
            grid.setMajorYLineDashArray(new float[] {1, 8});
            grid.setMajorYLinesRenderMode(GridLineRenderMode.INNER);
            grid.setLineThickness(1);
            grid.setLineColor(defaultSubtleColor);
            grid.setMajorLinesVisibility(GridLineVisibility.XY); // Only shows X, not Y
            grid.setStripLinesVisibility(GridLineVisibility.XY); // Only shows X, not Y
            //grid.setMajorLinesVisibility(GridLineVisibility.X); // Works
            //grid.setStripLinesVisibility(GridLineVisibility.X); // Works
  3. DevCraft banner
  4. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 10 Jul 2014 Link to this post

    Hello Mike,

    I have answered you question in the support thread about the same issue. In a sentence, you need to set both axes to the chart itself for the grid lines/stripes to work.

    Please write again if you have other questions.

    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top