Scattergeo loading map offline from local topojson (with Python) [Solved]

Thanks Jon, your advice pointed me in the right direction. It was the same origin policy blocking me.

My solution goes a bit off topic but hopefully will help others.

In the end I rolled my dashboard into a node-webkit app and disabled Chromium’s same origin policy with the following line in my app manifest file:

"chromium-args": "--allow-file-access-from-files --allow-file-access --user-data-dir"

The line in the html output should be:
"topojsonURL": process.cwd() + "\\files\\topojson\\"

To prevent “process.cwd()” being added as a string value I did the following in Python:

html_plt = plot(fig, output_type='div', config={'topojsonURL': '*process.cwd()*' + '\\' + 'files\\topojson\\'})
html_plt = html_plt.replace('"*process.cwd()*', 'process.cwd() + "')

I then just wrote “html_plt” out as a html file.

Loads fine without a connection or server :slightly_smiling_face:

1 Like