This is a migrated thread and some comments may be shown as answers.

Skip Displaying Labels on Category Axis

2 Answers 220 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 21 May 2015, 04:00 AM

HI,

 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:

@(Html.Kendo().Chart()
         .Name("string-battery-chart")
         .Title("BATTERY VOLTAGES")
         .Theme("moonlight")
         .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");
             series.Line("Value").CategoryField("BatteryNumber");
         })
         .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"))
         .Transitions(false)
         .Events(e => e.Zoom("onZoom"))
         .Events(e => e.Drag("onDrag"))
         .Events(e => e.DragEnd("onDragEnd"))
         )

Can anyone help please?

Thanks

Scott

2 Answers, 1 is accepted

Sort by
0
Plamen Lazarov
Telerik team
answered on 22 May 2015, 10:54 AM

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))
    )

Regards,

Plamen Lazarov
Telerik
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
0
Scott
Top achievements
Rank 1
answered on 24 May 2015, 10:32 PM

Easy. 

Thanks Plamen

Tags
Chart
Asked by
Scott
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or