liveBook · Manning

ΜPlot

As explained in Digital Twins in Action

μPlot is a compact JavaScript charting library optimized for rendering large time-series datasets.

μPlot is a compact JavaScript charting library optimized for large time-series datasets. In a browser, it can turn sensor readings into small graphs that make trends and anomalies easier to compare without giving every measurement a full-sized chart. section 6.2.1

A sensor dashboard can query a digital twin’s GraphQL API for measurements from a named space over a 24-hour period. It then creates one chart per measurement, hiding axes and legends for a sparkline effect. A fuller view also reports each measurement’s minimum, maximum, mean, and latest reading. section 6.2.1

result.spaces.forEach(space =>
  space.measurements.forEach(({ name, values }) => {
    const chartsDiv = document.getElementById('charts');
    const chartDiv = document.createElement('div');
    chartsDiv.appendChild(chartDiv);

    const timestamps = values.map(({ timestamp })  #1
      => parseInt(timestamp) / 1000);
    const chartValues = values.map(({ value })
      => parseFloat(value));

    new uplot({
      width: 300,
      height: 30,
      axes: [ { show: false }, { show: false } ], #2
      series: [ {}, {stroke: "#0066cc", fill: "#3b82f619"} ],
      legend: { show: false },  #3
      cursor: { show: false }
    }, [timestamps, chartValues], chartDiv);
}));

The rendering listing converts timestamps to seconds and values to numbers, then passes both arrays to a 300-by-30-pixel μPlot chart with axes, legend, and cursor hidden. section 6.2.1

How Digital Twins in Action covers it

How deep it goes
Shows data conversion and chart configuration for sparklines; defers the fuller HTML page to GitHub.
Examples
Uses a 24-hour home-sensor query and one small chart per measurement.
What it assumes
Assumes a working GraphQL API and stored sensor data; uses HTML, CSS, and JavaScript for the frontend.
What you can do after
Apply μPlot to render queried sensor measurements as browser-based sparklines.
How it connects
Connects GraphQL queries, digital twins, DynamoDB, and sparklines in a browser visualization workflow.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Digital Twins in Action. The section links point to the parts of the book it draws on.