Category Cartesian Axis

If global configuration is used, labels are drawn from one of the label arrays included in the chart data. If only data.labels is defined, this will be used. If data.xLabels is defined and the axis is horizontal, this will be used. Similarly, if data.yLabels is defined and the axis is vertical, this property will be used. Using both xLabels and yLabels together can create a chart that uses strings for both the X and Y axes.

Specifying any of the settings above defines the x axis as type: 'category' if not defined otherwise. For more fine-grained control of category labels it is also possible to add labels as part of the category axis definition. Doing so does not apply the global defaults.

Category Axis Definition

Globally:

  1. let chart = new Chart(ctx, {
  2. type: ...
  3. data: {
  4. labels: ['January', 'February', 'March', 'April', 'May', 'June'],
  5. datasets: ...
  6. }
  7. });

As part of axis definition:

  1. let chart = new Chart(ctx, {
  2. type: ...
  3. data: ...
  4. options: {
  5. scales: {
  6. xAxes: [{
  7. type: 'category',
  8. labels: ['January', 'February', 'March', 'April', 'May', 'June']
  9. }]
  10. }
  11. }
  12. });

Tick Configuration Options

The category scale provides the following options for configuring tick marks. They are nested in the ticks sub object. These options extend the common tick configuration.

NameTypeDefaultDescription
labelsstring[]-An array of labels to display.
minstringThe minimum item to display. more…
maxstringThe maximum item to display. more…

Min Max Configuration

For both the min and max properties, the value must be in the labels array. In the example below, the x axis would only display "March" through "June".

  1. let chart = new Chart(ctx, {
  2. type: 'line',
  3. data: {
  4. datasets: [{
  5. data: [10, 20, 30, 40, 50, 60]
  6. }],
  7. labels: ['January', 'February', 'March', 'April', 'May', 'June']
  8. },
  9. options: {
  10. scales: {
  11. xAxes: [{
  12. ticks: {
  13. min: 'March'
  14. }
  15. }]
  16. }
  17. }
  18. });