Skip to content
Browse all functions

Create a Line Chart

charts/linechart

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

Use cases

  • Email a monthly chart of website visitors from Google Analytics data
  • Compare revenue of several years as lines in one chart
  • Add a trend chart of daily orders to a PDF report

Try it in the 1001fx app

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

linechart in the 1001fx app: the form with example values
Create a Line Chart in the 1001fx app

Endpoint

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

Parameters

  • labelsarray<string>required

    An array of labels to display.

  • dataarray<object>required

    An array of data to be displayed

    • labelstringrequired

      The text to associate with your dataset.

      Example:
      2022
    • valuesarray<number>required

      The values of your dataset.

    • borderColorstring (HEX Color)optional

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

      Example:
      #FF9F40
    • borderDasharray<number>optional

      Length and spacing of dashes.

    • fillColorstring (HEX Color)optional

      The fill color between your line and the axis.

      Example:
      #FF9F4033
    • tensionnumberoptional

      Bezier curve tension of the line. Set to 0 to draw straightlines. Defaults to 0.

      Example:
      0.5
  • 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
    • indexAxisenumoptional

      The base axis. Defaults to x.

      Values:
      x
      y
      Example:
      y
  • outputFormatenumrequired

    The desired output format.

    Values:
    pdf
    png
    jpg
    Example:
    png

Examples

Line chart as PDF

Custom title, subtitle and colours; returns a PDF.

Input

