Skip to content

Components

Every tag, with its attributes. The tags are the same in the three setups; one script makes them work:

<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>
Tags
Charts <bar-chart> <line-chart> <pie-chart> <doughnut-chart>
Key figures <score-card> <simple-value>
Tables <data-table>
Filters <date-range-filter> <ui-filter>
Data sources <source-table> <source-view> <source-api>
Explore a table <bar-chart-grid> <tables-list-chart> <table-description-chart>

The examples of this page are live. They form one dashboard, a static page on a CSV file of orders: click a bar, a slice or a row and everything else on the page is filtered.

<source-table
  name="orders"
  url="orders.csv"
  columns="*, date_trunc('month', date) as month"
  date-column="date">
</source-table>

Naming data: two ways

A component names what it shows in one of two ways. The table attribute decides.

With table: SQL expressions Without table: named measures
Example <bar-chart table="orders" measure="sum(revenue)" by="country"> <bar-chart measure="revenue" by="country">
measure is Any SQL aggregate: sum(revenue), count(distinct customer), sum(a) / sum(b) A name your server knows: revenue
by is A column or a SQL expression: country, date_trunc('month', date) A name your server knows: country
Who computes it The database named by table Your server, its own way
Used in A static page; a sandbox, if you allow it Your backend; a sandbox

The examples below use SQL expressions, since this page has no server. With named measures the same tags are shorter, and get a few more attributes: see the last column and the dashboard on a FastAPI backend.

Common attributes

Shared by charts, key figures and tables.

Attribute SQL expressions Named measures
table The table to query: a <source-table> or <source-view> of the page, or a table your Host exposes. Its presence selects SQL expressions. ✓
measure What to compute. One per chart or key figure. ✓ ✓
measures Several, separated by commas. <data-table> only. ✓ ✓
by The dimension to split by. Clicking one of its values filters the other components. ✓ ✓
breakdown-by A second dimension: one series per value. ✓ ✓
sort-by A measure or a dimension, with an optional direction: sort-by="sum(revenue) desc". Also written order_by. ✓ ✓
limit The number of rows. ✓ ✓
format eur, pct, int or dec: see number formats. With named measures, your server can give it. ✓ ✓
title A title above the component. ✓ ✓
where A SQL condition for this component only. Static page only. ✓
date-column The column the period applies to, when it is not the one of the table. ✓
breakdown-limit With breakdown-by: how many series to keep, the biggest first (6). ✓
granularity A time series: day, week, month, quarter or year, with no by. ✓
compare A comparison with another period: yoy, mom or prev_period. ✓
attributes Columns that describe a dimension, for a table: attributes="city, manager". ✓ ✓
param-* Anything else your server understands: param-scope="like_for_like". ✓ ✓

An alias gives the displayed name of an expression: measure="sum(revenue) as Revenue".

granularity and compare written without a value follow the page: a <ui-filter option="date_granularity"> or <ui-filter option="period_comparison_method"> then drives every component at once.

Charts

Charts take height (400px by default) and hide-axis-names. Without sort-by, a chart follows its dimension (time, then A to Z); horizontal bars and pies show the biggest values first.

Bar chart

<bar-chart
  table="orders"
  measure="sum(revenue)"
  by="country"
  sort-by="sum(revenue) desc"
  format="eur"
  height="300px">
</bar-chart>

horizontal makes a ranking, limit keeps the first rows:

<bar-chart
  table="orders"
  measure="count(*)"
  by="category"
  limit="5"
  format="int"
  height="220px"
  horizontal>
</bar-chart>

breakdown-by makes one series per value, side by side or stacked:

<bar-chart
  table="orders"
  measure="sum(revenue)"
  by="month"
  breakdown-by="channel"
  format="eur"
  height="300px"
  stacked>
</bar-chart>

Line chart

A dimension holding dates gets a time axis.

<line-chart
  table="orders"
  measure="sum(revenue)"
  by="month"
  breakdown-by="category"
  format="eur"
  height="300px">
</line-chart>

stacked adds the series up. With named measures, a time series needs no by, and compare draws the other period as a dashed line:

<line-chart measure="revenue" granularity="month" compare="yoy"></line-chart>

Pie and doughnut chart

<pie-chart table="orders" measure="count(*)" by="channel" height="260px"></pie-chart>

<doughnut-chart table="orders" measure="sum(revenue)" by="customer_type" format="eur" height="260px"></doughnut-chart>

Key figures

Score card

One figure with its title. Without title, the name of the measure is used, or the label your server gives.

<score-card title="Revenue" table="orders" measure="sum(revenue)" format="eur"></score-card>
<score-card title="Orders" table="orders" measure="count(*)" format="int"></score-card>
<score-card title="Average order" table="orders" measure="avg(revenue)" format="eur"></score-card>

With named measures, compare adds a colored badge with the variation against the other period:

<score-card measure="revenue" compare="yoy"></score-card>

format also takes a spreadsheet pattern here: format="#,##0.0".

Simple value

The figure alone, to place in a sentence or a title.

The shop took orders from countries.

The shop took <simple-value table="orders" measure="count(*)" format="int"></simple-value> orders
from <simple-value table="orders" measure="count(distinct country)"></simple-value> countries.

Tables

Data table

