> 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/radial-charts/charts/pie-and-donut-chart/styling.md).

# Styling

All styling in the `Piechart` and other chart widgets are **Hierarchical** from Top to Bottom. This means that the *Bottom/Child* level styling will **override** the *Top/Parent* level styling.

The class `SliceDataStyle` provides the styling options for the `Piechart`.

{% hint style="info" %}
The Hierarchical Styling is available for `labelStyle` which provides Text Styling for all the Pie piece labels of a Pie Chart.
{% endhint %}

Let's take an example to see how it works.

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

```dart
...
import 'package:chart_it/chart_it.dart';

class TestPieCharts StatefulWidget {
  const TestPieCharts({Key? key}) : super(key: key);

  @override
  State<TestPieCharts> createState() => _TestPieChartsState();
}

class _TestPieChartsState extends State<TestPieCharts> {
  @override
  Widget build(BuildContext context) {
    return PieChart(
      data: PieSeries(
        slices: <SliceData>[
          SliceData(
            label: (_, value) => 'Quarter 1',
            value: 18,
          ),
          SliceData(
            label: (_, value) => 'Quarter 2',
            value: 45,
          ),
          SliceData(
            label: (_, value) => 'Quarter 3',
            value: 72,
          ),
          SliceData(
            label: (_, value) => 'Quarter 4',
            value: 55,
          ),
        ],
      ),
    );
  }
}
```

{% endtab %}

{% tab title="Result" %}

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

Above example will draw four Pie Slices as a PieChart. Now let's add styling to our Pie pieces in this example.

### Series Styling

To provide uniform styling for **All the Pie Pieces** in the `Piechart`, we provide the styling at *Series* Level to the `seriesStyle` property of the `PieSeries` class.

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

<pre class="language-dart"><code class="lang-dart">...
import 'package:chart_it/chart_it.dart';

class TestPieCharts extends StatefulWidget {
  const TestPieCharts({Key? key}) : super(key: key);

  @override
  State&#x3C;TestPieCharts> createState() => _TestPieChartsState();
}

class _TestPieChartsState extends State&#x3C;TestPieCharts> {
  @override
  Widget build(BuildContext context) {
    return PieChart(
      data: PieSeries(
<strong>        seriesStyle: SliceDataStyle(
</strong><strong>          radius: 100,
</strong><strong>          color: Color(0xFF7136E7),
</strong><strong>          strokeWidth: 3.0,
</strong><strong>          strokeColor: Colors.white,
</strong><strong>        ),
</strong>        slices: &#x3C;SliceData>[
          SliceData(
            label: (_, value) => 'Quarter 1',
            value: 18,
          ),
          SliceData(
            label: (_, value) => 'Quarter 2',
            value: 45,
          ),
          SliceData(
            label: (_, value) => 'Quarter 3',
            value: 72,
          ),
          SliceData(
            label: (_, value) => 'Quarter 4',
            value: 55,
          ),
        ],
      ),
    );
  }
}
</code></pre>

{% endtab %}

{% tab title="Result" %}

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

### Pie Styling

Besides `seriesStyle`, you can can also customize **each individual pie** with the property **style** for every `SliceData`. This is the bottom most styling property and will override the parent series level styling.

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

<pre class="language-dart"><code class="lang-dart">...
import 'package:chart_it/chart_it.dart';

class TestPieCharts extends StatefulWidget {
  const TestPieCharts({Key? key}) : super(key: key);

  @override
  State&#x3C;TestPieCharts> createState() => _TestPieChartsState();
}

class _TestPieChartsState extends State&#x3C;TestPieCharts> {
  @override
  Widget build(BuildContext context) {
    return PieChart(
      data: PieSeries(
        seriesStyle: SliceDataStyle(
          radius: 200,
          color: Color(0xFF7136E7),
          strokeWidth: 3.0,
          strokeColor: Colors.white,
        ),
        slices: &#x3C;SliceData>[
          SliceData(
            label: (_, value) => 'Quarter 1',
            value: 18,
          ),
          SliceData(
<strong>            style: SliceDataStyle(
</strong><strong>              radius: 150,
</strong><strong>              color: Color(0xFFBDA2F4),
</strong><strong>              labelPosition: 200,
</strong><strong>              strokeWidth: 2.0,
</strong><strong>              strokeColor: Colors.white,
</strong><strong>            ),
</strong>            label: (_, value) => 'Quarter 2',
            value: 45,
          ),
          SliceData(
<strong>            style: SliceDataStyle(
</strong><strong>              radius: 250,
</strong><strong>              color: Color(0xFFFFB86E),
</strong><strong>              labelPosition: 125,
</strong><strong>              strokeWidth: 2.0,
</strong><strong>              strokeColor: Colors.white,
</strong><strong>            ),
</strong>            label: (_, value) => 'Quarter 3',
            labelStyle: ChartTextStyle(
              textStyle: GoogleFonts.poppins(
                color: Color(0xFF693C00),
              ),
            ),
            value: 72,
          ),
          SliceData(
<strong>            style: SliceDataStyle(
</strong><strong>              radius: 175,
</strong><strong>              color: Color(0xFF693C00),
</strong><strong>              labelPosition: 90,
</strong><strong>              strokeWidth: 2.0,
</strong><strong>              strokeColor: Colors.white,
</strong><strong>            ),
</strong>            label: (_, value) => 'Quarter 4',
            labelStyle: ChartTextStyle(
              textStyle: GoogleFonts.poppins(
                color: Color(0xFFFFB86E),
              ),
            ),
            value: 55,
          ),
        ],
      ),
    );
  }
}
</code></pre>

{% endtab %}

{% tab title="Result" %}

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

The above example provides a clear picture of the **Hierarchical Structure** for styling across the widget tree classes.

### SliceDataStyle Properties

| Name          | Type        | Required                               | Default Value |
| ------------- | ----------- | -------------------------------------- | ------------- |
| radius        | `double?`   | <mark style="color:blue;">false</mark> | `null`        |
| labelPosition | `double?`   | <mark style="color:blue;">false</mark> | `null`        |
| color         | `Color?`    | <mark style="color:blue;">false</mark> | `null`        |
| gradient      | `Gradient?` | <mark style="color:blue;">false</mark> | `null`        |
| strokeWidth   | `double?`   | <mark style="color:blue;">false</mark> | `null`        |
| strokeColor   | `Color?`    | <mark style="color:blue;">false</mark> | `null`        |
