Skip to content
Browse all functions

Create a Bar Chart

charts/barchart

barchart (Create a Bar Chart) is a 1001fx API function in the group Charts: POST https://api.1001fx.com/charts/barchart, 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 bar chart with custom data and styling. Output can be an image or a PDF.

Use cases

  • Send a weekly revenue bar chart per region by email from a Google Sheet
  • Add a chart of open tickets per team to a Slack report
  • Put a bar chart of survey answers into a PDF report
  • Compare monthly sign-ups in a horizontal bar chart

Try it in the 1001fx app

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

barchart in the 1001fx app: the form with example values
Create a Bar Chart in the 1001fx app

Endpoint

POSThttps://api.1001fx.com/charts/barchart
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 bar. Defaults to #000000 if no color is provided.

      Example:
      #FF9F4033
    • borderColorstring (HEX Color)optional

      The border color of your bar. Defaults to #000000 if no color is provided.

      Example:
      #FF9F40
  • 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
    • yAxisTitlestringoptional

      Text to be displayed on the y axis.

      Example:
      Month
    • xAxisTitlestringoptional

      Text to be displayed on the x axis.

      Example:
      Value
    • axisTitleFontSizenumberoptional

      The axis title's font size.

      Example:
      18
    • axisTitleColorstring (HEX Color)optional

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

      Example:
      #4BC0C0
    • gridColorstring (HEX Color)optional

      The grid's color. Defaults to #f2f2f2 if no color is provided. Hide by setting to same as chart background color.

      Example:
      #4BC0C0
    • axisColorstring (HEX Color)optional

      The grid's color. Defaults to #a0a0a0 if no color is provided. Hide by setting to same as chart background color.

      Example:
      #9966FF
    • axisFontSizenumberoptional

      The axis's font size.

      Example:
      18
    • borderWidthnumberoptional

      The border width of your bars. Defaults to 0.

      Example:
      1
    • borderRadiusnumberoptional

      The border radius of your bars. Defaults to 0.

      Example:
      5
    • indexAxisenumoptional

      The base axis. x for vertical bars. y for horizontal bars. Defaults to x.

      Values:
      x
      y
      Example:
      y
  • outputFormatenumrequired

    The desired output format.

    Values:
    pdf
    png
    jpg
    Example:
    png

Examples

Bar chart as PDF

Custom title, subtitle and colours; returns a PDF.

Input

