An ESM library for rendering an SVG timeseries plot.
import render from 'https://tomashubelbauer.github.io/esm-svg-timeseries/index.js';
Set proper width and height values on your SVG element with no content.
To use in an existing SVG, use foreignObject.
const timeseriesSvg = document.getElementById('timeseriesSvg');
const data = [];
window.setInterval(() => {
data.push({ stamp: new Date(), value: Math.random() });
render(timeseriesSvg, data);
}, 100);
The arguments are:
svg: the SVG element instace to render the plot todata: an array of { stamp: Date, value: Numbe } points to plotforceMinValue: forced min value (default: zero to prevent jumping)forceMaxValue: forced max value
Check out demo.html.
innerHTML and appending a fragmentReuse existing elements and update their attribute values where possible.
Skip the stamp components which are equal across the board instead of defaulting to time-only.