> For the complete documentation index, see [llms.txt](https://support.attackforge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.attackforge.com/app/modules/reporting/template-charts.md).

# Template - Charts

## Overview

You can add charts to your reports. ReportGen draws them from your project data when the report is generated, so they're always up to date. Charts are supported in ReportGen v2.5.4 or later.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2Fvo14al2sN2ATRH79PuKT%2Ftemplate-charts-at-a-glance.svg?alt=media&amp;token=4eb9efee-025c-49bf-8372-b4317bd86159" alt=""><figcaption></figcaption></figure>

There are three chart types:

| Chart                            | Use it to show                                                  | `type`        |
| -------------------------------- | --------------------------------------------------------------- | ------------- |
| **Pie** (and donut)              | How a total splits into parts, such as findings by priority     | `pie`         |
| **Bar** (horizontal or vertical) | Counts side by side, such as findings by priority or by source  | `bar`         |
| **Stacked bar**                  | Counts split into groups, such as severity within each category | `stacked-bar` |

Watch the [video walkthrough](https://youtu.be/g1BIGD_Qfi4). Help, examples and tips are also on the [ReportGen GitHub support site](https://github.com/AttackForge/ReportGen).

## How a chart tag is built

Every chart uses the same wrapper, with the chart's settings written as JSON in the middle:

```
{#json}{=< >=}</><%$chart[
   { ...chart settings... }
]><#json><={ }=>{/}
```

| Part                | What it does                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| `{#json}{=< >=}</>` | Switches the tag delimiters from `{ }` to `< >`, so the curly brackets in the JSON aren't read as tags. |
| `<%$chart[ ... ]>`  | Calls the chart function with your chart settings.                                                      |
| `<#json><={ }=>{/}` | Switches the delimiters back to `{ }`.                                                                  |

Copy the wrapper exactly, and change only the settings inside it.

## Why it matters

* **See the picture at a glance.** Executives and clients understand a chart faster than a table of numbers.
* **Always up to date.** Charts are drawn from live project data each time the report is generated, so there's nothing to redraw by hand.
* **On brand.** Set colours, sizes and titles to match your report template.

## Who uses it

| Who                         | To                                                        |
| --------------------------- | --------------------------------------------------------- |
| **Report template authors** | Add charts to executive summaries and findings sections   |
| **Consultancies and MSSPs** | Give clients clear, branded visuals of their results      |
| **Security leaders**        | Show risk by priority, source or category to stakeholders |

## Where chart values come from

Each value in a chart can be:

| Source                                      | Write it as       | Example                         |
| ------------------------------------------- | ----------------- | ------------------------------- |
| A number or string                          | The value itself  | `"5"`                           |
| An existing tag, using scope                | `%(tagName)`      | `"%(totalCriticalVulns)"`       |
| A variable you've worked out with functions | `$(variableName)` | `"$(CriticalInternalFindings)"` |

Use variables when the numbers you need aren't already a tag, such as counts of internal findings. See [Template Functions](https://support.attackforge.com/app/modules/reporting/template-functions) and [Template Filters](https://support.attackforge.com/app/modules/reporting/template-filters).

## Add a pie chart

A pie chart shows how a total splits into parts. Set `inner_radius` to turn it into a donut chart.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FbrsH3faxueCtdaZNvbfw%2Fpie-chart.png?alt=media&amp;token=f762af5c-d397-44b6-bd84-ebe6311a28b5" alt="" width="563"><figcaption></figcaption></figure>

### Example 1: Pie chart showing unique vulnerabilities

This example uses existing tags, such as `{totalCriticalVulns}` and `{totalHighVulns}`, for the values.

```
{#json}{=< >=}</><%$chart[
   {
      “type”: “pie”,
      “name”: “unique_vulns_by_priority_pie”,
      “options”: {
         “title”: “”, 
         “data”: {
            “ignore_falsy_values”: true,
            “names”: [
	       “Critical”,
	       “High”,
	       “Medium”,
 	       “Low”,
   	       “Info”
	    ],
            “values”: [
               “%(totalCriticalVulns)”,
	       “%(totalHighVulns)”,
	       “%(totalMediumVulns)”,
	       “%(totalLowVulns)”,
	       “%(totalInfoVulns)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”,
	       “#00B050”
            ]
         },
         “width”: 600,
         “height”: 400
      }
   }
]><#json><={ }=>{/}
```

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FtW8jrUDvH0mCZb2u9Tac%2Fpie-chart-2.png?alt=media&amp;token=c52d8de7-456b-4848-8063-fd71b9bd018b" alt="" width="563"><figcaption></figcaption></figure>

### Example 2: Pie chart using data from custom variables

This example counts internal findings by priority, using `filterBy` on the `Source:Internal` custom tag. It stores each count in a variable, then charts the variables.

```
{$declare[CriticalInternalFindings][0]}
{$declare[HighInternalFindings][0]}
{$declare[MediumInternalFindings][0]}
{$declare[LowInternalFindings][0]}
{$declare[InfoInternalFindings][0]}
{#vulnerabilities | filterBy:’AffectedAssetCustomTags’:[‘Source:Internal’]}
{#priority == ‘Critical’}{$increment[CriticalInternalFindings][1]}{/}
{#priority == ‘High’}{$increment[HighInternalFindings][1]}{/}
{#priority == ‘Medium’}{$increment[MediumInternalFindings][1]}{/}
{#priority == ‘Low’}{$increment[LowInternalFindings][1]}{/}
{#priority == ‘Info’}{$increment[InfoInternalFindings][1]}{/}
{/}

{#json}{=< >=}</><%$chart[
   {
      “type”: “pie”,
      “name”: “unique_internal_findings_pie”,
      “options”: {
         “title”: “”, 
         “data”: {
            “ignore_falsy_values”: true,
            “names”: [
	       “Critical”,
	       “High”,
	       “Medium”,
 	       “Low”
	    ],
            “values”: [
               “$(CriticalInternalFindings)”,
	       “$(HighInternalFindings)”,
	       “$(MediumInternalFindings)”,
	       “$(LowInternalFindings)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”
            ]
         },
         “width”: 600,
         “height”: 400
      }
   }
]><#json><={ }=>{/}
```

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FX0CiZev59yUfTd2Rd4hE%2Fpie-chart-3.png?alt=media&amp;token=83e23a6c-7114-4662-b5b7-6ed7802cd52d" alt="" width="563"><figcaption></figcaption></figure>

### Example 3: Donut pie chart showing unique vulnerabilities

The same as Example 1, with `inner_radius` set to make a hole in the centre.

```
{#json}{=< >=}</><%$chart[
   {
      “type”: “pie”,
      “name”: “unique_vulns_by_priority_pie”,
      “options”: {
         “title”: “”, 
         “inner_radius”: 130,
         “data”: {
            “ignore_falsy_values”: true,
            “names”: [
	       “Critical”,
	       “High”,
	       “Medium”,
 	       “Low”,
   	       “Info”
	    ],
            “values”: [
               “%(totalCriticalVulns)”,
	       “%(totalHighVulns)”,
	       “%(totalMediumVulns)”,
	       “%(totalLowVulns)”,
	       “%(totalInfoVulns)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”,
	       “#00B050”
            ]
         },
         “width”: 600,
         “height”: 400
      }
   }
]><#json><={ }=>{/}
```

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2F2GiC32g41MXndjFrnJoV%2Fpie-chart-4.png?alt=media&amp;token=d541253a-1617-43ce-82a3-1c5486108345" alt="" width="563"><figcaption></figcaption></figure>

### Pie chart options

| Option                             | Required | Type            | Default | Description                                                                 |
| ---------------------------------- | -------- | --------------- | ------- | --------------------------------------------------------------------------- |
| `type`                             | Yes      | String          | —       | The chart type: `pie`.                                                      |
| `name`                             | Yes      | String          | —       | A unique name for the chart.                                                |
| `options`                          | Yes      | Object          | —       | The chart settings below.                                                   |
| `options.inner_radius`             | No       | Number          | 0       | The size of the hole in the centre. Makes a donut chart.                    |
| `options.title`                    | No       | String          | —       | Text shown above the chart.                                                 |
| `options.title_font_size`          | No       | Number          | 18      | The title's font size.                                                      |
| `options.title_offset`             | No       | Number          | 25      | The space between the title and the top edge.                               |
| `options.labels_inside_chart`      | No       | Boolean         | false   | Shows the labels inside the chart.                                          |
| `options.data`                     | Yes      | Object          | —       | The chart data below.                                                       |
| `options.data.ignore_falsy_values` | No       | Boolean         | —       | Removes sections, and their labels, whose value is 0.                       |
| `options.data.names`               | Yes      | List of strings | —       | The label for each section.                                                 |
| `options.data.names_font_size`     | No       | Number          | 14      | The labels' font size.                                                      |
| `options.data.values`              | Yes      | List            | —       | The value for each section: strings, numbers, `%(scope)` or `$(variables)`. |
| `options.data.values_font_size`    | No       | Number          | 14      | The values' font size.                                                      |
| `options.data.colors`              | No       | List of strings | black   | The colour of each section, as hex codes or system colour names.            |
| `options.width`                    | No       | Number          | 640     | The chart width, in pixels.                                                 |
| `options.height`                   | No       | Number          | 400     | The chart height, in pixels.                                                |
| `options.margin.top`               | No       | Number          | 0       | The space between the top of the chart and its boundary.                    |
| `options.margin.bottom`            | No       | Number          | 0       | The space between the bottom of the chart and its boundary.                 |
| `options.margin.left`              | No       | Number          | 0       | The space between the left of the chart and its boundary.                   |
| `options.margin.right`             | No       | Number          | 0       | The space between the right of the chart and its boundary.                  |

## Add a bar chart

A bar chart shows counts side by side. Set `orientation` to `horizontal` or `vertical`.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FrBiUmXWmCNljmS7FDtgK%2FScreenshot%202023-02-05%20at%203.09.59%20pm.png?alt=media&amp;token=f366fce4-5acb-4871-bc02-82dea7e179c7" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FQYj3PBqHkkw4NK0p51sy%2FScreenshot%202023-02-05%20at%203.15.49%20pm.png?alt=media&amp;token=1daf845c-938b-4623-b256-9dbebdac0956" alt="" width="563"><figcaption></figcaption></figure>

### Example 1: Horizontal bar chart showing unique vulnerabilities

This example uses existing tags, such as `{totalCriticalVulns}` and `{totalHighVulns}`, for the values.

```
{#json}{=< >=}</><%$chart[
   {
      “type”: “bar”,
      “name”: “unique_vulns_by_priority_bar_horizontal”,
      “options”: {
         “orientation”: “horizontal”,
         “title”: “Unique Vulnerabilities”, 
         “data”: {
            “names_label”: “Priority”,
            “names”: [
	       “critical”,
	       “high”,
	       “medium”,
 	       “low”,
   	       “info”
	    ],
            “values_label”: “Vulnerabilities”,
            “values”: [
               “%(totalCriticalVulns)”,
	       “%(totalHighVulns)”,
	       “%(totalMediumVulns)”,
	       “%(totalLowVulns)”,
	       “%(totalInfoVulns)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”,
	       “#00B050”
            ]
         },
         “width”: 400,
         “height”: 300
      }
   }
]><#json><={ }=>{/}
```

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FrBiUmXWmCNljmS7FDtgK%2FScreenshot%202023-02-05%20at%203.09.59%20pm.png?alt=media&amp;token=f366fce4-5acb-4871-bc02-82dea7e179c7" alt="" width="563"><figcaption></figcaption></figure>

### Example 2: Vertical bar chart showing unique vulnerabilities

The same as Example 1, with `orientation` set to `vertical`.

```
{#json}{=< >=}</><%$chart[
   {
      “type”: “bar”,
      “name”: “unique_vulns_by_priority_bar_vertical”,
      “options”: {
         “orientation”: “vertical”,
         “title”: “Unique Vulnerabilities”, 
         “data”: {
            “names_label”: “Priority”,
            “names”: [
	       “critical”,
	       “high”,
	       “medium”,
 	       “low”,
   	       “info”
	    ],
            “values_label”: “Vulnerabilities”,
            “values”: [
               “%(totalCriticalVulns)”,
	       “%(totalHighVulns)”,
	       “%(totalMediumVulns)”,
	       “%(totalLowVulns)”,
	       “%(totalInfoVulns)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”,
	       “#00B050”
            ]
         },
         “width”: 400,
         “height”: 300
      }
   }
]><#json><={ }=>{/}
```

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FQYj3PBqHkkw4NK0p51sy%2FScreenshot%202023-02-05%20at%203.15.49%20pm.png?alt=media&amp;token=1daf845c-938b-4623-b256-9dbebdac0956" alt="" width="563"><figcaption></figcaption></figure>

### Example 3: Bar chart using data from custom variables

This example counts internal findings by priority, stores each count in a variable, then charts the variables. Change `orientation` to switch between horizontal and vertical.

```
{$declare[CriticalInternalFindings][0]}
{$declare[HighInternalFindings][0]}
{$declare[MediumInternalFindings][0]}
{$declare[LowInternalFindings][0]}
{$declare[InfoInternalFindings][0]}
{#vulnerabilities | filterBy:’AffectedAssetCustomTags’:[‘Source:Internal’]}
{#priority == ‘Critical’}{$increment[CriticalInternalFindings][1]}{/}
{#priority == ‘High’}{$increment[HighInternalFindings][1]}{/}
{#priority == ‘Medium’}{$increment[MediumInternalFindings][1]}{/}
{#priority == ‘Low’}{$increment[LowInternalFindings][1]}{/}
{#priority == ‘Info’}{$increment[InfoInternalFindings][1]}{/}
{/}

{#json}{=< >=}</><%$chart[
   {
      “type”: “bar”,
      “name”: “unique_vulns_by_priority_bar_horizontal”,
      “options”: {
         “orientation”: “horizontal”,
         “title”: “Unique Vulnerabilities”, 
         “data”: {
            “names_label”: “Priority”,
            “names”: [
	       “critical”,
	       “high”,
	       “medium”,
 	       “low”,
   	       “info”
	    ],
            “values_label”: “Vulnerabilities”,
            “values”: [
               “$(CriticalInternalFindings)”,
	       “$(HighInternalFindings)”,
	       “$(MediumInternalFindings)”,
	       “$(LowInternalFindings)”,
	       “$(InfoInternalFindings)”
	    ],
            “colors”: [
               “#7030A0”,
	       “#FF0000”,
	       “#FFC000”,
	       “#0070C0”,
	       “#00B050”
            ]
         },
         “width”: 400,
         “height”: 300
      }
   }
]><#json><={ }=>{/}
```

The following chart is produced:

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FtBvonFx7BqxpxB3i3sdl%2FScreenshot%202023-02-05%20at%203.24.13%20pm.png?alt=media&amp;token=7d8aa3b6-0523-4e73-bdf3-9e2fa77ef3b4" alt="" width="563"><figcaption></figcaption></figure>

Switching horizontal to vertical will produce the following:

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FxcviKAgeb5AhAjM0JA9w%2FScreenshot%202023-02-05%20at%203.25.35%20pm.png?alt=media&amp;token=d194b883-4424-4740-9e22-5d607855669b" alt="" width="563"><figcaption></figcaption></figure>

### Bar chart options

| Option                                        | Required | Type            | Default                   | Description                                                                                 |
| --------------------------------------------- | -------- | --------------- | ------------------------- | ------------------------------------------------------------------------------------------- |
| `type`                                        | Yes      | String          | —                         | The chart type: `bar`.                                                                      |
| `name`                                        | Yes      | String          | —                         | A unique name for the chart.                                                                |
| `options`                                     | Yes      | Object          | —                         | The chart settings below.                                                                   |
| `options.orientation`                         | Yes      | String          | —                         | `vertical` or `horizontal`.                                                                 |
| `options.chart_color`                         | No       | String          | black                     | The colour of all labels and lines, as a hex code or system colour name.                    |
| `options.title`                               | No       | String          | —                         | Text shown above the chart.                                                                 |
| `options.title_font_size`                     | No       | Number          | 18                        | The title's font size.                                                                      |
| `options.title_offset`                        | No       | Number          | 25                        | The space between the title and the top edge.                                               |
| `options.data`                                | Yes      | Object          | —                         | The chart data below.                                                                       |
| `options.data.names_label`                    | No       | String          | —                         | The label for the names axis.                                                               |
| `options.data.names_label_font_size`          | No       | Number          | 18                        | The names label's font size.                                                                |
| `options.data.names_label_offset`             | No       | Number          | 5 vertical, 15 horizontal | The distance from the names label to the left edge (horizontal) or bottom edge (vertical).  |
| `options.data.names`                          | Yes      | List of strings | —                         | The label for each bar.                                                                     |
| `options.data.names_font_size`                | No       | Number          | 10                        | The names' font size.                                                                       |
| `options.data.values_label`                   | No       | String          | —                         | The label for the values axis.                                                              |
| `options.data.values_label_font_size`         | No       | Number          | 18                        | The values label's font size.                                                               |
| `options.data.values_label_offset`            | No       | Number          | 15 vertical, 5 horizontal | The distance from the values label to the bottom edge (horizontal) or left edge (vertical). |
| `options.data.values`                         | Yes      | List            | —                         | The value for each bar: strings, numbers, `%(scope)` or `$(variables)`.                     |
| `options.data.values_font_size`               | No       | Number          | 10                        | The values' font size.                                                                      |
| `options.data.colors`                         | No       | List of strings | black                     | The colour of each bar, as hex codes or system colour names.                                |
| `options.y_axis_increase_ticks_by_percentage` | No       | Number          | —                         | For vertical bars, raises the top of the y-axis by a percentage.                            |
| `options.width`                               | No       | Number          | 640                       | The chart width, in pixels.                                                                 |
| `options.height`                              | No       | Number          | 400                       | The chart height, in pixels.                                                                |
| `options.margin.top`                          | No       | Number          | 50                        | The space between the top of the chart and its boundary.                                    |
| `options.margin.bottom`                       | No       | Number          | 50                        | The space between the bottom of the chart and its boundary.                                 |
| `options.margin.left`                         | No       | Number          | 50                        | The space between the left of the chart and its boundary.                                   |
| `options.margin.right`                        | No       | Number          | 0 vertical, 10 horizontal | The space between the right of the chart and its boundary.                                  |

## Add a stacked bar chart

A stacked bar chart splits each bar into coloured groups, such as the severity of findings in each category. You set the groups and their colours once, then give each bar a value for every group.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FKnbhpNvKiximlmsjdQoY%2Fchart.png?alt=media&amp;token=5defcba0-4bb4-44c7-8d44-4dae61302486" alt=""><figcaption></figcaption></figure>

### Example 1: Vertical stacked bar chart

This example shows findings by severity for each category of the OWASP Top 10 API Security Risks 2023. The values are fixed numbers for illustration; in your template, use `%(scope)` or `$(variables)`.

```
{#json}{=< >=}</><%$chart[
    {
        “type”:“stacked-bar”,
        “name”:“all_vulns”,
        “options”: {
            “data”: {
                “names_label”: “OWASP Top 10 API Security Risks 2023”,
                “names”: [
                    “API1”,
                    “API2”,
                    “API3”,
                    “API4”,
                    “API5”,
                    “API6”,
                    “API7”,
                    “API8”,
                    “API9”,
                    “API10”
                ],
                "names_font_size":15,
                “groups”: {
                    “Critical”: “#001C57”,
                    “High”: “#1F3864”,
                    “Medium”: “#2F5496”,
                    “Low”: “#8EAADB”
                },
                “values_label”: “Vulnerabilities”,
                “values”:[
                    {
                        “Critical”: “1”,
                        “High”: “4”,
                        “Medium”: “6”,
                        “Low”: “8”
                    },
                    {
                        “Critical”: “0”,
                        “High”: “0”,
                        “Medium”: “3”,
                        “Low”: “5”
                    },
                    {
                        “Critical”: “0”,
                        “High”: “0”,
                        “Medium”: “0”,
                        “Low”: “1”
                    },
                    {
                        “Critical”: “6”,
                        “High”: “2”,
                        “Medium”: “1”,
                        “Low”: “5”
                    },
                    {
                        “Critical”: “9”,
                        “High”: “6”,
                        “Medium”: “7”,
                        “Low”: “4”
                    },
                    {
                        “Critical”: “2”,
                        “High”: “8”,
                        “Medium”: “9”,
                        “Low”: “2”
                    },
                    {
                        “Critical”: “6”,
                        “High”: “7”,
                        “Medium”: “0”,
                        “Low”: “2”
                    },
                    {
                        “Critical”: “0”,
                        “High”: “0”,
                        “Medium”: “0”,
                        “Low”: “0”
                    },
                    {
                        “Critical”: “0”,
                        “High”: “2”,
                        “Medium”: “7”,
                        “Low”: “8”
                    },
                    {
                        “Critical”: “1”,
                        “High”: “2”,
                        “Medium”: “8”,
                        “Low”: “0”
                    }
                ],
                "values_font_size":15
            },
            “y_axis_increase_ticks_by_percentage”: 20,
            “width”:700, 
            “height”:400, 
            "margin": {
                "top":10,
                "bottom":70,
                "left":80,
                "right":30
            }
        }
    }
]><#json><={ }=>{/}
```

### Stacked bar chart options

| Option                                        | Required | Type            | Default                   | Description                                                                             |
| --------------------------------------------- | -------- | --------------- | ------------------------- | --------------------------------------------------------------------------------------- |
| `type`                                        | Yes      | String          | —                         | The chart type: `stacked-bar`.                                                          |
| `name`                                        | Yes      | String          | —                         | A unique name for the chart.                                                            |
| `options`                                     | Yes      | Object          | —                         | The chart settings below.                                                               |
| `options.chart_color`                         | No       | String          | black                     | The colour of all labels and lines, as a hex code or system colour name.                |
| `options.title`                               | No       | String          | —                         | Text shown above the chart.                                                             |
| `options.title_font_size`                     | No       | Number          | 18                        | The title's font size.                                                                  |
| `options.title_offset`                        | No       | Number          | 25                        | The space between the title and the top edge.                                           |
| `options.data`                                | Yes      | Object          | —                         | The chart data below.                                                                   |
| `options.data.names_label`                    | No       | String          | —                         | The label for the names axis.                                                           |
| `options.data.names_label_font_size`          | No       | Number          | 18                        | The names label's font size.                                                            |
| `options.data.names_label_offset`             | No       | Number          | 5 vertical, 15 horizontal | The distance from the names label to the axis.                                          |
| `options.data.names`                          | Yes      | List of strings | —                         | The label for each bar.                                                                 |
| `options.data.names_font_size`                | No       | Number          | 10                        | The names' font size.                                                                   |
| `options.data.groups`                         | Yes      | Object          | —                         | Each group name, mapped to a hex colour.                                                |
| `options.data.values_label`                   | No       | String          | —                         | The label for the values axis.                                                          |
| `options.data.values_label_font_size`         | No       | Number          | 18                        | The values label's font size.                                                           |
| `options.data.values_label_offset`            | No       | Number          | 15 vertical, 5 horizontal | The distance from the values label to the axis.                                         |
| `options.data.values`                         | Yes      | List of objects | —                         | One object per bar, with a value for each group: a number, `%(scope)` or `$(variable)`. |
| `options.data.values_font_size`               | No       | Number          | 10                        | The values' font size.                                                                  |
| `options.y_axis_increase_ticks_by_percentage` | No       | Number          | —                         | For vertical charts, raises the top of the y-axis by a percentage.                      |
| `options.width`                               | No       | Number          | 640                       | The chart width, in pixels.                                                             |
| `options.height`                              | No       | Number          | 400                       | The chart height, in pixels.                                                            |
| `options.margin.top`                          | No       | Number          | 50                        | The space between the top of the chart and its boundary.                                |
| `options.margin.bottom`                       | No       | Number          | 50                        | The space between the bottom of the chart and its boundary.                             |
| `options.margin.left`                         | No       | Number          | 50                        | The space between the left of the chart and its boundary.                               |
| `options.margin.right`                        | No       | Number          | 0 vertical, 10 horizontal | The space between the right of the chart and its boundary.                              |

## Tips

* **Start from an example.** Copy the closest example, then change only the settings you need.
* **Give every chart a unique `name`,** especially when a template has more than one chart.
* **Use `ignore_falsy_values` on pie charts,** so priorities with no findings don't show empty labels.
* **Match your colours to your priorities.** Use the same hex codes in every chart and table, so readers learn them once.
* **Work out counts first.** Use functions and filters to count what you need into variables, then chart the variables.
* **Use straight quotes (") in Word.** Turn off Word's smart quotes when writing chart JSON.
* **Check your data with `$help`** if a chart is empty or shows the wrong numbers.

## FAQ

**Which version of ReportGen do I need?** v2.5.4 or later.

**What chart types are there?** Pie (including donut), bar (horizontal or vertical) and stacked bar.

**How do I make a donut chart?** Add `inner_radius` to a pie chart, such as `"inner_radius": 130`.

**Can I chart my own counts?** Yes. Count with functions such as `$declare` and `$increment`, then use the variables as values, such as `"$(CriticalInternalFindings)"`.

**Why is my chart blank?** Check that the wrapper is copied exactly, that `names` and `values` have the same number of items, and that your values aren't all 0.

**What units are width, height and margins in?** Pixels.

**Can I use system colour names instead of hex codes?** Yes, for `colors` and `chart_color`. Stacked bar `groups` use hex codes.

## Related pages

* [Reporting overview](https://support.attackforge.com/app/modules/reporting/overview)
* [Template functions](https://support.attackforge.com/app/modules/reporting/template-functions)
* [Template filters](https://support.attackforge.com/app/modules/reporting/template-filters)
* [Template tables](https://support.attackforge.com/app/modules/reporting/template-tables)
* [Template styles](https://support.attackforge.com/app/modules/reporting/template-styles)
* [ReportGen on GitHub](https://github.com/AttackForge/ReportGen)
* [Charts video walkthrough](https://youtu.be/g1BIGD_Qfi4)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.attackforge.com/app/modules/reporting/template-charts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
