Theme, formats, language¶
Components take their look from the page around them. A few CSS variables and one JavaScript call cover most needs, in every setup.
Colors¶
Components read six CSS variables. Define them on :root (or on any parent element) to match your product:
:root {
--bic-bg: #ffffff; /* background of cards, tables and tooltips */
--bic-fg: #1f2937; /* text and axes */
--bic-border: #e5e7eb; /* borders and grid lines */
--bic-primary: #0891b2; /* selection, links, active filter */
--bic-success: #15803d; /* positive change of a score card */
--bic-error: #b91c1c; /* negative change, error messages */
}
If your page uses DaisyUI, there is nothing to do: the variables default to the DaisyUI ones (--color-base-100, --color-base-content, --color-base-300, --color-primary, --color-success, --color-error).
Fonts are inherited from the page.
Chart palette¶
The colors of the series are a list, changed in one line:
window.dashboard.sync({ theme: { palette: ['#0891b2', '#f59e0b', '#10b981', '#ef4444', '#8b5cf6'] } });
Charts already on screen are redrawn. Run this in a <script type="module">, which runs after bi-components.js.
Light and dark¶
data-theme="dark" on <html> starts the page in dark mode. To switch while the page is open:
window.dashboard.sync({ theme: { mode: 'dark' } }); // or 'light'
Nothing is reloaded and no query is sent again.
Number formats¶
format (charts, score cards) and formats (tables) accept four names:
| Format | Example (English) |
|---|---|
eur |
€1,234 |
pct |
12.3% (the value is a ratio: 0.123) |
int |
1,234 |
dec |
1,234.50 |
<score-card measure="sum(revenue)" format="eur"></score-card>
<data-table by="country" measures="sum(revenue), count(*)" formats="sum(revenue):eur, count(*):int"></data-table>
A score card also takes a spreadsheet pattern: format="#,##0.0".
With named measures, your server gives the format and the label of each measure in meta, so dashboards do not have to set them.
Language and locale¶
- Labels of the components ("No data", "Period", "All"...) are in English. Set
<html lang="fr">for French. - Numbers and dates follow the language of the page (
<html lang>, English when absent). To choose another locale:
window.dashboard.sync({ variables: { locale: 'en-GB' } });
In a sandboxed frame¶
The Host sets all of this from outside, for dashboards it did not write:
| In a page of your own | In a sandbox, from the Host | |
|---|---|---|
| Colors | CSS variables on :root |
The css option: css: ':root { --bic-primary: #4f46e5; }' |
| Palette | window.dashboard.sync({ theme: { palette } }) |
state: { theme: { mode, palette } } |
| Light and dark | window.dashboard.sync({ theme: { mode } }) |
The theme option, then dashboard.setState({ theme: { mode } }) |
| Language | <html lang="fr"> |
The lang option |
| Locale of numbers | window.dashboard.sync({ variables: { locale } }) |
state: { variables: { locale } } |
| A CSS framework | Your page loads what it wants | The resources option |