# linechart: Create a Line Chart

> 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.

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

- Group: Charts
- Endpoint: `POST https://api.1001fx.com/charts/linechart`
- 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/linechart

## Parameters

- `labels` (array<string>, required) – Labels: An array of labels to display.
- `data` (array<object>, required) – Datasets: An array of data to be displayed
  - `label` (string, required) – Label: The text to associate with your dataset.
  - `values` (array<number>, required) – Values: The values of your dataset.
  - `borderColor` (string (HEX Color), optional) – Border Color: The border color of your bar. Defaults to #000000 if no color is provided.
  - `borderDash` (array<number>, optional) – Border Dash: Length and spacing of dashes.
  - `fillColor` (string (HEX Color), optional) – Fill Color: The fill color between your line and the axis.
  - `tension` (number, optional) – Tension: Bezier curve tension of the line. Set to 0 to draw straightlines. Defaults to 0.
- `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.
  - `yAxisTitle` (string, optional) – Y Axis Title: Text to be displayed on the y axis.
  - `xAxisTitle` (string, optional) – X Axis Title: Text to be displayed on the x axis.
  - `axisTitleFontSize` (number, optional) – Axis Title Fontsize: The axis title's font size.
  - `axisTitleColor` (string (HEX Color), optional) – Axis Title Color: The axis title's color. Defaults to #000000 if no color is provided.
  - `gridColor` (string (HEX Color), optional) – Grid Color: The grid's color. Defaults to #f2f2f2 if no color is provided. Hide by setting to same as chart background color.
  - `axisColor` (string (HEX Color), optional) – Axis Color: The grid's color. Defaults to #a0a0a0 if no color is provided. Hide by setting to same as chart background color.
  - `axisFontSize` (number, optional) – Axis Fontsize: The axis's font size.
  - `indexAxis` (enum, optional, one of `x`, `y`) – Index Axis: The base axis. Defaults to x.
- `outputFormat` (enum, required, one of `pdf`, `png`, `jpg`) – Output Format: The desired output format.

## 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

## Example: Line chart as PDF

```bash
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"}'
```

## FAQ

**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.