Creates a line chart
{
  "labels": [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July"
  ],
  "data": [
    {
      "label": "Expectations",
      "values": [
        30,
        35,
        58,
        51,
        81,
        23,
        77
      ],
      "borderColor": "#a0a0a0",
      "tension": 0.5,
      "borderDash": [
        5,
        15
      ]
    },
    {
      "label": "Value",
      "values": [
        10,
        15,
        38,
        31,
        91,
        43,
        67
      ],
      "borderColor": "#FF9F40",
      "fillColor": "#FF9F4033",
      "tension": 0.5
    },
    {
      "label": "Base Line",
      "values": [
        5,
        10,
        15,
        20,
        25,
        30,
        35
      ],
      "borderColor": "#4BC0C0",
      "fillColor": "#4BC0C033"
    }
  ],
  "options": {
… (18 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/linechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"labels":["January","February","March","April","May","June","July"],"data":[{"label":"Expectations","values":[30,35,58,51,81,23,77],"borderColor":"#a0a0a0","tension":0.5,"borderDash":[5,15]},{"label":"Value","values":[10,15,38,31,91,43,67],"borderColor":"#FF9F40","fillColor":"#FF9F4033","tension":0.5},{"label":"Base Line","values":[5,10,15,20,25,30,35],"borderColor":"#4BC0C0","fillColor":"#4BC0C033"}],"options":{"title":"Linechart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic linechart generation from as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"dataLabelAnchor":"start","dataLabelAlignment":"top","dataLabelFontSize":16,"indexAxis":"x"},"outputFormat":"pdf"}'

Line chart as PNG

Custom title, subtitle and colours; returns a PNG.

Input

Creates a line chart
{
  "labels": [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July"
  ],
  "data": [
    {
      "label": "Expectations",
      "values": [
        30,
        35,
        58,
        51,
        81,
        23,
        77
      ],
      "borderColor": "#a0a0a0",
      "tension": 0.5,
      "borderDash": [
        5,
        15
      ]
    },
    {
      "label": "Value",
      "values": [
        10,
        15,
        38,
        31,
        91,
        43,
        67
      ],
      "borderColor": "#FF9F40",
      "fillColor": "#FF9F4033",
      "tension": 0.5
    },
    {
      "label": "Base Line",
      "values": [
        5,
        10,
        15,
        20,
        25,
        30,
        35
      ],
      "borderColor": "#4BC0C0",
      "fillColor": "#4BC0C033"
    }
  ],
  "options": {
… (18 more lines)

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/linechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"labels":["January","February","March","April","May","June","July"],"data":[{"label":"Expectations","values":[30,35,58,51,81,23,77],"borderColor":"#a0a0a0","tension":0.5,"borderDash":[5,15]},{"label":"Value","values":[10,15,38,31,91,43,67],"borderColor":"#FF9F40","fillColor":"#FF9F4033","tension":0.5},{"label":"Base Line","values":[5,10,15,20,25,30,35],"borderColor":"#4BC0C0","fillColor":"#4BC0C033"}],"options":{"title":"Linechart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic linechart generation from as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"dataLabelAnchor":"start","dataLabelAlignment":"top","dataLabelFontSize":16,"indexAxis":"x"},"outputFormat":"png"}'

Line chart as JPG

Custom title, subtitle and colours; returns a JPG.

Input

Creates a line chart
{
  "labels": [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July"
  ],
  "data": [
    {
      "label": "Expectations",
      "values": [
        30,
        35,
        58,
        51,
        81,
        23,
        77
      ],
      "borderColor": "#a0a0a0",
      "tension": 0.5,
      "borderDash": [
        5,
        15
      ]
    },
    {
      "label": "Value",
      "values": [
        10,
        15,
        38,
        31,
        91,
        43,
        67
      ],
      "borderColor": "#FF9F40",
      "fillColor": "#FF9F4033",
      "tension": 0.5
    },
    {
      "label": "Base Line",
      "values": [
        5,
        10,
        15,
        20,
        25,
        30,
        35
      ],
      "borderColor": "#4BC0C0",
      "fillColor": "#4BC0C033"
    }
  ],
  "options": {
… (18 more lines)

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/linechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"labels":["January","February","March","April","May","June","July"],"data":[{"label":"Expectations","values":[30,35,58,51,81,23,77],"borderColor":"#a0a0a0","tension":0.5,"borderDash":[5,15]},{"label":"Value","values":[10,15,38,31,91,43,67],"borderColor":"#FF9F40","fillColor":"#FF9F4033","tension":0.5},{"label":"Base Line","values":[5,10,15,20,25,30,35],"borderColor":"#4BC0C0","fillColor":"#4BC0C033"}],"options":{"title":"Linechart Generation for Automation Platforms with 1001fx","titleAlignment":"center","titleColor":"#2563EB","subtitle":"Automatic linechart generation from as image and PDF. Highly customizable.","subtitleAlignment":"center","subtitleColor":"#333333","fontFamily":"Roboto","titleFontSize":20,"subtitleFontSize":16,"axisTitleFontSize":16,"axisFontSize":16,"dataLabelAnchor":"start","dataLabelAlignment":"top","dataLabelFontSize":16,"indexAxis":"x"},"outputFormat":"jpg"}'

Line chart with default options

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

Input

Creates a line chart
{
  "labels": [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July"
  ],
  "data": [
    {
      "label": "Expectations",
      "values": [
        30,
        35,
        58,
        51,
        81,
        23,
        77
      ],
      "borderColor": "#a0a0a0",
      "tension": 0.5,
      "borderDash": [
        5,
        15
      ]
    },
    {
      "label": "Value",
      "values": [
        10,
        15,
        38,
        31,
        91,
        43,
        67
      ],
      "borderColor": "#FF9F40",
      "fillColor": "#FF9F4033",
      "tension": 0.5
    },
    {
      "label": "Base Line",
      "values": [
        5,
        10,
        15,
        20,
        25,
        30,
        35
      ],
      "borderColor": "#4BC0C0",
      "fillColor": "#4BC0C033"
    }
  ],
  "outputFormat": "jpg"
… (1 more lines)

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/linechart' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"labels":["January","February","March","April","May","June","July"],"data":[{"label":"Expectations","values":[30,35,58,51,81,23,77],"borderColor":"#a0a0a0","tension":0.5,"borderDash":[5,15]},{"label":"Value","values":[10,15,38,31,91,43,67],"borderColor":"#FF9F40","fillColor":"#FF9F4033","tension":0.5},{"label":"Base Line","values":[5,10,15,20,25,30,35],"borderColor":"#4BC0C0","fillColor":"#4BC0C033"}],"outputFormat":"jpg"}'

Frequently asked questions

Can I draw several lines in one chart?
Yes. Each entry in data is one line with its own label, values and colors. The labels array holds the points on the x axis.
How do I get smooth or filled lines?
Set tension above 0 for curves (0 draws straight lines) and fillColor to fill the area between the line and the axis.
In which formats can I get the chart?
As PNG, JPG or PDF, set with outputFormat.

Use cases

Try linechart now

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

Changelog

  • 1.0.010.03.2023created
Ask 1001fx