Get # of datapoints every hour in Flux

Trying to learn flux and have some problems with converting the following influxQL query in Grafana:

SELECT COUNT(“val1”) FROM “dbname”.“autogen”.“measurement” WHERE $timeFilter AND “id”=‘var1’ GROUP BY time(1h)

Flux query:

from(bucket: “dbname”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “measurement”)
|> filter(fn: (r) => r[“_field”] == “val1”)
|> filter(fn: (r) => r[“dev_id”] == “var1”)
|> window(every: 1h)
|> count()

I get somewhat the result I’m expecting, but the Grafana dashboard is laggy when I move the mouse over the graph, so most likely there is a much better way to do it than what I tried above.

Thanks

Poorly explained by me above, sorry, having problems explaining this issue properly.

The result of the flux query is that I get multiple tables, instead of one with several rows. One row per hour, with the count of how many datapoints is within that specific hour.