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
Petr_Durana
Frequent Visitor

Using a custom "map" for Shape Map

Hello,

I have this SVG file which is a basketball backboard divided into individual sectors.

palubovka_sektory.png
I have a set of shot data, for each shot the x and y coordinates and whether the shot was converted (1) or not (0).
I would need to create a Shape Map visual that assigns each sector a shade of color based on the overall success rate of shots belonging to that sector.
I know I need to convert the SVG file to JSON format.
- What is the best tool for this?
- Which JSON output format to choose (GeoJSON, TopoJSON)?
- Do I need to add any information to the JSON? Maybe sector numbers?
Then I select the extracted JSON in the Shape Map visual.
- Where do I insert the x, y and sucess fields to color code the sectors?

Thank you very much!

Regards

Ing. Petr Ďurana

1 ACCEPTED SOLUTION
Petr_Durana
Frequent Visitor

My solution to find out which sector the shot belongs to. There are many methods to find out if a certain point is in a certain polygon, but all methods do not guarantee the correct result and are very demanding on the computational algorithm. So I chose the "brute force" method:
I gave the artificial intelligence (ChatGPT) an image of the sectors on the board (see initial post above) and instructed it to export the coordinates of each point and the color at that point. For the exported 411,651 points 🙂 I changed the color number to the sector number and inserted the resulting table (x, y, id) into the project.
With a simple DAX formula, I can find the sector id for the given x and y coordinates of the shot and that's what I needed. The result is shown in the figure, where the color of the sector is determined by the %FG (percentage of shot success) value from 0 (dark red) to 100 (light green).

Petr_Durana_0-1723895912024.png

 

View solution in original post

3 REPLIES 3
Petr_Durana
Frequent Visitor

My solution to find out which sector the shot belongs to. There are many methods to find out if a certain point is in a certain polygon, but all methods do not guarantee the correct result and are very demanding on the computational algorithm. So I chose the "brute force" method:
I gave the artificial intelligence (ChatGPT) an image of the sectors on the board (see initial post above) and instructed it to export the coordinates of each point and the color at that point. For the exported 411,651 points 🙂 I changed the color number to the sector number and inserted the resulting table (x, y, id) into the project.
With a simple DAX formula, I can find the sector id for the given x and y coordinates of the shot and that's what I needed. The result is shown in the figure, where the color of the sector is determined by the %FG (percentage of shot success) value from 0 (dark red) to 100 (light green).

Petr_Durana_0-1723895912024.png

 

v-kaiyue-msft
Community Support
Community Support

Hi @Petr_Durana ,

 

TopoJson is a json file that encodes topology for use with shape-mapped visual objects on Power BI.
Any* SVG image can be converted to a TopoJson file using the SVGtoTopoJson.pbix file.
More details can be found at the link:
GitHub - PBIZeroZ/SVGtoTopoJson: Simple SVG to TopoJson converter

 

To use TopoJSON map files, add the Shape map visual object to the report. In the Format pane, under Map Settings, select Custom Map from the drop-down list, and then select Add Map Type ‘Under Map Settings in the Format pane, select Custom Maps from the drop-down list and then select Add Map Type.

vkaiyuemsft_0-1723704178805.png

 


For more details, refer to the link:
Use Shape maps in Power BI Desktop (Preview) - Power BI | Microsoft Learn
How To Create Custom Shape Maps for Power BI — DiscoverEI

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Hello,
thanks a lot for the link to SVGtoTopoJson.pbix, it helped me a lot.
I have now created a JSON file that seems to display correctly in Power BI:

 

Petr_Durana_0-1723748129972.png

 

As I wrote, it has the x and y coordinates of the shots on the paubovce and a success rate of 0/1.
I would need to display in color the total success rate of all shots falling in these sectors in each sector of the "map".
In which properties of the visual should I insert which columns from the table?
Thanks a lot Petr Ď.

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!

December 2024

A Year in Review - December 2024

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