Skip Displaying Labels on Category Axis

3 posts, 0 answers
  1. Scott
    Scott avatar
    2 posts
    Member since:
    May 2015

    Posted 20 May 2015 Link to this post


     I am displaying 80 records on a bar chart and when the renders on the screen, all the labels on the category axis are squashed together. 

    Is there a way of only displaying the 5th label?

    The code i have tried is:

             .Title("BATTERY VOLTAGES")
             .Legend(legend => legend.Visible(false))
             .ChartArea(ch => ch.Height(300).Background("transparent"))
             .DataSource(ds => ds.Read(read => read.Action("BatteryVoltageChartData", "STRING")))
             .Series(series =>
                 series.Column("Value").CategoryField("BatteryNumber").Name("Volts [V]").Color("#0099ff");
             .CategoryAxis(axis => axis.Title("Battery Number").MajorTicks(ticks => ticks.Skip(4).Step(5)))
             .ValueAxis(axis => axis.Numeric("Value").Title("Volts").Labels(lab => lab.Format("{0}V")))
             .Tooltip(t => t.Visible(true).Template("Battery ${category}: ${value} V"))
             .Events(e => e.Zoom("onZoom"))
             .Events(e => e.Drag("onDrag"))
             .Events(e => e.DragEnd("onDragEnd"))

    Can anyone help please?



  2. Plamen Lazarov
    Plamen Lazarov avatar
    135 posts

    Posted 22 May 2015 Link to this post

    Hi Scott,

    By default every label is rendered. In order to achieve this you could use categoryAxys.labels.step configuration - it provides an option to render every n-th label. Take a look at the code snippet below: 

    .CategoryAxis(axis => axis
            .Labels(labels => labels.Step(5))


    Plamen Lazarov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX bannerTelerik UI for ASP.NET Core is out
  4. Scott
    Scott avatar
    2 posts
    Member since:
    May 2015

    Posted 24 May 2015 in reply to Plamen Lazarov Link to this post


    Thanks Plamen

Back to Top