grafana / grafonnet

Jsonnet library for generating Grafana dashboards.
https://grafana.github.io/grafonnet/
Apache License 2.0
320 stars 18 forks source link

makeGrid with startY issues #160

Closed Frankwayne closed 5 months ago

Frankwayne commented 5 months ago

I'm using the latest version

import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'

and trying to make use of calling the new functionality of the grid.makeGrid function twice with the startY parameter but it does not appear to be working for me.

The first row and panels created are positioned correctly but the second call to makeGrid with the startY parameter leaves the gridPos.y = 0 for the next row and the below panels are spaced correctly with a gridPos.y = 1

This causes all of the panels to exist under the second row.

Frankwayne commented 5 months ago

The only way I seem to be able to get the grid to output the correct y positions for my new rows is by adding the new row to the result of the first makeGrid function call and calling the function again. This of course changes the x size of my first row though.

I'm not inputing the startY parameter on the second call either

Frankwayne commented 5 months ago

this was the MR feature I was trying to use

https://github.com/grafana/grafonnet/pull/109

Frankwayne commented 5 months ago

This looks to be some sort of lazy loading issue I'm running into.

calling just
g.util.grid.makeGrid(self.jobExecutorPanels, 6, 8, 9))

doesn't result in the correct y values. but if I apply the function at the end of the makeGrid function

std.map(function(p) p + { gridPos+: { y+: 9 } }, g.util.grid.makeGrid(self.jobExecutorPanels, 6, 8, 9))

it returns with the correct y positions.

Duologic commented 5 months ago

Did this work before? Do you have some example code I could execute?

Duologic commented 5 months ago

I just introduced a fix for startY in #159, so perhaps your version is already outdated? :innocent:

Frankwayne commented 5 months ago

I'm not sure if it ever worked before. I'll see if I can get some sample code, under some deadlines so it may take me bit to remove all company information.

I'm using the latest tag import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'

Frankwayne commented 5 months ago

its clearly working in some situations. The unit test I wrote for it appears work correctly but in my code I believe I'm still getting the same issue. Maybe I'm just doing something silly in my code base I haven't spotted yet.

it is making me feel a little crazy though as I thought I reproduced it last night and this AM it wasn't giving me the same results.

Duologic commented 5 months ago

Using the latest directory is good, don't forget to call jb update to also get the latest revision.

Duologic commented 5 months ago

@Frankwayne Did you manage to resolve this?

Frankwayne commented 5 months ago

I did not, I have bogged down with work tasks. @Duologic you can close the issue though, since I was able to see a working grid in the unit test I was writing for you.

Once I get a moment to retry and I'm able to reproduce outside of my code base, I will reopen and share the code.