# piechart: Create a Pie Chart

> piechart (Create a Pie Chart) is a 1001fx API function in the group Charts: POST https://api.1001fx.com/charts/piechart, 3 credits per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Creates a pie chart with custom data and styling. Output can be an image or a PDF.

- Group: Charts
- Endpoint: `POST https://api.1001fx.com/charts/piechart`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 3 credits per call
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/piechart

## Parameters

- `data` (array<object>, required) – Data: An array of data to be displayed
  - `label` (string, required) – Label: The text to associate with your value
  - `value` (number, required) – Value: The value of your entry
  - `backgroundColor` (string (HEX Color), optional) – Slice Color: The background color of your pie slice. Defaults to #000000 if no color is provided.
- `options` (object, optional) – Chart Options: Options to customize your chart.
  - `title` (string, optional) – Chart Title: The title to be displayed above your chart.
  - `titleAlignment` (enum, optional, one of `start`, `center`, `end`, default `center`) – Chart Title Alignment: Where to place your chart title. Defaults to center.
  - `titleColor` (string (HEX Color), optional) – Title Color: The title's color. Defaults to #000000 if no color is provided.
  - `titleFontSize` (number, optional) – Title Fontsize: The title's font size.
  - `subtitle` (string, optional) – Chart Subtitle: The subtitle to be displayed above your chart.
  - `subtitleAlignment` (enum, optional, one of `start`, `center`, `end`, default `center`) – Chart Subtitle Alignment: Where to place your chart subtitle. Defaults to center.
  - `subtitleColor` (string (HEX Color), optional) – Subtitle Color: The subtitle's color. Defaults to #000000 if no color is provided.
  - `subtitleFontSize` (number, optional) – Subtitle Fontsize: The subtitleFontSize's font size.
  - `backgroundColor` (string (HEX Color), optional) – Chart Background Color: The chart's backgroundColor. Defaults to #ffffff if no color is provided.
  - `padding` (number, optional) – Chart Padding: The padding around your chart. Defaults to 50.
  - `fontFamily` (enum, optional, one of `Alegreya`, `Barlow`, `Inter`, `Lato`, `Montserrat`, `OpenSans`, `Oswald`, `Poppins`, `PTSans`, `Raleway`, `Roboto`) – Font: The font to use in your chart.
  - `dataLabelAnchor` (enum, optional, one of `start`, `center`, `end`, default `center`) – Data Label Anchor: Anchor position of your element. Defaults to center.
  - `dataLabelAlignment` (enum, optional, one of `start`, `center`, `end`, `left`, `top`, `right`, `bottom`, default `center`) – Data Label Alignment: Defines the position of the label relative to the anchor point. Defaults to center.
  - `dataLabelFontSize` (number, optional) – Data Label Font Size: The data label's font size
  - `dataLabelOffset` (number, optional) – Data Label Offset: Offset from the anchor point. Defaults to 0.
  - `dataLabelsHidden` (boolean, optional, default `false`) – Data Labels Hidden: When true hides all data labels. Defaults to false.
  - `dataLabelClamp` (boolean, optional, default `false`) – Data Label Clamping: When true enforces the anchor position to be calculated based on the visible geometry of the associated element. Defaults to false.
  - `legendHidden` (boolean, optional) – Legend Hidden: When true hides the legend. Defaults to false.
  - `legendPosition` (enum, optional, one of `left`, `top`, `right`, `bottom`, default `top`) – Legend Position: Where to place your legend. Defaults to top.
  - `legendFontSize` (number, optional) – Legend Fontsize: The legend's font size.
- `type` (enum, optional, one of `pie`, `donut`) – Chart Type: How to display your chart. Defaults to pie.
- `outputFormat` (enum, required, one of `pdf`, `png`, `jpg`) – Output Format: The desired output format.

## Use cases

- Send a weekly sales pie chart by email from a Google Sheet
- Show the share of support tickets per category in a Slack report
- Add a donut chart of a budget split to a PDF report

## Example: Pie chart as PDF

```bash
curl -X POST 'https://api.1001fx.com/charts/piechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"type":"pie","data":[{"label":"January","value":65,"backgroundColor":"#FF6384"},{"label":"February","value":39,"backgroundColor":"#FF9F40"},{"label":"March","value":49,"backgroundColor":"#FFCD56"},{"label":"April","value":72,"backgroundColor":"#4BC0C0"},{"label":"May","value":93,"backgroundColor":"#36A2EB"},{"label":"June","value":84,"backgroundColor":"#9966FF"}],"options":{"title":"PieChart / Donut Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic piechart / donut generation from your data as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","fontFamily":"Roboto","titleFontSize":32,"subtitleFontSize":16,"dataLabelAnchor":"end","dataLabelAlignment":"end","dataLabelFontSize":18,"legendPosition":"top","legendFontSize":18},"outputFormat":"pdf"}'
```

## FAQ

**Can I create a donut chart?**

Yes. Set type to donut. The default is pie.

**In which formats can I get the chart?**

As PNG, JPG or PDF, set with outputFormat. The answer is the file itself.

**How do I set the colors and fonts?**

Each slice has its own backgroundColor as hex color (default #000000). Title, subtitle, legend, data labels and one of 11 fonts such as Inter, Roboto or Montserrat are set in options.
