Hi all,

Earlier last week we heard from Alberto and Joris on how to build a premier league dashboard. Taking a deeper look at the front end dashboard Joris raised a good point around Tableau Publics ability to render url’s through a parameter.

On Tableau Public you end up with the player icons showing like this.

But in desktop they render perfectly fine!

Now Joris rightly mentioned that Tableau has announced image role at the Tableau conference. You can read more about what that looks like here. Thanks to this new feature you can now have images render dynamically by having a field with the URL of the image in your data.

Whilst we eagerly await the release of this, it’s worth considering how these images may render in quality and size. What format they are stored and also the shape. Presumably this example has some well formatted circles as oppose to being dynamic crops.

So for the time being, is there a quick work around?

Well yes, we can still use the shapes repository file.

What a lot of people aren’t aware is that Tableau shapes repository works actually works alphanumerically.

This means that if we make sure our ID’s and our shape files are labelled the same thing. To clarify, Tableau doesn’t know that Mohamed Salah’s image as 306.png is ID 306, it only knows the sequence of number of ID’s on the sheet pane, and the sequence of the storing of the files within the shape repository.

Things to be cautious of:

  • Not having the same amount of players as shapes in your repository. – This will mean they misalign.
  • Certain instances your alphanumerical ordering may break.

Let’s look at an example of how the alignment works.

Here is a snippet of the top 5 strikers dataset from the season.

Each player has an ID in the dataset, within the photo field it also has there ID, appended to the media.api site.

Here are the Top 5 goal scorers in a shapes repository.

Lets see that in action.

So because I’ve filtered the dataset to just the 5 ID’s shown above, and then applied shape, it has alphanumerically assigned them in the correct order to match. This is to be used at caution when scaling to larger datasets.

So how can I scale this?

Well, presumably you won’t want to go ahead and download every picture manually. So I’ve created this python script that will do it for you. You can find the code at the top of the blog in the repository.

I’ve put in some fake subset data for now, but I recommend probably parsing through an excel file and then converting the ID to a list.

Next it looks to build a folder called images in your directory, and it loops through each of the id’s and creates the media.api website using the ID for each player. These images then get saved down into the images folder.

The script can be then run again, and it will skip over players you already have saved.

This folder of images can then be placed within your shapes repository, fit for use!

Hope this was somewhat useful. Like mentioned previous, I’m nervously excited for what the new image role functionality will have to offer in Tableau!

LOGGING OFF,

CJ