Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
shoooouse
New Member

Deneb grid

I want to create a grid that should display images in base64 format from my table. The idea is that the spaces (and therefore the images) should grow as I filter the data, always filling the canvas with images (so if I select just one image, the canvas is basically one image. If I filter by a group of 100 images, the code should split the canvas evenly across 100 cells).
Currently I have a grid where I can display images. If I don't filter, it looks fine, but not all images are displayed. (see 1. screenshot) If I filter for a group with many images, it works, the size of the images grows and there are fewer cells, but it seems to keep the space of the filtered out image. (see 2. screenshot) When I filter for a group with only a few images, it stops working and I get a blank canvas again.
I can't figure out what the problem is, as it works to some extent, but not completely.

shoooouse_1-1735227994575.png

 

shoooouse_0-1735227931605.png

 


I would appreciate any help or ideas.

Here is my Vega code: 

{
  "width": 1100,
  "height": 600,
  "data": [
    {
      "name": "dataset",
      "format": {"type": "json"},
      "url": "data:dataset"  // Load filtered data from Power BI
    }
  ],
  "signals": [
    {
      "name": "filteredDatasetLength",
      "update": "data('dataset').length"  // Track the length of the filtered dataset
    },
    {
      "name": "gridSize",
      "update": "filteredDatasetLength > 0 ? ceil(sqrt(filteredDatasetLength)) : 0"  // Grid size adjusts based on available data
    },
    {
      "name": "cellSize",
      "update": "filteredDatasetLength > 0 ? ceil((width - 20) / gridSize) : 0"  // Dynamic cell size based on grid size
    }
  ],
  "marks": [
    {
      "type": "image",
      "from": {"data": "dataset"},
      "encode": {
        "enter": {
          "url": {"field": "Base64:"},  // Use the Base64 column for images
          "x": {
            "signal": "cellSize * (datum.Index % gridSize) + 10"  // Dynamic calculation of X position based on index and grid size
          },
          "y": {
            "signal": "cellSize * floor(datum.Index / gridSize) + 10"  // Dynamic calculation of Y position based on index and grid size
          },
          "width": {"signal": "cellSize - 5"},  // Image width adjusted to fit in grid
          "height": {"signal": "cellSize - 5"}  // Image height adjusted to fit in grid
        }
      }
    }
  ]
}



 

1 REPLY 1
lbendlin
Super User
Super User

How do you plan to arrange the images? 16:9 ?  or more something like a network graph where the items arrange around in a fluid fashion?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors