Forum Discussion

carlymay's avatar
carlymay
Regular Visitor
1 year ago
Solved

Add labels to custom shape map

I have a custom shape map in Power BI which I generate using a TopoJSON file. Below is a snippet of the code and also what the resulting shape map looks like. As can be seen, the map is not geographical but more so a graphical representation of work departments.

 

"type": "Topology",
    "arcs": [
        [[-61.25,1000],[700,0],[0,-70],[-700.5,0],[0,70]],
        [[658.75,1000],[700,0],[0,-70],[-700.5,0],[0,70]],
        [[1378.75,1000],[700.5,0],[0,-70],[-700.5,0],[0,70]],
        [[2098.75,1000],[700.5,0],[0,-70],[-700.5,0],[0,70]],

        [[-61.25,700],[400,0],[0,-70],[-400,0],[0,70]],
        [[960.0,700],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1378.75,700],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1980.0,700],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,700],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[-61.25,610],[400,0],[0,-70],[-400,0],[0,70]],
        [[960.0,610],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1378.75,610],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1980.0,610],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,610],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[-61.25,520],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[960.0,520],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1378.75,520],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1980.0,520],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,520],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[960.0,430],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1378.75,430],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1980.0,430],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,430],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[1980.0,340],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,340],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[1980.0,250],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,250],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[1980.0,160],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,160],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[1980.0,70],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,70],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[720.0,-80],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1140.0,-80],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1560.0,-80],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[1980.0,-80],[400.0,0],[0,-70],[-400.0,0],[0,70]],
        [[2400.0,-80],[400.0,0],[0,-70],[-400.0,0],[0,70]],

        [[370.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[720.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[1070.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[1420.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[1770.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[2120.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]],
        [[2470.0,-175],[330.0,0],[0,-70],[-330.0,0],[0,70]]
    ],
    "transform": {
        "scale": [0.000001, 0.000001],
        "translate": [0, 0]
    },
    "objects": {
        "NameHere": {
            "type": "GeometryCollection",
            "geometries": [
                {
                    "arcs": [[0]],
                    "type": "Polygon",
                    "properties": {"id": "Department 1"}
                },
                {
                    "arcs": [[1]],
                    "type": "Polygon",
                    "properties": {"id": "Department 2"}
                },
                {
                    "arcs": [[2]],
                    "type": "Polygon",
                    "properties": {"id": "Department 3"}
                },
...

 

 

Clicking the regions produces some filtering of a data matrix in Power BI. However, I need to add labels to each of the regions/boxes to show what they filter. If I add a text box over the top, I am no longer able to click the regions and filter. I think the solution is to add labels within the Topojson file but I can't figure out how to do this while ensuring the labels appear in a custom shape map in Power BI. Any help for how to display labels on top of each of these boxes would be much appreciated.

2 Replies