Install and versions¶
There is nothing to build. BI Components is two files, and you load one of them:
| File | You load it | For |
|---|---|---|
bi-components.js |
<script src="..." defer> |
The components, in a page of your own: setups 1 and 2. 1.2 MB, about 330 KB compressed, ECharts included. |
bi-components-host.js |
import { embedDashboard } from '...' |
embedDashboard, in the page that shows sandboxed dashboards: setup 3. 15 KB. Each frame then loads bi-components.js by itself. |
From a CDN¶
The latest version, served by this site:
<script src="https://unytics.io/bi-components/dist/bi-components.js" defer></script>
import { embedDashboard } from 'https://unytics.io/bi-components/dist/bi-components-host.js';
A fixed version, from npm through jsDelivr, for a page that must keep working as it is:
<script src="https://cdn.jsdelivr.net/npm/bi-components@1.3.0/dist/bi-components.js" defer></script>
import { embedDashboard } from 'https://cdn.jsdelivr.net/npm/bi-components@1.3.0/dist/bi-components-host.js';
With npm¶
npm install bi-components
In a page of your own, import the components once; the tags then work in any framework (they are standard custom elements):
import 'bi-components/components';
A Host with npm¶
import { embedDashboard } from 'bi-components';
embedDashboard(element, {
html, resolveQuery,
components: new URL('bi-components/components', import.meta.url), // where your application serves bi-components.js
});
A sandboxed frame loads bi-components.js by its address, as a classic script: it cannot use the modules of your bundle. Tell embedDashboard where your application serves that file with components. The line above works with bundlers that copy assets (Vite, webpack 5); otherwise copy node_modules/bi-components/dist/bi-components.js to your public folder and give its address.
Versions¶
Versions and their changes are listed in the changelog. Until 2.0.0 the API is still settling, and a minor version may change it: its changelog says what to change. From 2.0.0, only a new major version will break a page.
Pin a version for anything that must not change.
What the browser downloads¶
| From | When | |
|---|---|---|
bi-components.js, with ECharts |
Where you load it from | Always. Once for every frame of a Host. |
| DuckDB-WASM | jsDelivr | In a static page only, when the first <source-table> loads. |
| The Parquet and JSON readers of DuckDB | extensions.duckdb.org |
The first time a static page reads such a file. CSV files and records pushed by a script need none. |
The resources of a Host |
The addresses you list | In each sandboxed frame. |
A page with <source-api>, and a sandboxed frame, download neither DuckDB-WASM nor its readers.
Serving everything yourself¶
Download bi-components.js and bi-components-host.js (from the addresses above, or from dist/ in the npm package) and serve them from your own domain, in the same folder. A sandbox then reaches no third party, provided its resources are yours too.
In a static page, DuckDB-WASM still comes from jsDelivr: its engine is downloaded from there by the library itself.
Without the built file¶
src/bi-components.js is the same file before the build: a plain ES module, used as it is, which loads the components from the modules next to it. This is how the pages of this site load them.
<script type="module" src="https://unytics.io/bi-components/src/bi-components.js"></script>
To pin a version this way: https://cdn.jsdelivr.net/gh/unytics/bi-components@v1.3.0/src/bi-components.js.
These modules import ECharts from jsDelivr. To serve it from your own domain, redirect its address with an import map placed before the script:
<script type="importmap">
{ "imports": { "https://cdn.jsdelivr.net/npm/echarts@6.1.0/dist/echarts.esm.min.js": "/vendor/echarts.esm.min.js" } }
</script>
A Host always imports the built bi-components-host.js, and its frames always load the built bi-components.js: a frame cannot load modules.
Run the repository locally¶
npm ci && npm run build
python3 -m http.server 8000
Then open http://localhost:8000/docs/examples/sales-dashboard/. The other examples, the tests and the documentation site are described in the README.