Skip to content
Browse all functions

Create a Pie Chart

charts/piechart

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.

3 credits per callHTTP APIn8nMake

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

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

Try it in the 1001fx app

Run piechart in your browser with your API key – fill the form, click Run and get the answer or the file.

piechart in the 1001fx app: the form with example values
Create a Pie Chart in the 1001fx app

Endpoint

POSThttps://api.1001fx.com/charts/piechart
Header
X-API-KEY: YOURSECRETAPIKEY How to
Content type
application/json

Parameters

  • dataarray<object>required

    An array of data to be displayed

    • labelstringrequired

      The text to associate with your value

      Example:
      January
    • valuenumberrequired

      The value of your entry

      Example:
      100
    • backgroundColorstring (HEX Color)optional

      The background color of your pie slice. Defaults to #000000 if no color is provided.

      Example:
      #FF9F4033
  • optionsobjectoptional

    Options to customize your chart.

    • titlestringoptional

      The title to be displayed above your chart.

      Example:
      Anual Report
    • titleAlignmentenumoptional

      Where to place your chart title. Defaults to center.

      Values:
      start
      center
      end
      Default:
      center
      Example:
      left
    • titleColorstring (HEX Color)optional

      The title's color. Defaults to #000000 if no color is provided.

      Example:
      #36A2EB
    • titleFontSizenumberoptional

      The title's font size.

      Example:
      18
    • subtitlestringoptional

      The subtitle to be displayed above your chart.

      Example:
      Anual Report
    • subtitleAlignmentenumoptional

      Where to place your chart subtitle. Defaults to center.

      Values:
      start
      center
      end
      Default:
      center
      Example:
      left
    • subtitleColorstring (HEX Color)optional

      The subtitle's color. Defaults to #000000 if no color is provided.

      Example:
      #4BC0C0
    • subtitleFontSizenumberoptional

      The subtitleFontSize's font size.

      Example:
      18
    • backgroundColorstring (HEX Color)optional

      The chart's backgroundColor. Defaults to #ffffff if no color is provided.

      Example:
      #FFCD56
    • paddingnumberoptional

      The padding around your chart. Defaults to 50.

      Example:
      25
    • fontFamilyenumoptional

      The font to use in your chart.

      Values:
      Alegreya
      Barlow
      Inter
      Lato
      Montserrat
      OpenSans
      Oswald
      Poppins
      PTSans
      Raleway
      Roboto
      Example:
      Roboto
    • dataLabelAnchorenumoptional

      Anchor position of your element. Defaults to center.

      Values:
      start
      center
      end
      Default:
      center
      Example:
      start
    • dataLabelAlignmentenumoptional

      Defines the position of the label relative to the anchor point. Defaults to center.

      Values:
      start
      center
      end
      left
      top
      right
      bottom
      Default:
      center
      Example:
      top
    • dataLabelFontSizenumberoptional

      The data label's font size

      Example:
      10
    • dataLabelOffsetnumberoptional

      Offset from the anchor point. Defaults to 0.

      Example:
      10
    • dataLabelsHiddenbooleanoptional

      When true hides all data labels. Defaults to false.

      Default:
      false
      Example:
      true
    • dataLabelClampbooleanoptional

      When true enforces the anchor position to be calculated based on the visible geometry of the associated element. Defaults to false.

      Default:
      false
      Example:
      true
    • legendHiddenbooleanoptional

      When true hides the legend. Defaults to false.

      Example:
      true
    • legendPositionenumoptional

      Where to place your legend. Defaults to top.

      Values:
      left
      top
      right
      bottom
      Default:
      top
      Example:
      bottom
    • legendFontSizenumberoptional

      The legend's font size.

      Example:
      18
  • typeenumoptional

    How to display your chart. Defaults to pie.

    Values:
    pie
    donut
    Example:
    pie
  • outputFormatenumrequired

    The desired output format.

    Values:
    pdf
    png
    jpg
    Example:
    png

Examples

Pie chart as PDF

Custom title, subtitle and colours; returns a PDF.

Input

Creates a pie chart
{
  "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"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "application/pdf",
    "content-disposition": "attachment; filename=\"result.pdf\""
  }
}
Show curl command
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"}'

Pie chart as PNG

Custom title, subtitle and colours; returns a PNG.

Input

Creates a pie chart
{
  "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": "png"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/png",
    "content-disposition": "attachment; filename=\"result.png\""
  }
}
Show curl command
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":"png"}'

Pie chart as JPG

Custom title, subtitle and colours; returns a JPG.

Input

Creates a pie chart
{
  "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": "jpg"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/jpeg",
    "content-disposition": "attachment; filename=\"result.jpg\""
  }
}
Show curl command
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":"jpg"}'

Donut chart as JPG

type "donut" with custom title, subtitle and colours.

Input

Creates a donut chart
{
  "type": "donut",
  "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": "jpg"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/jpeg",
    "content-disposition": "attachment; filename=\"result.jpg\""
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/charts/piechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"type":"donut","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":"jpg"}'

Donut chart with default options

Only type, data and outputFormat; everything else uses the defaults.

Input

Creates a donut chart
{
  "type": "donut",
  "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"
    }
  ],
  "outputFormat": "jpg"
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/jpeg",
    "content-disposition": "attachment; filename=\"result.jpg\""
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/charts/piechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"type":"donut","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"}],"outputFormat":"jpg"}'

Frequently asked questions

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.

Use cases

Try piechart now

Run it in your browser or create a free account and get 100 credits every month.

Changelog

  • 1.0.009.03.2023created
Ask 1001fx