Live time-series plot of probe samples: lines, scatter, uncertainty bands. More...
| Import Statement: | import Clayground.Lab |
| Inherits: |
Autoscaled strip chart over a sliding sim-time window, one colored series per probe with a legend showing the latest values. Hover the chart and it reads back every visible series at the sample nearest the cursor, which is the difference between "the curves crossed somewhere here" and a number you can write down.
One axis carries one quantity. Two quantities that must be compared get strips: stacked charts, each autoscaled on its own axis, sharing one time axis and one cursor - the shape of a multi-channel scope.
Example usage:
import Clayground.Lab
Plot2D {
anchors.bottom: parent.bottom
width: parent.width; height: 150
probes: ["kineticEnergy", "avgHeight"]
}
Plot2D { // a fix and what it is worth
series: [{ probe: "estimate", label: "fused", color: LabTheme.secondary,
sigmaProbe: "estimateSigma" },
{ probe: "gpsFix", label: "GPS", color: LabTheme.rose,
style: "scatter" }]
}
See also Probe, Lab, and WatchMonitor.
cursorReadout : bool |
Read every series back at the hovered sample.
placeholder : string |
Text drawn centred while there is nothing to plot.
probes : var |
Probe names to draw (empty = all registered probes).
series : var |
Explicit series as [{probe, label, color, style, sigmaProbe}], overriding probes.
Use this when the plotted set is built at runtime and the lab owns the naming and colouring - a probe name like "part7" then still reads as "BULB 2" in the legend, in the same colour the lab marks that part with elsewhere. label and color are optional (probe name and the cycled seriesColors are the fallbacks). With series set, legend entries become clickable and emit seriesClicked.
Two optional keys change how a series is drawn:
style - "line" (the default) or "scatter". A quantity that arrives in discrete events - a GPS fix, a measurement, a spawn - is not a curve, and joining its samples with a line invents values between them that were never measured.sigmaProbe - the name of a probe carrying this series' uncertainty. The band value ± sigma is filled translucently behind the curve, so "the estimate is here" and "the estimate is worth this much" are one picture instead of two panels.Null (the default) hands control back to probes. An empty array is not the same thing: it means the lab has nothing to plot right now, and placeholder is drawn instead of falling back to every probe.
seriesColors : var |
Colors cycled through per series (LabTheme paper set).
stripBandHeight : real |
Height of one strip's legend band (its title and latest values).
stripMinChart : real |
Smallest chart a stacked strip is allowed to shrink to.
Below roughly this the curve stops being a shape and becomes a line with noise on it, so a caller sizing a panel divides what it has down to here and then grows instead - see heightForStrips.
strips : var |
Stacked charts as [{label, series}], overriding series.
One quantity per axis is the rule; this is how two of them are read together anyway. Each entry becomes a strip with an autoscaled axis and a legend of its own, stacked top to bottom in the order given, and all of them share the time axis, the value gutter and the hover cursor - so "the voltage dipped when the current spiked" is one picture, and no curve is flattened onto the baseline by a neighbour measured in another unit.
label is drawn at the head of the strip, ahead of its legend, and only while there is more than one: with a single strip whatever names the quantity elsewhere (the WatchMonitor's chip row) already says it, and the layout is then pixel-for-pixel the one-quantity chart. It is display text - the caller has already put it through LabLang.
The per-series keys are series'; heightForStrips tells a caller how tall the panel has to be for a given number of strips.
Null (the default) hands control back to series.
windowSeconds : real |
Width of the sliding sim-time window.
seriesClicked(string probe) |
A legend entry was clicked (only with series set).
Labs use this to let the user drop a curve straight from the legend.
Note: The corresponding handler is onSeriesClicked.
real heightForStrips(int n) |
The height at which n strips are still readable.
The floor, not the wish: a panel takes the larger of its own budget and this, so one or two strips cost nothing and only a third one makes the panel grow.