Creates a pie chart
{
  "type": "pie",
  "data": [
    {
      "label": "January",
      "value": 65,
      "backgroundColor": "#FF638433",
      "borderColor": "#FF6384"
    },
    {
      "label": "February",
      "value": 39,
      "backgroundColor": "#FF9F4033",
      "borderColor": "#FF9F40"
    },
    {
      "label": "March",
      "value": 49,
      "backgroundColor": "#FFCD5633",
      "borderColor": "#FFCD56"
    },
    {
      "label": "April",
      "value": 72,
      "backgroundColor": "#4BC0C033",
      "borderColor": "#4BC0C0"
    },
    {
      "label": "May",
      "value": 93,
      "backgroundColor": "#36A2EB33",
      "borderColor": "#36A2EB"
    },
    {
      "label": "June",
      "value": 84,
      "backgroundColor": "#9966FF33",
      "borderColor": "#9966FF"
    }
  ],
  "options": {
    "title": "Barchart Generation for Automation Platforms with 1001fx",
    "titleAlignment": "center",
    "titleColor": "#2563EB",
    "subtitle": "Automatic barchart generation from your data as image and PDF. Highly customizable.",
    "subtitleAlignment": "center",
    "subtitleColor": "#333333",
    "gridColor": "#f2f2f2",
    "fontFamily": "Roboto",
    "titleFontSize": 20,
    "subtitleFontSize": 16,
    "axisTitleFontSize": 16,
    "axisFontSize": 16,
    "padding": 0,
    "dataLabelAnchor": "center",
    "dataLabelAlignment": "center",
    "dataLabelFontSize": 16,
    "indexAxis": "y"
  },
  "outputFormat": "pdf"
… (1 more lines)

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/barchart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"type":"pie","data":[{"label":"January","value":65,"backgroundColor":"#FF638433","borderColor":"#FF6384"},{"label":"February","value":39,"backgroundColor":"#FF9F4033","borderColor":"#FF9F40"},{"label":"March","value":49,"backgroundColor":"#FFCD5633","borderColor":"#FFCD56"},{"label":"April","value":72,"backgroundColor":"#4BC0C033","borderColor":"#4BC0C0"},{"label":"May","value":93,"backgroundColor":"#36A2EB33","borderColor":"#36A2EB"},{"label":"June","value":84,"backgroundColor":"#9966FF33","borderColor":"#9966FF"}],"options":{"title":"Barchart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic barchart generation from your data as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","gridColor":"#f2f2f2","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"padding":0,"dataLabelAnchor":"center","dataLabelAlignment":"center","dataLabelFontSize":16,"indexAxis":"y"},"outputFormat":"pdf"}'

Bar chart as PNG

Custom title, subtitle and colours; returns a PNG.

Input

Creates a pie chart
{
  "data": [
    {
      "label": "January",
      "value": 65,
      "backgroundColor": "#FF638433",
      "borderColor": "#FF6384"
    },
    {
      "label": "February",
      "value": 39,
      "backgroundColor": "#FF9F4033",
      "borderColor": "#FF9F40"
    },
    {
      "label": "March",
      "value": 49,
      "backgroundColor": "#FFCD5633",
      "borderColor": "#FFCD56"
    },
    {
      "label": "April",
      "value": 72,
      "backgroundColor": "#4BC0C033",
      "borderColor": "#4BC0C0"
    },
    {
      "label": "May",
      "value": 93,
      "backgroundColor": "#36A2EB33",
      "borderColor": "#36A2EB"
    },
    {
      "label": "June",
      "value": 84,
      "backgroundColor": "#9966FF33",
      "borderColor": "#9966FF"
    }
  ],
  "options": {
    "title": "Barchart Generation for Automation Platforms with 1001fx",
    "titleAlignment": "center",
    "titleColor": "#2563EB",
    "subtitle": "Automatic barchart generation from your data as image and PDF. Highly customizable.",
    "subtitleAlignment": "center",
    "subtitleColor": "#333333",
    "gridColor": "#f2f2f2",
    "fontFamily": "Roboto",
    "titleFontSize": 20,
    "subtitleFontSize": 16,
    "axisTitleFontSize": 16,
    "axisFontSize": 16,
    "padding": 0,
    "dataLabelAnchor": "center",
    "dataLabelAlignment": "center",
    "dataLabelFontSize": 16,
    "indexAxis": "y"
  },
  "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/barchart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"label":"January","value":65,"backgroundColor":"#FF638433","borderColor":"#FF6384"},{"label":"February","value":39,"backgroundColor":"#FF9F4033","borderColor":"#FF9F40"},{"label":"March","value":49,"backgroundColor":"#FFCD5633","borderColor":"#FFCD56"},{"label":"April","value":72,"backgroundColor":"#4BC0C033","borderColor":"#4BC0C0"},{"label":"May","value":93,"backgroundColor":"#36A2EB33","borderColor":"#36A2EB"},{"label":"June","value":84,"backgroundColor":"#9966FF33","borderColor":"#9966FF"}],"options":{"title":"Barchart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic barchart generation from your data as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","gridColor":"#f2f2f2","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"padding":0,"dataLabelAnchor":"center","dataLabelAlignment":"center","dataLabelFontSize":16,"indexAxis":"y"},"outputFormat":"png"}'

Bar chart as JPG

Custom title, subtitle and colours; returns a JPG.

Input

Creates a pie chart
{
  "data": [
    {
      "label": "January",
      "value": 65,
      "backgroundColor": "#FF638433",
      "borderColor": "#FF6384"
    },
    {
      "label": "February",
      "value": 39,
      "backgroundColor": "#FF9F4033",
      "borderColor": "#FF9F40"
    },
    {
      "label": "March",
      "value": 49,
      "backgroundColor": "#FFCD5633",
      "borderColor": "#FFCD56"
    },
    {
      "label": "April",
      "value": 72,
      "backgroundColor": "#4BC0C033",
      "borderColor": "#4BC0C0"
    },
    {
      "label": "May",
      "value": 93,
      "backgroundColor": "#36A2EB33",
      "borderColor": "#36A2EB"
    },
    {
      "label": "June",
      "value": 84,
      "backgroundColor": "#9966FF33",
      "borderColor": "#9966FF"
    }
  ],
  "options": {
    "title": "Barchart Generation for Automation Platforms with 1001fx",
    "titleAlignment": "center",
    "titleColor": "#2563EB",
    "subtitle": "Automatic barchart generation from your data as image and PDF. Highly customizable.",
    "subtitleAlignment": "center",
    "subtitleColor": "#333333",
    "gridColor": "#f2f2f2",
    "fontFamily": "Roboto",
    "titleFontSize": 20,
    "subtitleFontSize": 16,
    "axisTitleFontSize": 16,
    "axisFontSize": 16,
    "padding": 0,
    "dataLabelAnchor": "center",
    "dataLabelAlignment": "center",
    "dataLabelFontSize": 16,
    "indexAxis": "y"
  },
  "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/barchart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"label":"January","value":65,"backgroundColor":"#FF638433","borderColor":"#FF6384"},{"label":"February","value":39,"backgroundColor":"#FF9F4033","borderColor":"#FF9F40"},{"label":"March","value":49,"backgroundColor":"#FFCD5633","borderColor":"#FFCD56"},{"label":"April","value":72,"backgroundColor":"#4BC0C033","borderColor":"#4BC0C0"},{"label":"May","value":93,"backgroundColor":"#36A2EB33","borderColor":"#36A2EB"},{"label":"June","value":84,"backgroundColor":"#9966FF33","borderColor":"#9966FF"}],"options":{"title":"Barchart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic barchart generation from your data as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","gridColor":"#f2f2f2","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"padding":0,"dataLabelAnchor":"center","dataLabelAlignment":"center","dataLabelFontSize":16,"indexAxis":"y"},"outputFormat":"jpg"}'

Bar chart with default options

Only data and outputFormat; everything else uses the defaults.

Input

Creates a pie chart
{
  "data": [
    {
      "label": "January",
      "value": 65,
      "backgroundColor": "#FF638433",
      "borderColor": "#FF6384"
    },
    {
      "label": "February",
      "value": 39,
      "backgroundColor": "#FF9F4033",
      "borderColor": "#FF9F40"
    },
    {
      "label": "March",
      "value": 49,
      "backgroundColor": "#FFCD5633",
      "borderColor": "#FFCD56"
    },
    {
      "label": "April",
      "value": 72,
      "backgroundColor": "#4BC0C033",
      "borderColor": "#4BC0C0"
    },
    {
      "label": "May",
      "value": 93,
      "backgroundColor": "#36A2EB33",
      "borderColor": "#36A2EB"
    },
    {
      "label": "June",
      "value": 84,
      "backgroundColor": "#9966FF33",
      "borderColor": "#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/barchart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"data":[{"label":"January","value":65,"backgroundColor":"#FF638433","borderColor":"#FF6384"},{"label":"February","value":39,"backgroundColor":"#FF9F4033","borderColor":"#FF9F40"},{"label":"March","value":49,"backgroundColor":"#FFCD5633","borderColor":"#FFCD56"},{"label":"April","value":72,"backgroundColor":"#4BC0C033","borderColor":"#4BC0C0"},{"label":"May","value":93,"backgroundColor":"#36A2EB33","borderColor":"#36A2EB"},{"label":"June","value":84,"backgroundColor":"#9966FF33","borderColor":"#9966FF"}],"outputFormat":"jpg"}'

Frequently asked questions

In which formats can I get the chart?
As PNG, JPG or PDF, set with outputFormat. The answer is the file itself, ready to attach to an email or upload to a drive.
How do I create horizontal bars?
Set options.indexAxis to y. The default x draws vertical bars.
Why are my bars black?
Each entry has its own backgroundColor as a hex color. Without it the bar is drawn in #000000.

Use cases

Try barchart 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