Union data for Time Series

Hi, I’m trying to do something, but can’t manage:

  • What Grafana version and what operating system are you using?
    10.2.3 Windows 11
  • What are you trying to achieve?
    Union data so there line on Time Series is solid
  • How are you trying to achieve it?
import "strings"
import "date"

applyAggregation = (tables=<-, start, stop) => 
    if (uint(v: stop) - uint(v: start)) > (90*24*60*60*1000000000) then 
        tables |> aggregateWindow(every: 60m, fn: mean)
    else if (uint(v: stop) - uint(v: start)) > (7*24*60*60*1000000000) then 
        // more than 7 days in nanoseconds
        tables |> aggregateWindow(every: 10m, fn: mean)
    else
        tables

sensorList = strings.split(v: "${Environments}", t:",")

lastPointBeforeStart = from(bucket: "Measurements")
    |> range(start: date.sub(from: v.timeRangeStart, d: 1d), stop: v.timeRangeStart)
    |> filter(fn: (r) => r._measurement == "Measurements")
    |> filter(fn: (r) => r._field == "value")
    |> filter(fn: (r) => r.machinecode == "${Machine}")    
    |> filter(fn: (r) => contains(value: r.sensor, set: sensorList))
    |> last()
    |> map(fn: (r) => ({r with _time: v.timeRangeStart}))

    
data = from(bucket: "Measurements")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r._measurement == "Measurements")
    |> filter(fn: (r) => r._field == "value")
    |> filter(fn: (r) => r.machinecode == "${Machine}")
    |> filter(fn: (r) => contains(value: r.sensor, set: sensorList))
    |> applyAggregation(start: v.timeRangeStart, stop: v.timeRangeStop)

lastPoint = data
    |> last()

extendedPoint = lastPoint
    |> map(fn: (r) => ({r with _time: now()}))

combined = union(tables: [lastPointBeforeStart, data, extendedPoint])

combined
    |> yield()
  • What happened?

  • What did you expect to happen?
    The dots should be connected with lines, like in one column. Two lines from begging to the end of the panel.

Anyone can help me? :slight_smile: