> For the complete documentation index, see [llms.txt](https://guide.data.gov.sg/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.data.gov.sg/user-guide/for-data-owners/how-to-create-a-chart.md).

# How to create a chart

{% hint style="info" %}
Charts are only available for datasets with **a validated CSV file**. If you have not uploaded your data yet, see [How to publish data](/user-guide/for-data-owners/how-to-publish-data.md).
{% endhint %}

## Introduction

A chart gives people a quick read of your dataset before they download it or call the API. You create charts in the admin panel, on the same page you use to manage the dataset. Once the dataset is published, the chart appears on its public page.

You can create more than one chart per dataset.

## Before you start

**Your CSV must be uploaded and validated.** Until then the `Create chart` button is unavailable and the Charts section shows "No data available".

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2F5RwQpTni08Ej3TTvXnRL%2Fimage.png?alt=media&amp;token=94211d35-e5b9-4d61-a3d1-76e54e21921f" alt=""><figcaption></figcaption></figure>

**One row per observation works best.** The editor reads your data down the rows, so each row should be a single observation with one column per variable. Data laid out with years or categories as separate columns needs reshaping before you upload it.

Harder to chart – each year is its own column:

| Region | 2023   | 2024   |
| ------ | ------ | ------ |
| North  | 14,384 | 15,120 |
| South  | 9,201  | 9,876  |

Ready to chart – one row per observation:

| Region | Year | Value  |
| ------ | ---- | ------ |
| North  | 2023 | 14,384 |
| North  | 2024 | 15,120 |
| South  | 2023 | 9,201  |
| South  | 2024 | 9,876  |

**Display Names fill in your axis labels.** The Display Names you set during validation are reused as axis labels, so `facility_size` becomes "Facility Size" without you retyping it. Setting good Display Names before you start saves work here.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FBvvPDSYeFsnr5Zq5mcTt%2Fimage2.png?alt=media&amp;token=cd2b4329-5f48-42d9-89cd-d5f121748c3d" alt=""><figcaption></figcaption></figure>

Your column types are detected when you upload, and they decide which controls the editor offers:

| Column contains                                        | Detected as | Control you get on the X-axis |
| ------------------------------------------------------ | ----------- | ----------------------------- |
| Numbers, with or without thousands separators (14,384) | Number      | Range                         |
| Dates in one of the six supported formats              | Date        | Range                         |
| Anything else – names, categories, codes               | Text        | Sort                          |

The Y-axis only accepts number columns, because it has to add up or average what you give it. Group by accepts any column type.

## Chart type

| Chart type  | Best for                                          | Example                        |
| ----------- | ------------------------------------------------- | ------------------------------ |
| Bar         | Comparing values across categories                | Applications by town           |
| Line        | Change over a time period                         | Monthly rainfall, 2010 to 2025 |
| Area        | Change over time where the overall volume matters | Cumulative registrations       |
| Stacked bar | How parts add up to a total                       | Intake by course, by year      |

New charts start as Bar. You can change the type at any point without losing your other settings.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2F0XQc33AB4fUu6EqVSJlE%2Fimage3.gif?alt=media&amp;token=1f0f9193-13df-4a9f-83df-bf7ea731ec98" alt=""><figcaption></figcaption></figure>

## Step 1: Create your chart

1. In the admin panel, open your dataset and scroll down to the Charts section.
2. Click `Create chart`. The chart editor opens on the right, with a live preview beside it. The preview updates as you fill the form in.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FIZ9mbGVn6zvXDrRz60Xw%2Fimage4.gif?alt=media&amp;token=218515f6-03c4-424a-8060-4b366a954abf" alt=""><figcaption></figcaption></figure>

3. Choose a **Chart type**.
4. Enter a **Title (optional)**. The title gets auto-populated when you select the X-axis and Y-axis. You can overwrite it by filling in the Title field.
5. Under **X-axis**, choose the **Column** for the horizontal axis. This is usually a time period or a category. The **Label** fills in from that column's Display Name – edit it if you want different wording, or clear it to leave the axis unlabelled.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FRCjbHYu1nAheok9CyH83%2Fimage5.gif?alt=media&amp;token=f0cd9fd2-b614-4e35-9582-2f7ea8647fcc" alt=""><figcaption></figcaption></figure>

6. Under **Y-axis**, choose the **Column** for the vertical axis, then choose a **Measure**. The measure tells the editor what to do when several rows share the same X-axis value.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FrMizliTDjJKJ5Fr9pfUX%2Fimage6.gif?alt=media&amp;token=43402836-0d95-4bea-98f3-0b377db195eb" alt=""><figcaption></figcaption></figure>

| Measure  | What it plots                           |
| -------- | --------------------------------------- |
| Sum      | All values added together – the default |
| Count    | How many rows there are                 |
| Min      | The lowest value                        |
| Max      | The highest value                       |
| Average  | The mean of the values                  |
| Distinct | How many different values there are     |

7. To draw one series per category, choose a column under **Group by**.

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FCFeBRsnCWmrnsFhLJ4Ci%2Fimage7.gif?alt=media&amp;token=81221e69-8635-44f0-9f5f-bca29bc514d0" alt=""><figcaption></figcaption></figure>

8. Check the preview, then click `Create`.

{% hint style="info" %}
For large datasets, **the editor previews your chart on a subset of the rows** and tells you so above the preview. **The saved chart uses the whole dataset.**
{% endhint %}

## Step 2: Check and publish

Your chart is saved to the dataset as soon as you click `Create`, but it only becomes visible to the public when the dataset is published. See [How to publish data](/user-guide/for-data-owners/how-to-publish-data.md).

To add another chart, click `Create chart` again. When a dataset has more than one chart, thumbnails appear below it – click one to switch between them.

To change a chart you have already saved, see [How to edit a chart](/user-guide/for-data-owners/how-to-edit-a-chart.md).

<figure><img src="https://2014478147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fksq6aNCGbng1fqooERfi%2Fuploads%2FjPkcQmSIAfWcAHe97pSe%2Fimage8.gif?alt=media&amp;token=fd28283b-ee31-4830-a79d-7fbbfc69a483" alt=""><figcaption></figcaption></figure>

## Common issues

| What you see                                       | Likely cause                                 | What to try                                                                                      |
| -------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `Create chart` is unavailable, "No data available" | The dataset has no validated CSV             | Upload and validate a CSV first                                                                  |
| My column is missing from the Y-axis list          | The Y-axis only lists number columns         | Check the column holds numbers – empty cells and markers like "n/a" are fine, but text is not    |
| The preview stays empty                            | X-axis or Y-axis is not filled in            | Both are required before a chart can render                                                      |
| Dates are in the wrong order                       | The date column is not in a supported format | Reformat it to `YYYY`, `YYYY-MM`, `YYYY-MM-DD`, `YYYY-QN`, `YYYY-HN` or `YYYY-WNN` and re-upload |

For further queries feel free to reach out to us: [Contact the Data.gov.sg team](https://form.gov.sg/6449e5c3664c1b001249acf1).
