Skip to content

BI Components vs Mosaic

Mosaic and BI Components share an architecture: a chart does not hold data, it asks for it. Each component of a page describes what it needs, something central collects the questions, a database answers, and a selection made on one chart filters the others. Both are open source, and both can run on DuckDB in the browser, with no server.

They were built for different problems:

  • Mosaic is a framework for exploring very large data. It comes from two research labs (the University of Washington and Carnegie Mellon). You write JavaScript or Python, with a grammar of graphics: marks, scales, interactors. Its coordinator rewrites and caches queries so that brushing a histogram of a billion rows stays fluid.
  • BI Components is a set of HTML tags for business dashboards. You write <score-card> and <bar-chart> in a page of your application. The question it answers is who may ask what: queries are checked, the server that answers is yours, and the dashboard can be written by a model or by one of your customers.
Choose Mosaic Choose BI Components
You are building A tool to explore data: millions of rows, brushing, density, maps A dashboard in a product: key figures, comparisons, breakdowns
Who writes it Developers and data scientists, in JavaScript or Python Anyone who writes HTML, or a model
Who reads it People trusted with the whole database The users of your application, each with their rights
Who answers the queries DuckDB: in the browser, in a notebook, or behind a data server Your backend, whatever it queries, or DuckDB in the browser
The hard part it solves Speed at scale Safety, and as little to learn as possible

This page was written in December 2026, from the source of Mosaic 0.35.1 and its documentation. Mosaic describes itself as an active research project and releases often: check its documentation for what changed since.

The same dashboard, twice

Revenue by country and by month, on a CSV file, with a filter on the channel. Both run in the browser on DuckDB-WASM.

import * as vg from "@uwdata/vgplot";

vg.coordinator().databaseConnector(vg.wasmConnector());
await vg.coordinator().exec(vg.loadCSV("orders", "orders.csv"));

const $filter = vg.Selection.crossfilter();
const orders = vg.from("orders", { filterBy: $filter });

document.body.append(vg.vconcat(
  vg.menu({ label: "Channel", from: "orders", column: "channel", as: $filter }),
  vg.plot(
    vg.barY(orders, { x: "country", y: vg.sum("revenue"), fill: "steelblue" }),
    vg.toggleX({ as: $filter })
  ),
  vg.plot(
    vg.areaY(orders, { x: vg.dateBin("date", "month"), y: vg.sum("revenue") }),
    vg.intervalX({ as: $filter })
  )
));

A module, bundled with your application. The same thing can be written as a YAML or JSON specification, or in Python.

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

<ui-filter table="orders" dimension="channel"></ui-filter>
<bar-chart table="orders" measure="sum(revenue)" by="country"></bar-chart>
<line-chart table="orders" measure="sum(revenue)" by="month"></line-chart>

<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>

A piece of any HTML page. A click on a bar filters the rest; nothing says so in the code.

The Mosaic version says more: which selection each chart follows, which gesture feeds it (a click on the bars, a brush on the time axis). The BI Components version says less, and decides the rest.

What each one does

Mosaic BI Components
A dashboard is JavaScript or Python code, or a YAML / JSON specification HTML, with custom elements
Charts A grammar: some 40 marks to layer (bars, lines, areas, dots, cells, text, rules, maps, density, contours, hexbins, rasters, regression), facets, projections. No pie. Four finished charts: bar, line, pie, doughnut. Others with your own ECharts code
Drawn with Observable Plot (SVG) Apache ECharts (canvas)
Key figures None Score card, with a comparison to another period
Tables Sortable, loaded as you scroll Sortable, several dimensions and measures
Inputs Menu, search with completion, slider Period, select, buttons, toggle
Select on a chart Click, brush an interval in one or two dimensions, nearest point, pan and zoom, click on a legend Click on a bar, a slice or a row
Who follows a selection What you wire: any number of selections, each resolved as a union, an intersection or a cross-filter Everything: one selection for the page, as a cross-filter
Values in expressions Params: a slider changes a value inside a SQL expression Options of the page, sent to your server
Named measures None: SQL expressions only Yes: the page sends names, your server defines them
Numbers, theme, language Formats of d3; styles through CSS Formats for currencies and percentages, light and dark, locale
Database DuckDB only. Others through DuckDB (ATTACH) Any: your server answers. DuckDB-WASM in a static page
Very large data Its purpose: pre-aggregated tables, pixel-aware queries, Arrow What your database does with one group by per component
Rights of the viewer None: the page sends SQL statements Checked for every query, by your server
Untrusted authors Not a goal The sandbox
Notebooks A Jupyter and marimo widget, a Python API A Streamlit component
Frameworks Your own client in React, Svelte or Vue, with makeClient The tags, as they are
License, version BSD. 0.35, with breaking changes between minor versions MIT. 1.4

When to use which

