Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon'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.
Hello,
I have this SVG file which is a basketball backboard divided into individual sectors.
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
Solved! Go to Solution.
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).
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).
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.
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:
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 Ď.
User | Count |
---|---|
116 | |
73 | |
58 | |
49 | |
48 |
User | Count |
---|---|
171 | |
122 | |
60 | |
59 | |
56 |