thclark / sphinx-charts

Interactive charts in sphinx HTML docs, using plot.ly and D3
MIT License
26 stars 3 forks source link

New version of graph isn't rendered in browser upon regeneration of JSON #9

Closed TooDissing closed 2 years ago

TooDissing commented 2 years ago

Hey,

I got Plotlyand this plugin to work nicely together, but as I am setting up the work pipeline I am regenerating the same graph multiple times. Everything works great on the first render, but when I change the graph JSON, then nothing happens in the browser - i.e. no changes are reflected.

I sure that there's cache somewhere, because when I rename the newly generated file, then everything works as expected.

Any hint or clues on how to clear what ever cache or other mechanism that is blocking this re-render?

Using the following versions and is running this on macOS 10.14:

sphinx_charts>=0.0.4
plotly>=5.4.0
pandas>=1.3.5

Python 3.9.9

thclark commented 2 years ago

Hi @LydByDissing glad you’re getting some use from the library!

The issue could be elsewhere, but what I guess is that your browser is caching the json, since it’s downloaded as a static file rather than being embedded into the web page (I chose to do it like that because chart json files can get really massive and I wanted to show the downloading spinner as a preview in the chat panel).

To verify this, you could open up chrome devtools and disable the cache (or right click on the ‘reload’ button to allow you to clear cache and reload).

Let me know if that fixes things. If it does, then thats your workaround, and we’ll also look into the more permanent solution of hashing the data to avoid other people having the same problem

thclark commented 2 years ago

Btw I think the reason this hasn’t come up before is that normally in the workflow of getting charts rendering correctly, it’s easier to use plotly’s own rendering tools to show and manipulate the graph, rather than having to rebuild the documentation each time, so you might find that to be a helpful shortcut too.

TooDissing commented 2 years ago

First off, what a cool way to integrate graphs into a website!

Tried various browsers and to both disable the cache and to remove any local browser data. Sadly to no avail. I see that all website elements are fetched... i.e. http 200. I guess this potentially also becomes a problem when updating the JSON on a live site, but haven't tested this yet.

TooDissing commented 2 years ago

For some reason the local plotly render doesn't work. It runs and then opens a webpage, which then never loads. Should properly create a bug report for this. But to overcome this I am just generating an image. This works OK.

TooDissing commented 2 years ago

Just tried to update the descriptive title of this graph on a live page, that I visited earlier today (within the same hour). Here the problem also prevails: https://stroem.readthedocs.io/en/latest/guides/voicing.html.

The text should read: 'Measure frequency reposnse; performed using REW'. Added using this script: https://github.com/LydByDissing/stroem/blob/main/utils/make-plot.py But it doesn't in my browser; see picture below. Skærmbillede 2021-12-19 kl  18 48 32

How does this render at your end? If you also see the same as on the picture, then there's something going on during the build.

UPDATE: Just testing in another browser and here the text renders as intended. So the arrow seems to point to come browser based cache.

thclark commented 2 years ago

@LydByDissing sorry, just getting back to the desk after the christmas break (I was away for a bit).

On your docs I see the same title as in the script you've used to generate them, NOT the same as your screenshot... so itall looks good to me.

Perhaps it was a time based thing? Readthedocs can take a little while to push new versions of builds through its CDNs

So do you also see the right thing now? Or have you otherwise solved things in the meantime?

TooDissing commented 2 years ago

I believe it is some browser cache. not too bothered about it.