You explore millions of rows, and the interaction must stay fluid. Use Mosaic. Brushing ten million flights in the browser, or a billion rows with a DuckDB server, is what it was designed for, and BI Components has nothing like it: each selection is a new group by on the whole table.

You need statistical or scientific graphics. Use Mosaic: density, contours, hexbins, regression lines, rasters, map projections, small multiples. BI Components draws bars, lines and pies.

You work in a notebook. Use Mosaic. Its widget draws on a DuckDB connection, a pandas or a Polars data frame, in Jupyter and marimo.

You are building a dashboard for the users of a product. Use BI Components. Mosaic has no score card, no comparison with last year, no named measure, no currency format: you would write them. More importantly, a Mosaic page sends SQL statements to its data server, which runs them. That suits a tool for people trusted with the database, not a page open to customers who must each see their own rows.

A model writes the dashboard. Use BI Components. The model writes HTML with a dozen tags, and your application shows it in a sandbox where it can only ask for what the viewer may see. A Mosaic specification is easy for a model to write too, but it holds SQL: file paths, statements, extensions to load. It must come from someone you trust.

Your data is not in DuckDB. Use BI Components: your endpoint queries Postgres, BigQuery, a semantic layer or an API, as it likes. Mosaic writes DuckDB SQL; another database is reached through DuckDB.

The author does not write JavaScript. Use BI Components. Or Mosaic's YAML, if the page is still assembled by a developer.

You have a CSV or Parquet file and no server. Both do it, with DuckDB-WASM. Mosaic if the file is large and you want to brush it; BI Components if you want key figures and filters in five lines of HTML.

Technical choices

A grammar or a list of tags

Mosaic follows the grammar of graphics: a plot is a stack of marks, each with its data, its channels (x, y, fill) and its transforms, plus interactors and scales. vgplot adds this to Observable Plot. It can draw almost anything, and each mark is a client that queries on its own. It takes learning: rectY, intervalX, xDomain: Fixed.

BI Components has a short list of finished charts. <bar-chart measure="sum(revenue)" by="country"> cannot be layered with anything, and has few settings. A person, or a model, gets it right the first time, and the things a business dashboard always needs are attributes: compare="yoy", format="eur", granularity="month".

Mosaic has a declarative format too, close in spirit to a page of tags:

data:
  orders: { file: orders.parquet }
params:
  brush: { select: crossfilter }
vconcat:
- plot:
  - mark: rectY
    data: { from: orders, filterBy: $brush }
    x: { bin: amount }
    y: { count: }
  - select: intervalX
    as: $brush

It has a JSON Schema, and generators that turn a specification into JavaScript or Python code. BI Components has neither. The difference is elsewhere: this specification is a description of charts, not a document. Titles, text and layout around the charts are left to the page that loads it, where an HTML dashboard holds them itself.

What goes to the database

In both, a component produces a query, and something central sends it. What is sent is the main difference between the two projects.

Mosaic BI Components
A component produces A SQL query, built with mosaic-sql A description: table or mode, measures, dimensions, filters, period
Sent to a server as { "type": "arrow", "sql": "SELECT ..." }, and exec for statements { "queries": { id: description } }, to your endpoint
The server Runs it. Four are provided, in Python, Node, Rust and Go Yours. It checks, writes the query its own way, answers
Statements other than select Needed: loading data, pre-aggregated tables, ATTACH Impossible: there is no place to write one
Answer Apache Arrow JSON rows
Requests One per query, 32 at a time One per render: the queries of a page are grouped
Cache In the page: 256 MB of results, by SQL text. Identical queries in flight are merged None in the page. Yours, on your server
A newer query for the same chart One update waits at most; the latest selection wins Replaces the pending one

Mosaic needs the page to speak SQL: it is how the coordinator can rewrite a query, merge two of them, or build a table of sums to answer the next brush. The price is that the browser must be trusted with the database. The Python, Node and Rust servers run any statement they receive, from any origin. The Go server can check each query against a list of allowed tables and functions (an experimental mode, which then refuses exec and the pre-aggregated tables), and its documentation is clear that it cannot rewrite a query: a filter per viewer is not something it adds.

BI Components made the opposite trade. A query is a few names and expressions, so a server can check it against a dictionary, add the viewer's filter, and answer from any engine. The price is that nothing central can optimize: the page does not know SQL.

Selections

This is where Mosaic is the most worked out, and the subject of its second research paper.

A selection is an object you create and name. Charts and inputs write clauses to it (an interval, a point, a text match); other components read it with filterBy. A page can have several, and each has a resolution: the last clause only, the union, the intersection, or a cross-filter, where a chart ignores its own clause. A param is a single value, which can sit inside a SQL expression: a slider moves a threshold and the database computes again.

BI Components has one selection, owned by the page, always a cross-filter: the clicked chart keeps showing every value and the others are filtered. Every component follows it, filters included, with nothing to declare. It covers the usual dashboard and no more: no interval brushed on an axis, no second selection, no chart that ignores the filters.

