> For the complete documentation index, see [llms.txt](https://flutter.wednesday.is/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flutter.wednesday.is/charts/guides/cartesian-charts/chart-structuring/axis-labels.md).

# Axis Labels

The only missing element of our basic chart structure are Axis Labels. These are labels you would like to display on each interval tick along the axis.

To display interval labels along the axes, we will use the `axisLabels` property on any Cartesian Chart.

## AxisLabels

The property `axisLabels` requires a `AxisLabelConfig` for each individual axis. If the config is not provided, then interval labels won't be rendered for those axes.

{% tabs %}
{% tab title="Code Sample" %}

<pre class="language-dart"><code class="lang-dart">...
BarChart(
  height: 400,
  chartStructureData: const CartesianChartStructureData(
    xUnitValue: 1,
    yUnitValue: 2,
    maxYValue: 10,
  ),
  chartStylingData: CartesianChartStylingData(
    axisStyle: CartesianAxisStyle(
      axisWidth: 3.0,
      axisColor: Colors.white,
      tickConfig: AxisTickConfig.forAllAxis(
        showTicks: true,
        tickLength: 10.0,
        tickColor: Colors.white,
      ),
    ),
    gridStyle: CartesianGridStyle(
      show: true,
      gridLineWidth: 1.0,
      gridLineColor: Colors.white,
    ),
  ),
<strong>  axisLabels: AxisLabels(
</strong><strong>    left: AxisLabelConfig(
</strong><strong>      builder: (index, value) => Padding(
</strong><strong>        padding: const EdgeInsets.only(right: 8.0),
</strong><strong>        child: Text(
</strong><strong>          '$index',
</strong><strong>          style: const TextStyle(color: Colors.white),
</strong><strong>        ),
</strong><strong>      ),
</strong><strong>    ),
</strong><strong>    bottom: AxisLabelConfig(
</strong><strong>      builder: (index, value) => Padding(
</strong><strong>        padding: const EdgeInsets.only(top: 8.0),
</strong><strong>        child: Text(
</strong><strong>          '$index',
</strong><strong>          style: const TextStyle(color: Colors.white),
</strong><strong>        ),
</strong><strong>      ),
</strong><strong>    ),
</strong><strong>  ),
</strong>  data: BarSeries(
    barData: [
      SimpleBar(
        xValue: 1,
        yValue: const BarData(yValue: 2.3),
      ),
      SimpleBar(
        xValue: 2,
        yValue: const BarData(yValue: 7.2),
      ),
      SimpleBar(
        xValue: 3,
        yValue: const BarData(yValue: -4.8),
      ),
    ],
  ),
),
</code></pre>

{% endtab %}

{% tab title="Result" %}

<figure><img src="/files/rBvPEwZm5BDt8AbL7dQ4" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

Let's dive deeper into the `AxisLabelConfig` that's been provided to left and bottom edges.

## AxisLabelConfig

Each config must implement the mandatory `builder` method. This method provides the `index` of that iteration, and the `value` of the interval that has been processed with the Unit Values. Finally, it must return a widget that will be displayed as the label.&#x20;

Because the label consumes a widget, you have the complete freedom to provide even images or icons if you choose.

Additionally, there are two more properties that can help you position your labels better.

If you wish to have your labels positioned in the center of the unit interval, you can set the value of `centerLabels` property to true.

{% tabs %}
{% tab title="Code Sample" %}

<pre class="language-dart"><code class="lang-dart">...
BarChart(
  height: 400,
  chartStructureData: const CartesianChartStructureData(
    xUnitValue: 1,
    yUnitValue: 3,
  ),
  chartStylingData: CartesianChartStylingData(
    axisStyle: CartesianAxisStyle(
      axisWidth: 3.0,
      axisColor: Colors.white,
      tickConfig: AxisTickConfig.forAllAxis(
        showTicks: true,
        tickLength: 10.0,
        tickColor: Colors.white,
      ),
    ),
    gridStyle: CartesianGridStyle(
      show: true,
      gridLineWidth: 1.0,
      gridLineColor: Colors.white,
    ),
  ),
  axisLabels: AxisLabels(
    left: AxisLabelConfig(
<strong>      centerLabels: true,
</strong>      builder: (index, value) => Padding(
        padding: const EdgeInsets.only(right: 8.0),
        child: Text(
          '$index',
          style: const TextStyle(color: Colors.white),
        ),
      ),
    ),
    bottom: AxisLabelConfig(
<strong>      centerLabels: true,
</strong>      builder: (index, value) => Padding(
        padding: const EdgeInsets.only(top: 8.0),
        child: Text(
          '$index',
          style: const TextStyle(color: Colors.white),
        ),
      ),
    ),
  ),
  data: BarSeries(
    barData: [
      SimpleBar(
        xValue: 1,
        yValue: const BarData(yValue: 2.3),
      ),
      SimpleBar(
        xValue: 2,
        yValue: const BarData(yValue: 7.2),
      ),
      SimpleBar(
        xValue: 3,
        yValue: const BarData(yValue: 4.8),
      ),
    ],
  ),
),
</code></pre>

{% endtab %}

{% tab title="Result" %}

<figure><img src="/files/lFgpwbikc0wZL0wAl9wJ" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

And you can constrain the labels at the edges of each axis to fit within the axis range.

{% tabs %}
{% tab title="Code Sample" %}

```dart
BarChart(
  height: 400,
  chartStructureData: const CartesianChartStructureData(
    xUnitValue: 1,
    yUnitValue: 3,
  ),
  chartStylingData: CartesianChartStylingData(
    axisStyle: CartesianAxisStyle(
      axisWidth: 3.0,
      axisColor: Colors.white,
      tickConfig: AxisTickConfig.forAllAxis(
        showTicks: true,
        tickLength: 10.0,
        tickColor: Colors.white,
      ),
    ),
    gridStyle: CartesianGridStyle(
      show: true,
      gridLineWidth: 1.0,
      gridLineColor: Colors.white,
    ),
  ),
  axisLabels: AxisLabels(
    left: AxisLabelConfig(
      centerLabels: true,
      builder: (index, value) => Padding(
        padding: const EdgeInsets.only(right: 8.0),
        child: Text(
          '$index',
          style: const TextStyle(color: Colors.white),
        ),
      ),
    ),
    bottom: AxisLabelConfig(
      centerLabels: true,
      builder: (index, value) => Padding(
        padding: const EdgeInsets.only(top: 8.0),
        child: Text(
          '$index',
          style: const TextStyle(color: Colors.white),
        ),
      ),
    ),
  ),
  data: BarSeries(
    barData: [
      SimpleBar(
        xValue: 1,
        yValue: const BarData(yValue: 2.3),
      ),
      SimpleBar(
        xValue: 2,
        yValue: const BarData(yValue: 7.2),
      ),
      SimpleBar(
        xValue: 3,
        yValue: const BarData(yValue: 4.8),
      ),
    ],
  ),
),
```

{% endtab %}

{% tab title="Result" %}

<figure><img src="/files/nsqieUjNA4SzTbW14zHA" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### Class Properties

<table><thead><tr><th width="217">Name</th><th width="242">Type</th><th width="112">Required</th><th>Default Value</th></tr></thead><tbody><tr><td>builder</td><td><code>Widget Function(int, double)</code></td><td><mark style="color:red;">true</mark></td><td>--</td></tr><tr><td>centerLabels</td><td><code>bool</code></td><td><mark style="color:blue;">false</mark></td><td><code>false</code></td></tr><tr><td>constraintEdgeLabels</td><td><code>bool</code></td><td><mark style="color:blue;">false</mark></td><td><code>false</code></td></tr></tbody></table>

This concludes our section to structure and customize the Cartesian Grid and Axes elements.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://flutter.wednesday.is/charts/guides/cartesian-charts/chart-structuring/axis-labels.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
