Skip to content
  • There are no suggestions because the search field is empty.

Create a Handlebars chart

A Handlebars chart displays your data as custom, styled content, such as program impact summaries, quote cards, or story highlights that a bar or line chart can't show. You add a template that pulls in your data, plus optional styles, and an LLM can write that code for you.

Before you start:

  • Ensure your UpMetrics login is assigned an Org Admin or Editor role.
  • Confirm the data you want to use is in Collect and ready for Advanced Analytics. This can be a standard data table or a Stories data set. For details, see Prepare your data for Advanced Analytics.
  • Have access to an LLM to help write the template, unless you're comfortable writing HTML, CSS, and Handlebars yourself.

How Handlebars charts work

A Handlebars chart has two code fields on the Customize tab. The Handlebars Template field holds HTML plus Handlebars syntax that pulls in your data, and the CSS Styles field holds optional styling such as fonts, colors, and spacing. Until you add a template, the preview shows your raw data as JSON.

In the template, {{this.column_name}} inserts the value of a column, and {{#each data}} ... {{/each}} repeats the content once for each row of data. Column names in the template must match your data exactly, including capitalization and spaces.

When you set up the chart, you also choose a query mode:

Query mode Use it for Where you add fields
Aggregate Showing summarized data, such as counts or totals Dimensions field
Raw records Showing each record exactly as it appears in the data table, including Stories data Columns field, with an Ordering field to sort the records

Handlebars charts

Set up the chart and its data

  1. From the Charts tab or your dashboard, click + in the upper right corner and select Chart. The Create a new chart screen displays.
  2. Select your data table or Stories data from the Choose a data table drop-down list and the Handlebars chart type, then click Create new chart. The chart builder displays.
  3. Enter a descriptive name for the chart at the top of the window, then under Query mode, select Aggregate to show summarized data, or Raw records to show each record exactly as it appears in the data table.
  4. Drag the fields you want to display from the Columns list to the Dimensions field (Aggregate) or the Columns field (Raw records).
  5. If you're using Raw records, select the field and direction to order the records from the Ordering drop-down list.
    The Handlebars chart builder with Raw records query mode, title, story_date, and summary_plain in the Columns field, and Ordering set to story_date descending, and three stories as raw JSON in the preview.
  6. (Optional) Limit the number of rows or filter the data (see Data options below), then click Create chart. Your raw data displays as JSON in the preview area.
    The Handlebars chart builder with Aggregate query mode, two columns in the Dimensions field, and Row limit set to 5, and five rows of raw JSON data in the preview.

Note: If you display the codes assigned to stories, each story appears once for every code it has. Using codes as filters doesn't cause this.

Add a template and styles

Warning: Before you paste any data or column names into an LLM, follow your organization's policies on data privacy and use of LLMs.

  1. Click the Customize tab. The Handlebars Template and CSS Styles fields display.
  2. In your LLM, enter a prompt like the following. Replace the bracketed text with your column names and a detailed description of how you want the data to look, including borders, fonts, spacing, line breaks, colors, and where each field goes. If you're using Stories data, include the last line so dates display as month, day, and year (for example, Jan 05, 2026).

    I am building a Handlebars chart in UpMetrics Advanced Analytics. The chart has two fields: a Handlebars Template field (HTML + Handlebars syntax) and a separate CSS Styles field. I can either style everything with inline styles directly in the HTML template or use the CSS Styles field with class names. Use whichever approach is cleaner for my use case.

    Use Handlebars syntax to reference data fields, for example {{this.column_name}}, and wrap iteration in {{#each data}} ... {{/each}}.

    My data has the following columns: [column names]

    I want to display: [detailed description]

    Give me the Handlebars Template and CSS Styles separately if you use classes, or a single Handlebars Template with inline styles if that's simpler.

    (Stories data only) Please insert the following code into the appropriate location in the Handlebars Template code: {{dateFormat this.story_date format="MMM DD, YYYY"}}

  3. Delete the default code in the Handlebars Template and CSS Styles fields. Paste the template from the LLM into Handlebars Template, and if the LLM gave you CSS, paste it into CSS Styles. Check that each field contains only the code from the LLM, with nothing extra copied by mistake. The closing </div> tag at the end of the Handlebars Template needs a line return after it. If you type code directly into either field, the editor adds closing tags and braces for you, so delete any extras.
  4. Click Update chart. Your formatted chart displays in the preview area.
    The Customize tab with a template in the Handlebars Template field and CSS in the CSS Styles field, and a preview listing each business name as a blue heading with a blue left border.
  5. Keep adjusting your data, prompt, and code until the chart looks the way you want, clicking Update chart after each change. If you get errors or the display doesn't look right, tell the LLM what's wrong. Sharing a screenshot of your results helps it find the problem.
  6. Click Save. In the Save chart dialog box, enter or edit the name in the Chart name field, select a dashboard from the Add to dashboard drop-down list or enter a name for a new one (optional), then click Save or Save & go to dashboard.

Data options

Use these options in the Data area to control which data your Handlebars chart shows. Click Create chart or Update chart to see the result.

Option Applies to What it does
Row limit Both query modes Limits the number of rows that display in the chart.
Filters Both query modes Shows only the data you choose. Drag a field from the Columns list to the Filters field, then select the field, an operator (such as in, equal to, or greater than), and one or more values, and click Save.
Ordering Raw records Sets which field orders the records and in which direction.

Handlebars chart best practices

Keep these practices in mind when you design Handlebars charts:

  • Start simple. Display one field first, then add more. Add your columns in the Data area first, then reference them in the template with {{this.column_name}}.
  • Match field names exactly. Column names in your template must match the data set exactly, including capitalization and spaces.
  • Use CSS to make it look polished. Set font sizes, colors, and spacing in the CSS Styles field to make your output professional and on-brand.
  • Think about your audience and the story you're telling. Handlebars works best when a bar or line chart can't capture what you need to say, such as a narrative summary.
  • Test your template often. Click Update chart after each change to see the output and catch errors early.

Needs improvement: This chart shows the default list output with raw JSON. It has no styling, shows field names instead of labels, and has no visual hierarchy.

A Handlebars chart titled Program Roster that shows raw JSON records as a bulleted list, with no styling.

Improved: This version adds HTML structure and CSS styling. Each business name is a blue heading, with its location and category below and a left border to set it apart.

A styled Handlebars chart listing businesses interested in partnership and networking, each with a blue name, a location, and a category, set off by a left border.

Learn more about Handlebars, HTML, and CSS

These third-party resources can help you understand the code behind Handlebars charts:

Related articles