New to Kendo UI for jQuery? Start a free 30-day trial

CategoryAxis.labels

configuration

Configures the axis labels.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            color: "red",
            font: "12px Arial",
            rotation: 45
        }
    }
});
</script>

The background color of the labels. Any valid CSS color string will work here, including hex and rgb.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            background: "yellow"
        }
    }
});
</script>

The border of the labels.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            border: {
                color: "blue",
                width: 1,
                dashType: "solid"
            }
        }
    }
});
</script>

The text color of the labels. Any valid CSS color string will work here, including hex and rgb.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            color: "blue"
        }
    }
});
</script>

Culture to use for formatting the dates. See Globalization for more information. It defaults to the global culture.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            culture: "de-DE"
        }
    },
    series: [{
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 0, 2), value: 20 },
            { date: new Date(2023, 0, 3), value: 15 }
        ],
        field: "value",
        categoryField: "date"
    }]
});
</script>

Date format strings

"hours"

"HH:mm"

"days"

"M/d"

"weeks"

"M/d"

"months"

"MMM 'yy"

"years"

"yyyy"

The Chart will choose the appropriate format for the current baseUnit. Setting the labels format option will override these defaults.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            dateFormats: {
                days: "dd/MM",
                months: "MMM yyyy"
            }
        }
    },
    series: [{
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 1, 1), value: 20 },
            { date: new Date(2023, 2, 1), value: 15 }
        ],
        field: "value",
        categoryField: "date"
    }]
});
</script>

The font style of the labels.

Default: "12px Arial,Helvetica,sans-serif"

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            font: "14px Verdana"
        }
    }
});
</script>

The format of the labels.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            format: "MMM yyyy"
        }
    }
});
</script>

The margin of the labels.

Default: 0

pseudo
    // sets the top, right, bottom and left margin to 3px.
    margin: 3

    // sets the top and left margin to 1px
    // margin right and bottom are with 0px (by default)
    margin: { top: 1, left: 1 }

Mirrors the axis labels and ticks. If the labels are normally on the left side of the axis, mirroring the axis will render them to the right.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            mirror: true
        }
    }
});
</script>

The padding of the labels.

Default: 0

pseudo
    // sets the top, right, bottom and left padding to 3px.
    padding: 3

    // sets the top and left padding to 1px
    // padding right and bottom are with 0px (by default)
    padding: { top: 1, left: 1 }

The rotation angle of the labels.

Default: 0

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            rotation: 45
        }
    }
});
</script>

Number of labels to skip. Skips rendering the first n labels.

Default: 1

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            skip: 2
        }
    }
});
</script>

Label rendering step. Every n-th label is rendered where n is the step

Default: 1

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            step: 2
        }
    }
});
</script>

The template which renders the labels.

The fields which can be used in the template are:

  • value - the category value
  • dataItem - the data item for the category
  • format - the default format of the label
  • culture - the default culture (if set) on the label
  • index - the 0-based index of the current label
  • count - the total number of labels on the axis
<div id="chart"></div>
<script>
// chart initialization
$("#chart").kendoChart({
     title: {
         text: "My Chart Title"
     },
     series: [{
         name: "Series 1",
         data: [200, 450, 300, 125]
     }],
     categoryAxis: {
         categories: [2000, 2001, 2002, 2003],
         labels: {
             // labels template
             template: "Year: #= value #"
         }
     }
});
</script>

The visibility of the labels.

Default: true

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    categoryAxis: {
        labels: {
            visible: false
        }
    }
});
</script>