grafana / grafonnet

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

Non-collapsed row has no panels. #145

Closed Antiarchitect closed 6 months ago

Antiarchitect commented 8 months ago

Not sure if it's a Grafonnet bug at all, but I faced it using Grafonnet:

  db.new(input.config.board_title)
  + db.withPanels([
    row.new('Row Name')
    + row.withCollapsed(false)
    + row.withPanels( ... )

If using + row.withCollapsed(false) rows are empty (no panels) If using + row.withCollapsed(true) panels are in place

There is a workaround in not using rowWithPanels but flattening row and successive panels but it's not very comfortable to use especially with nested for cycles

malcolmholmes commented 8 months ago

The json format for rows is odd: for collapsed rows the panels are embedded into the row. For uncollapsed ones, they are outside the row, i.e. following the row. Just setting the row.withCollapsed() isn't sufficient.

Duologic commented 7 months ago

I have written the logic to sort out collapsed rows but it is currently intertwined with utils.makeGrid(). It would be a great feature to make this logic available separately.

Duologic commented 6 months ago

Calling util.panel.resolveCollapsedFlagOnRows(panels) on the eventual array of panels should resolve this (introduced in #155).

https://grafana.github.io/grafonnet/API/util.html#fn-panelresolvecollapsedflagonrows