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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Nilo
Frequent Visitor

Python visual displaying a map in a new webpage

Hello All,

 

I am trying to create a heatmap, using the Power BI heat map visual,  it doesnt fulfill my purpose, as i dont see option to add text on hover, and no way to add a tooltip.

I tried creating one using python visual and it wroks perfectly, the only problem is that it shows up in a new web page, instead on the report view.

 

I am not sure, if theres something that i missed in the code, or thats how it works.  Please find teh code below

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:

# dataset = pandas.DataFrame(shipcountry, postcode)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
import pgeocode
import pandas as pd
import plotly.express as px
import numpy as np

fig = px.density_mapbox(dataset, lat='latitude', lon='longitude', z='Adjusted Revenue', radius=10,
                        center=dict(lat=dataset['latitude'].mean(), lon=dataset['longitude'].mean()), zoom=5,
                        mapbox_style="open-street-map")

dataset['Adjusted Revenue'] = dataset['Adjusted Revenue'].round(2)

hover_data = {
    'latitude': False,
    'longitude': False,
    'Adjusted Revenue': True
}

fig.update_traces(customdata=dataset[['Adjusted Revenue']],
                  hovertemplate='<extra></extra>Adjusted Revenue: €%{customdata:.2f}')


fig.show()

I am quite new to Power BI, and would really appreciate your help.

Thanks,
A fellow student tired of googling.
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You cannot bring your own renderer ( plotly.express in your case).  You must use the default renderer.

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

You cannot bring your own renderer ( plotly.express in your case).  You must use the default renderer.

Nilo
Frequent Visitor

Okay, thanks.

And if I use the default Map visual, I am unable to add hover over the map funcionality, is there anyway I could do that?

Didn't Arcgis have heatmap options? You can also consider using Deneb.

Nilo
Frequent Visitor

oh wow, yes! I activated the ArcGIS settings and I was able to get what I was looking for, thank you!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.