Charts
Charts for dashboards and reports from one component each, on ECharts. What they share, and which to use.
Which chart
Principles
- Function over decoration. A framed plot, ticks out from the edges, faint grid lines, straight lines between readings: the look of the instrument software our customers already use.
- Every axis says what and in which unit, "Oxygen (mg/l)". Numbers in nb-NO with the decimals the parameter is measured to.
- A parameter keeps its colour everywhere: temperature is green in a profile, a time series and a report. Things that aren’t parameters (casts, stations, months) take the series colours in order.
- Nothing is smoothed, binned or joined across a gap by the chart without saying so. A gap in the data is a gap in the line.
- Hover reads values, it never changes them: no dimming, no enlarging. The readout lists every series at that point, in tabular figures.
- No animation. A chart that moves when the data changes looks like the data moved.
Screen and print
Every chart takes a medium. Screen is canvas in the page's theme, rebuilt when the theme changes, and interactive. Print is SVG in dark ink on white and Arial, with nothing that needs a pointer: legends become keys drawn in the chart, and every scale is drawn and named. Each chart can hand over its print version whatever is on screen.
<script lang="ts">
let chart = $state<ReturnType<typeof TimeSeriesChart>>();
</script>
<TimeSeriesChart bind:this={chart} {series} />
<!-- The print version, wherever it's shown -->
chart.exportSvg('buoy'); // download
chart.toSvg({ width, height }); // a string, for the PDF
chart.exportPng('buoy'); // what's on screen Download
ChartExport is the one download menu, top right of a chart's frame: PNG as on screen, SVG in print ink, and CSV of the numbers when the page hands them over. With a decimal comma the CSV is separated by semicolons, so it opens in columns in a Norwegian Excel.
<div class="flex items-center justify-between">
<h3>Samples per month</h3>
<ChartExport chart={chart} filename="samples-2026" data={() => ({ columns, rows })} />
</div>
<BarChart bind:this={chart} ... /> Loading, empty and error
ChartState stands in for a chart at its size, in its frame, so the page doesn't move when the data lands. Loading draws a faint ghost of the chart to come with a scan line crossing the plot; empty and error say why, small, inside the frame.
Time series, kind="line"
Bar, kind="bar"
Profile, kind="profile"
Isopleth, kind="field"
Calendar, kind="calendar"
{#if data.loading}
<ChartState state="loading" kind="line" height={340} />
{:else if data.error}
<ChartState state="error" kind="line" height={340} title="Couldn't load the readings" onretry={reload} />
{:else if !data.series.length}
<ChartState state="empty" kind="line" height={340} title="No readings in this period" />
{:else}
<TimeSeriesChart series={data.series} height={340} />
{/if} Parameter colours
The chart tokens, --color-chart-1 to -10, with a light and a dark value each. The parameters that own one:
chart-1 salinitychart-2 conductivitychart-3 temperaturechart-4 oxygenSaturationchart-5 oxygenchart-6 fluorescence, chlorophyllchart-7 turbidity, opticalOxygenSaturationchart-8 pressure, opticalOxygenchart-9 densitychart-10 soundVelocity