Skip to main content
Version: Next

Handlebars Chart

The Handlebars chart lets you render query results using a custom Handlebars template. This gives you full control over how your data is displayed — from simple tables to rich HTML layouts.

Basic Usage

In the chart editor, write a Handlebars template in the Template field. Your query results are available as data, an array of row objects.

{{#each data}}
<p>{{this.name}}: {{this.value}}</p>
{{/each}}

Built-in Helpers

Superset registers several custom helpers on top of the standard Handlebars built-ins.

dateFormat

Formats a date value using Day.js format strings.

{{dateFormat my_date format="MMMM YYYY"}}
OptionDefaultDescription
formatYYYY-MM-DDA Day.js-compatible format string

stringify

Converts an object to a JSON string, or any other value to its string representation.

{{stringify myObj}}

formatNumber

Formats a number using locale-aware formatting.

{{formatNumber myNumber "en-US"}}
OptionDefaultDescription
localeen-USA BCP 47 language tag

parseJson

Parses a JSON string into an object that can be used in your template.

{{parseJson myJsonString}}

groupBy

Groups an array of objects by a key, powered by handlebars-group-by.

{{#groupBy data "department"}}
<h3>{{value}}</h3>
{{#each items}}
<p>{{this.name}}</p>
{{/each}}
{{/groupBy}}

Helpers from just-handlebars-helpers

Superset also registers all helpers from the just-handlebars-helpers library. These include a wide range of comparison, math, string, and conditional helpers. Commonly used ones include:

Comparison

HelperDescriptionExample
eqStrict equality{{#if (eq status "active")}}
eqwWeak equality{{#if (eqw count "5")}}
neqStrict inequality{{#if (neq role "admin")}}
ltLess than{{#if (lt score 50)}}
lteLess than or equal{{#if (lte score 100)}}
gtGreater than{{#if (gt price 0)}}
gteGreater than or equal{{#if (gte age 18)}}

Logical

HelperDescriptionExample
andLogical AND{{#if (and isActive isVerified)}}
orLogical OR{{#if (or isAdmin isMod)}}
notLogical NOT{{#if (not isDisabled)}}
ifxInline conditional{{ifx isActive "Yes" "No"}}
coalesceReturns first non-falsy value{{coalesce nickname name "Anonymous"}}

String

HelperDescriptionExample
capitalizeCapitalizes first letter{{capitalize name}}
uppercaseConverts to uppercase{{uppercase status}}
lowercaseConverts to lowercase{{lowercase email}}
truncateTruncates a string{{truncate description 100}}
containsChecks if string contains substring{{#if (contains tag "urgent")}}

Math

HelperDescriptionExample
addAddition{{add a b}}
subtractSubtraction{{subtract total discount}}
multiplyMultiplication{{multiply price quantity}}
divideDivision{{divide total count}}
ceilCeiling{{ceil value}}
floorFloor{{floor value}}
roundRound{{round value}}

For the full list of available helpers, see the just-handlebars-helpers documentation.

Tips

  • Use raw blocks to escape Handlebars syntax if you need to display double curly braces literally.
  • Comparison helpers like eq must be wrapped in a subexpression when used with #if: {{#if (eq myVal "foo")}}.
  • HTML output is sanitized by default based on your Superset configuration (HTML_SANITIZATION).