Hello,
I am working with a time series property in Workshop, and would like to display the last value as well as the timestamp of the last value.
I can very easily fetch the last value of the time series property in Workshop:
However, I can’t figure out how to fetch the time of the last point to display alongside my value. Is there a way to do this without resorting to a TypeScript function?
My current workaround looks like this, but it would be great if this was possible directly in Workshop.
@Function()
public async lastDataPointTimestamp(metric: Metric): Promise<Timestamp | undefined> {
return metric.metricValue?.getLastPointV2().then(point => {
if (point) {
return Timestamp.fromEpochMilli(point.time.epochSeconds * 1000);
} else {
return undefined;
}
});
}