Skip to content

Get started

A dashboard is a few HTML tags: <score-card>, <bar-chart>, <data-table>, <ui-filter>. A tag says what to show; it does not know where the data comes from. That part is yours to choose, and there are three setups.

Choose your setup

Two questions decide:

  1. Who writes the dashboard? You, or someone you cannot trust with your page: a language model, another user.
  2. Where is the data? In files the browser may download, or behind your server.
Who writes the dashboard Where the data is Setup
A report, a documentation page, a prototype You Files anyone opening the page may read 1 · Static page
The dashboards of your product You Behind your server, with access rules 2 · Your backend
Generative BI, dashboards built by your users A model, or your users Behind your server, with access rules 3 · Sandbox

New to the project? Do the static page first: five minutes, no server, and every other setup uses the same tags.

1 · Static page

Your pageThe tags, written by you
SQL, built by the components
DuckDB-WASMA database inside the browser
downloads once
Data filesCSV, Parquet, JSON, or records pushed by a script
<source-table name="orders" url="orders.csv" date-column="date"></source-table>

<score-card title="Revenue" table="orders" measure="sum(revenue)" format="eur"></score-card>
<bar-chart table="orders" measure="sum(revenue)" by="country"></bar-chart>

<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>
  • You add <source-table>, and table="..." on each component. Measures are SQL expressions.
  • Choose it when the data fits in a file and may be read by everyone who opens the page.
  • No backend: any static host works, including a Markdown site such as this one.

Static page guide Live example

2 · Your backend

Your pageThe tags, written by you
one POST per render: "revenue by country"
Your APIChecks each query, applies the rights of the signed-in user
your SQL
Your dataWarehouse, database, semantic layer
<source-api url="/api/queries"></source-api>

<score-card measure="revenue" compare="yoy"></score-card>
<bar-chart measure="revenue" by="country"></bar-chart>

<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>
  • You add <source-api>, and one endpoint on your server. Measures are names your server knows: no table, no SQL in the page.
  • Choose it when you write the dashboards yourself and the data must stay on your server.
  • Not for a dashboard written by someone else: its scripts would run in your page. That is setup 3.

Backend guide Live example

3 · Sandbox

Sandboxed frameThe dashboard, written by a model or a user. No network, no access to your page
asks: "revenue by country"
Your pageembedDashboard validates each query, then calls your resolveQuery
your call
Your APIChecks again, applies the viewer's rights, answers
import { embedDashboard } from 'https://unytics.io/bi-components/dist/bi-components-host.js';

embedDashboard(document.getElementById('dashboard'), {
  html: dashboardHtml,                       // written by a model or a user: untrusted
  resolveQuery: (query) => fetch('/api/query', { method: 'POST', body: JSON.stringify(query) }).then((r) => r.json()),
});
  • You add one call to embedDashboard in your page, and a function that answers a query.
  • Choose it when you do not write the dashboard: a model generates it, or your users build and share their own.
  • What you get: the dashboard can only ask your page for data. It cannot read your page, your cookies or the network, and it sees what its viewer may see, whoever wrote it.

Sandbox guide Generative AI guide Playground

Side by side

1 · Static page 2 · Your backend 3 · Sandbox
Dashboard written by You You A model, your users
Queries answered by DuckDB-WASM, in the browser Your server Your server, through your page
What you add <source-table> <source-api> and one endpoint embedDashboard() and resolveQuery
File to load bi-components.js bi-components.js bi-components-host.js
Measures are SQL expressions Names your server knows Names, or SQL expressions you allow
Access rules None: the file is public Your server Your server
Server code None One endpoint Usually one endpoint

An application often uses two of them: setup 2 for the dashboards its team writes, setup 3 for those its users generate. Both can call the same endpoint.

Two ways to name data

The tags are the same everywhere. What changes is how a component names what it wants, and the table attribute decides:

With table: SQL expressions Without table: named measures
A component <bar-chart table="orders" measure="sum(revenue)" by="country"> <bar-chart measure="revenue" by="country">
Who knows what revenue means The page: it is written there Your server: a semantic layer, dbt metrics, SQL views
Extras Any SQL aggregate or expression, where compare="yoy", granularity="month", formats and labels given by the server
Works in Static page; sandbox, if you allow it Your backend; sandbox

Named measures give one definition of each figure, and they are what a language model handles best. SQL expressions need no definition at all. Components lists the attributes of both.

How it fits together

Every component, and every script you write, talks to a single object: window.dashboard. It runs queries and holds the filters, the period and the theme. Each setup installs its own version of it, which is why a dashboard does not change when the setup does.

 <score-card>  <bar-chart>  <data-table>  <ui-filter>  your scripts
        \           |            |            |           /
         +---------------- window.dashboard ---------------+
              |                    |                    |
       1 · Static page       2 · Your backend       3 · Sandbox
       <source-table>        <source-api>           embedDashboard()
       DuckDB-WASM           POST to your API       postMessage to your page

Next

  • Components: every tag and its attributes, with live examples.
  • Answer the queries: what your server receives and what it returns, for setups 2 and 3.
  • Generative AI: the system prompt and the loop that make a model write dashboards.
  • Install and versions: the two files, a CDN or npm, pinning a version.
  • Examples: working pages for each setup, with their source.