Hi all,
I’m new to Grafana, InfluxDB, and Flux queries, and I’m currently working on setting up a Sankey diagram. I’ve successfully set it up using the Sankey Panel plugin, but I’m encountering an issue with column indices when refreshing the page. Sometimes the columns are misplaced, which breaks the Sankey diagram.
Demo Data:
"refugee_cases,origin_country=Sudan,origin_continent=Africa,asylum_country=Germany,asylum_continent=Europe cases=150"
Flux Query for Sankey Diagram:
from(bucket: "sankey-grafana")
|> range(start: -30d)
|> filter(fn: (r) => r._measurement == "refugee_cases")
|> group(columns: ["asylum_country", "origin_country"])
|> count(column: "_value")
|> map(fn: (r) => ({
source: r.origin_country, // Source country
target: r.asylum_country, // Destination country
value: r._value // Count of flows
}))
|> yield(name: "result")
This query works fine, and I receive the following result:
However, when I refresh the page, the column indices are sometimes misaligned, which results in a broken Sankey diagram, as shown below:
Question:
How can I ensure the columns stay in the correct order to prevent this issue from happening in the Sankey diagram?