Search code examples
powerbipowerbi-desktopvega-litevegadeneb

How to Set Default Collapsed State in Deneb-Vega Gantt Chart for Power BI


I'm utilizing the highly impressive Gantt chart by David Bacci in Power BI, built with Vega and Deneb, which is arguably the best in terms of functionality and aesthetics within the Power BI universe.

Currently, the Gantt chart loads with all tasks and phases expanded. I would like to modify it so that the initial view presents everything in a collapsed state, enhancing the user's ability to navigate large datasets by expanding only the sections they need to focus on.

Could anyone advise on how to adjust the Vega JSON configuration to set the default state to collapsed for all tasks and phases?

I'm very early to Deneb, but keen to learn - so I'd like to understand if this is possible without rewriting David Bacci's entire specification.


Solution

  • A quick hacky fix using a timer as I can't find a load event:

    Add a signal:

    {
      "name": "closeLoad",
      "init": "false",
      "on": [{"events": "timer{1}", "update": "true"}]
    },
    

    Add a trigger here:

     {
          "name": "collapsedPhases",
          "on": [
            {"trigger": "phaseClicked", "toggle": "phaseClicked"},
            {"trigger": "closeAll", "remove": true},
            {"trigger": "closeAll", "insert": "data('phases')"},
            {"trigger": "closeLoad", "insert": "data('phases')"},
            {"trigger": "openAll", "remove": true}
          ]
        },