Styling additional fields in Candlestick chart

  • What Grafana version and what operating system are you using?
    v11.6.0

  • What are you trying to achieve?
    I want to stylize executions on candlestick chart so LONG would be green color and SHORT red.

  • How are you trying to achieve it?
    I was trying do to is with value mapping, thresholds combined with Overrides

  • Can you copy/paste the configuration(s) that you are having problems with?
    “from(bucket: “backtest_data”)
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r[”_measurement"] == “exec_details”)
    |> filter(fn: (r) => r[“_field”] == “price”)
    |> group(columns: [“positionId”])
    |> map(fn: (r) => ({
    r with
    transactionType: if r.side == “BOT” then “LONG” else if r.side == “SLD” then “SHORT” else “UNKNOWN”
    }))
    |> sort(columns: [“_time”])
    |> yield(name: “processed”)
    "


I would be very grateful for the answer!

welcome @ignacykkg

Could you please provide sample data coming from that query

Data sample in my influxdb:


this is raw data sample imported to db:
“exec_details,positionId=1,orderId=0,execId=exId1,side=BOT price=16294.5,avgPrice=16294.5,cumQty=1,shares=1 1639406039988
exec_details,positionId=2,orderId=2,execId=exId2,side=SLD price=16287.5,avgPrice=16286.75,cumQty=1,shares=1 1639406099976”

1 Like

This is also output of my query inspector if thats important:
" Object

traceId:undefined

request:Object

url:“api/ds/query?ds_type=influxdb&requestId=mixed-0-SQR534”

method:“POST”

data:Object

queries:Array[2]

0:Object

refId:“A”

hide:undefined

datasource:Object

query:“from(bucket: "candle_m1") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "candle_m1") |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value") |> keep(columns: ["_time", "open", "high", "low", "close", "volume"])”

datasourceId:1

intervalMs:500

maxDataPoints:2500

queryCachingTTL:undefined

1:Object

refId:“B”

hide:false

datasource:Object

query:"from(bucket: "backtest_data") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "exec_details") |> filter(fn: (r) => r["_field"] == "price") |> group(columns: ["positionId"]) |> map(fn: (r) => ({ r with transactionType: if r.side == "BOT" then "LONG" else if r.side == "SLD" then "SHORT" else "UNKNOWN" })) |> sort(columns: ["_time"]) |> yield(name: "processed") "

datasourceId:1

intervalMs:500

maxDataPoints:2500

queryCachingTTL:undefined

from:“1640787877018”

to:“1640789449894”

hideFromInspector:false

response:Object

results:Object

A:Object

status:200

frames:Array[1]

refId:“A”

B:Object

status:200

frames:Array[11]

refId:“B”"

sorry, I meant to say the query result in grafana. what does it look like there. when you click on the Table view


Thats how table view looks like