Speed at scale

Mosaic's results come from techniques a page of BI Components does not have:

  • Pre-aggregated tables. When the pointer enters a chart, the coordinator creates, for each other chart, a small table of sums by pixel of the brushed axis. Each movement of the brush then reads this table, not the data. The tables are created in the database, in a mosaic schema, and kept between sessions.
  • Pixel-aware queries. A line of ten million points is reduced by the database to the few points per pixel that draw the same line (M4). Histograms, densities, heatmaps and hexbins are binned in SQL.
  • Arrow from the database to the chart, without a JSON step.
  • Prefetch: the next page of a table, the neighbor tiles of a raster.
  • A queue with priorities, and a cache of results in the page.

Its benchmarks show interactive updates up to a billion rows with a DuckDB server, and ten million in the browser. A BI Components dashboard asks for aggregates, a few hundred rows at most per component, so the transfer is rarely the limit; the time of each group by is. Above a few million rows in the browser, or when every click must answer in a few milliseconds, Mosaic is the right tool.

Security

Mosaic has no security model, and does not claim one: no sandbox, no semantic layer, no rights per viewer. It is a framework for the people who own the data. Its specifications can name any file or address to read, any SQL statement to create a table from, and any DuckDB extension to load.

BI Components was designed from the other end: see the security model. A dashboard written by someone else runs in a frame with no network and no access to the page; its queries are rebuilt from a strict schema, with one SQL expression per field at most and a list of safe functions; and your server applies the rights of the session.

The two are not alternatives on this point. If the people who open the page may read the whole database, Mosaic's model is simpler and far more powerful. If they may not, it does not apply.

Running it

Mosaic is a set of npm packages, shipped as ES modules, to bundle with your application. Data comes from DuckDB-WASM, from one of the four data servers, or from the kernel of a notebook. There is no file to load from a CDN with a <script> tag, and no HTML element: a plot is created by a function call and added to the page.

BI Components is one file, loaded by a <script> tag or imported from npm, and tags that work in plain HTML and in every framework.

What Mosaic has that BI Components does not

Not counting what makes Mosaic a grammar of graphics, which BI Components leaves aside on purpose. The list below is what a library of dashboard components could take from it.

Selections

  • An interval brushed on an axis: a period selected on a time series, a range of amounts on a histogram.
  • Pan and zoom on a chart, with the other charts following.
  • The value under the pointer, shared between charts: a ruler on every time series at once.
  • A click on a legend that filters.
  • Several selections in a page, and components that follow one, another, or none.
  • Highlighting instead of filtering: the selected values keep their color, the others fade, with no new query.
  • A choice of resolution: union, intersection, the last one only.

Speed

  • A cache of results in the page: going back to a selection already seen asks nothing.
  • Identical queries merged: two components that ask the same thing make one query.
  • Tables of sums prepared when the pointer enters a chart, in a static page, where DuckDB-WASM is ours to use.
  • Line charts reduced by the database to what the pixels can show.
  • Arrow instead of JSON rows, between DuckDB-WASM and the charts.
  • A GET mode for queries, so that a CDN or the browser caches the answers.

Charts and inputs

  • A histogram: bins computed by the database.
  • A heatmap, a scatter plot that stays readable with a million points (density, hexbins).
  • A map.
  • Small multiples: the same chart repeated for each value of a dimension.
  • A slider, on a value or a range, with its bounds read from the data.
  • A text search with completion from a column.
  • A table that loads its rows as you scroll.
  • A value of the page usable inside an expression: a slider that changes a threshold in measure.

Writing a dashboard

  • A JSON Schema of the format: for validation, and completion in an editor.
  • The documentation as llms.txt, in one file for a model.
  • A Python API that writes the same dashboard, and a Jupyter and marimo widget.
  • A documented way to write a component of your own with its full life cycle: pending, result, error, and whether its query is stable under filters.

Servers

  • A data server ready to install (pip install), for a dashboard on local files larger than a browser can hold.
  • Compression and HTTP/2 between the page and the server.

What BI Components has that Mosaic does not

  • HTML tags. No JavaScript to write, no bundler: a dashboard is a text anyone, or a model, can write.
  • The components of a business dashboard: score cards, comparisons with another period, pies, formats for currencies and percentages, a period filter with presets.
  • Named measures. measure="revenue", defined once on your server.
  • A query that can be checked. Names and expressions, never statements.
  • Rights per viewer, applied by your server with the session of your application.
  • A sandbox for dashboards written by someone else.
  • Any backend. The server that answers decides how; nothing assumes DuckDB.
  • One request per render, and a single endpoint to write.
  • A theme: light and dark, colors of your application, locale.
  • Nothing to wire. Filters and clicks apply to the whole page.