I am trying to generate a world map with data in plotly as an html file, which should offline usable.
The problem is that plotly wants to use https://cdn.plot.ly/world_110m.json, is there a way to give it to plotly locally. Like building it into the html file. (Internet while compiling is O.K. afterwards it should be able to run without)
To demonstrate my Problem, I have copied the example from here Choropleth maps in Python and it looks like this:
import plotly.graph_objects as go
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
fig = go.Figure(data=go.Choropleth(
locations = df['CODE'],
z = df['GDP (BILLIONS)'],
text = df['COUNTRY'],
colorscale = 'Blues',
autocolorscale=False,
reversescale=True,
marker_line_color='darkgray',
marker_line_width=0.5,
colorbar_tickprefix = '$',
colorbar_title = 'GDP<br>Billions US$',
))
fig.update_layout(
title_text='2014 Global GDP',
geo=dict(
showframe=False,
showcoastlines=False,
projection_type='equirectangular',
),
annotations = [dict(
x=0.55,
y=0.1,
xref='paper',
yref='paper',
text='Source: <a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">\
CIA World Factbook</a>',
showarrow = False
)]
)
fig.write_html("file.html")
When I try to open it without internet it looks like this(write it to html)
But adding fig.write_html("file.html",config={'topojsonURL':'./world_110m.json'})
(the files are in the same dir, and replacing it with the files URL https://cdn.plot.ly/world_110m.json also stops it from displaying while in internet)
Doesnโt help either (is also stops working with internet)
If you try it out, donโt forget to use a private window to simulate a different browser