# Show a visitor's scores in a chart at the end of a story

Source: https://knowledge.intractive.app/en/articles/chart

The **Chart** block shows each visitor a visual result based on their own answers. Use it to end a story, such as a quiz, with a personal result that leads each visitor to the content that fits them.

## How the chart works

The chart collects the results of your story and shows them visually. The results come from variables, so the chart shows what the visitor's own answers added up to.

For example, in a quiz about vacancies, every answer adds points to a vacancy. At the end, the chart shows the 3 vacancies that fit the visitor best. The visitor can open the vacancy they're interested in.

The chart is a horizontal bar chart with one bar per variable, highest first. Each bar shows its value, in points or as a percentage of the **Target value**. A visitor only has to select a bar when its variable has **Start branch** and **Allow Skip** is off. When a branch loops back, the visitor returns to the chart, the bars they chose show a check, and this goes on until all the branches are played. Otherwise the end setting of the branch applies.

\[screenshot: a chart in story preview showing a visitor's top 3 results\]

## Build the questions first

A chart needs something to show, so give your variables a value with questions before the chart. You create a variable on the **Variables** page (the button in the story's top bar) or from a block's **Set variables** window (**Logic** in the classic editor).

1. Create a **Number** variable for each result you want to show, on the **Variables** page.
2. Add content blocks that can set a variable, such as **Multiple Choice**, **True or False**, **Poll**, **Swipe Cards** or **This or That**.
3. Open **Set variables** on each of these blocks. On a **Multiple Choice** block, it's below the **Answers** list.

   \[screenshot: the Set variables window of a Multiple Choice block with points per answer\]
4. Connect every answer to a variable and give it a value. On a **Multiple Choice** block, pick a **Number** variable, then **Add** and the points.

## Set up the chart

1. Add a **Chart** block after the questions.

   \[screenshot: the block picker with the Chart block\]
2. Write the text above the chart in **Text**.
3. Optional: add a variable to the text, such as `{{@matching_score}}` (no spaces inside the braces), so the visitor sees their own score in a sentence.
4. Select **Add variable** for each variable you want to show.
5. Set the **Target value**. This is the value that counts as a full score, 100%: with a target value of 100, a variable with a value of 50 shows as 50%, half a bar. A bar never shows more than 100%. The target value isn't linked to the points in your questions, so to make 100% mean that everything scored, set it to the highest score a variable can reach.
6. Choose what happens when a visitor selects a variable, with **Action on click**.

![](https://storage.googleapis.com/intractive-knowledge-media/0281aadc973ad5e6d2bd079b59a3b3dc3e369b8d45406949953e341eadb51aa1.png)

> [!TIP]
> Note: previewing only the chart skips the blocks before it, so their variables are empty there. Preview the whole story to see the chart filled in.

## Settings per variable

| Setting | What it does |
| --- | --- |
| **Label** | The name the visitor sees in the chart. |
| **Text (if highest)** | A text with extra explanation, shown when this variable has the highest score, such as what the result means or a tip for a next step. |
| **Action on click** | What happens when the visitor selects this variable. With **Start branch** and a **Branch** chosen, the visitor goes to that branch, so every result can have its own content, such as one vacancy or one study programme. With **Do Nothing**, the bar can't be selected: the visitor sees the chart and the text of the highest variable, and nothing else happens. |

## Cut-off for long charts

With many variables, a long chart gets hard to read on a phone. Use the cut-off to show only the results that matter.

Set the cut-off with **Show items**:

| Option | What the visitor sees |
| --- | --- |
| **Only show first few options** | Only the top results, 5 by default, for example the best 3. Optional: add a **Show "Show more" button** that lets the visitor show all results. |
| **Hide items below score** | Results that score under the **Minimum score** are hidden. With a **Target value** set, the minimum score is a percentage of the target, from 0 to 100%. Without one, it is in points. The **Show "Show more" button** option also works here. |
| **Show all items** | All results, always. |

\[screenshot: the chart settings with Show items set to Only show first few options\]

> [!TIP]
> Tip: set **Show items** to **Only show first few options** to keep the chart short, for example the top 3 results.
