how draw vertical grid?

2 posts, 0 answers
  1. Seung-Ho
    Seung-Ho avatar
    1 posts
    Member since:
    Nov 2014

    Posted 26 Nov 2014 Link to this post


    my code is.. :
     
    CategoricalAxis horizontalAxis = new CategoricalAxis();
    horizontalAxis.setVerticalLocation(AxisVerticalLocation.BOTTOM);
    lineSeries_Temperature.setHorizontalAxis(horizontalAxis);

    CategoricalAxis horizontalAxis_top = new CategoricalAxis();
    horizontalAxis_top.setVerticalLocation(AxisVerticalLocation.TOP);

    LinearAxis verticalAxis = new LinearAxis();
    verticalAxis.setMaximum(maxTemperature);
    verticalAxis.setMinimum(minTemperature);

    chartView_line.setVerticalAxis(verticalAxis);


    // Grid 
    CartesianChartGrid grid = new CartesianChartGrid();
    grid.setMajorYLinesRenderMode(GridLineRenderMode.ALL);
    grid.setMajorXLinesRenderMode(GridLineRenderMode.ALL);
    grid.setMajorLinesVisibility(GridLineVisibility.XY);
    grid.setStripLinesVisibility(GridLineVisibility.XY);
    chartView_line.setGrid(grid);








  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 27 Nov 2014 Link to this post

    Hello Seung,

    Thanks for writing.
    To draw vertical grid lines, you need to set your axes on the chart, not on the series. This is crucial since the grid does not know which series to get axes from if the axes are set on the series. Once the axes are set on the chart object, you just have to set the grid to render only vertical lines. For example:
    CartesianChartGrid grid = new CartesianChartGrid();
    grid.setMajorLinesVisibility(GridLineVisibility.X);
    grid.setCanApplyPalette(false);
    this.chartView.setGrid(grid);
    You need to stop the palette from applying because otherwise it will overwrite your settings.

    Please write again if you have more 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.

     
  3. DevCraft banner
Back to Top