Several measures, with columns always shown in the declared order: dimensions, attributes, measures. Click a column header to sort, click a row to filter the other components (Ctrl / Cmd + click to select several rows).

<data-table
  table="orders"
  by="country"
  measures="sum(revenue) as Revenue, count(*) as Orders, round(avg(revenue), 2) as Average"
  formats="Revenue:eur, Orders:int, Average:eur"
  sort-by="Revenue desc">
</data-table>
Attribute
by One or several dimensions: by="country, channel". A click on a row filters on the first.
measures Several measures. Commas inside parentheses do not split: round(avg(revenue), 2) is one measure.
formats A format per column: formats="Revenue:eur, Orders:int".
max-height The height from which the table scrolls, under a fixed header: max-height="400px".

Filters

Filters apply to the whole page: every component asks again with the new selection.

Period

Quick presets and two dates. It applies to the tables that declare a date-column, or is sent to your server.

<date-range-filter presets="all,30d,90d,365d,ytd" max="2026-11-30"></date-range-filter>
Attribute
presets Among all, 7d, 30d, 90d, 365d (any number of days), mtd and ytd.
max The last day of the presets, when it is not today: the last day of your data.
default The period at start: a preset (default="90d") or two dates (default="2026-06-01, 2026-11-29").

Dimension filter

<ui-filter dimension="channel" type="segmented" table="orders" label="Channel"></ui-filter>
<ui-filter dimension="category" type="select" table="orders" label="Category"></ui-filter>
<ui-filter dimension="customer_type" value="Returning" type="toggle" label="Returning customers only"></ui-filter>
Attribute
dimension The dimension to filter on.
type select (default), segmented (buttons) or toggle (a checkbox).
options The choices: options="Web, Store", or with labels options="web:Online, store:In store". Without it, the values are read from the data: from table, or asked to your server.
table Where to read the values, with SQL expressions.
label The text before the control. label="" for none.
multiple A select that takes several values.
value For a toggle on a dimension: the value it filters on.
default The selection at start: default="Web", default="Web, Store".

Option of the page

With option instead of dimension, the control sets an option of the page rather than a filter. Two options are known to the components, and you can add your own:

<!-- Drives every component written with `granularity` and no value -->
<ui-filter option="date_granularity" type="segmented" options="week:Week, month:Month" default="month"></ui-filter>

<!-- Drives every component written with `compare` and no value -->
<ui-filter
  option="period_comparison_method"
  type="segmented"
  options="prev_period:vs previous period, yoy:vs last year"
  default="yoy">
</ui-filter>

<!-- A switch of your own, read by your server -->
<ui-filter option="exclude_discounts" type="toggle" label="Exclude discounted orders"></ui-filter>

How your server reads an option of your own: Your own parameters.

Data sources

Invisible elements that say where the data comes from. A page has either <source-table> and <source-view> elements, or one <source-api>. A dashboard in a sandbox has none: its Host answers.

Source table

Loads a file, or records given by a script, into the database of the browser: the static page setup.

<source-table name="orders" url="orders.parquet" columns="*, revenue - cost as margin" date-column="date"></source-table>
Attribute
name The name components use in table="...".
url A Parquet, CSV or JSON file, or an API that returns JSON.
columns The columns to keep or compute, as in a SQL select. * by default.
date-column The column the period of the page applies to.
format parquet, csv, tsv or json, when the address does not end with it.

Without url: set element.data = records, then call element.load(true). It emits data-loaded when its data is ready.

Source view

A SQL query over the tables of the page, used as a table.

<source-view name="top_days">
  select date, sum(revenue) as revenue from orders group by 1 order by 2 desc limit 5
</source-view>

name and date-column as above. A script reads it with window.dashboard.query('top_days').

Source API

Sends the queries of the page to your server, one POST per render: the backend setup. The components then use named measures.

<source-api url="/api/queries" body='{"workspace": "emea"}'></source-api>
Attribute
url Where the queries go, relative to the page.
body A JSON object added to every request.
credentials same-origin (default) or include, for an API on another site.

Its headers and body properties take an object or a function: see Who is looking.

Explore a table

Three components to look at a dataset before building its dashboard.

Bar chart grid

One small chart per dimension, all filtering each other. Without by, every text column of the table gets its chart.

<bar-chart-grid
  table="orders"
  measure="count(*)"
  by="country, channel, category, customer_type"
  limit="6"
  horizontal>
</bar-chart-grid>

With SQL expressions, each chart shows shares of the total, and the tool at its top right breaks the other charts down by its dimension.

Tables and columns

In a static page, <tables-list-chart> lists the tables of the page and <table-description-chart> the columns of one:

<table-description-chart table="orders"></table-description-chart>

What every component does

  • It waits. A grey placeholder is shown until the first answer, and the content is dimmed while a new one loads.
  • It says when there is nothing: "No data" for an empty answer.
  • It shows its error: an unknown table or measure, a refused query. The text comes from the database or from your server, and it is what to give back to a model that wrote the dashboard.
  • It filters the page: a click on a value of its by dimension selects it, Ctrl / Cmd + click adds to the selection, a second click or a click on the background removes it. The clicked component keeps showing every value, with the selection highlighted.
  • It follows the theme of the page: see Theme, formats, language.

When no component fits, write the chart yourself: Custom charts and scripts.