thclark / sphinx-charts Goto Github PK
View Code? Open in Web Editor NEWInteractive charts in sphinx HTML docs, using plot.ly and D3
License: MIT License
Interactive charts in sphinx HTML docs, using plot.ly and D3
License: MIT License
When using dirhtml
as builder, everything appears to work fine. However, in pages other than index.rst
the charts won't be shown. I suppose it's a path resolution issue, but couldn't really pinpoint where the problem is.
I have the documentation hosted on Github Pages, and I could display the graphics correctly, until I decided to update Sphinx and the pydata-sphinx-theme.
Before the update I had the following versions:
Sphinx 6.1.3
pydata-sphinx-theme 0.12.0
sphinx-design 0.3.0
myst-parser 0.18.1
After upgrading to the latest version of Sphinx and pydata, the following versions resulted:
Sphinx 7.0.0
pydata-sphinx-theme 0.13.3
sphinx-design 0.4.1
myst-parser 1.0.0
There are some other libraries that were also updated (I don't remember which ones), but they were not directly related to Sphinx.
I've tried downgrading to the original versions of the mentioned packages, but I can't get the graphics to work again. I don't know what else to try, any ideas on what might be causing the problem? The chart area shows "loading" indefinitely.
For generation of technical reports, it's extremely useful to be able to render charts to a static version and embed them into a PDF using LaTeX.
Without doing this, we can't make reports downloadable (currently, reports are HTML only, and although they could be downloaded, they'd need a local server so the viewer would need some significant technical expertise).
Need to add a builder specifically to generate static chart image at build time then invoke it as an alternative to the html builders here
If plotly renders the figures before mathjax's configuration has run correctly, latex labels don't get rendered.
Solution will be to hook the invocation of plotly (in charts.js
) to the startup hook of mathjax like in this answer so we can be certain pmathjax is available.
As a bonus that allows us to get rid of the duplicate script annoyance here
Hey,
trying to upgrade to the latest version of Sphinx - version 4.3.2 - but this module doesn't seem to be compatible.
Any plans on addressing this, or any clues on how to fix this?
When running pip3 install -U Sphinx
, I'm getting the below error:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
sphinx-charts 0.0.4 requires sphinx<4,>=2, but you have sphinx 4.3.2 which is incompatible.
And when trying to build the site anyway, then this error happens:
File "/usr/local/lib/python3.9/site-packages/sphinx_charts/charts.py", line 242, in setup
app.add_javascript(path)
AttributeError: 'Sphinx' object has no attribute 'add_javascript'
The full traceback has been saved in /var/folders/p8/h425k82s2r3cy03hyqyhst7w0000gp/T/sphinx-err-sxpazmrg.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Command exited with exit code: 2
The server will continue serving the build folder, but the contents being served are no longer in sync with the documentation sources. Please fix the cause of the error above or press Ctrl+C to stop the server.
Expected
Opening an html file in browser loads the charts and displays correctly
What happens
Opening an html in a browser (right click > open with > chrome, for eg.) does not load the chart jsons.
Reason
Chrome (and Edge, haven't tested other) doesn't allow ajax calls to be made to local files.
Workarounds
To get the setup to work, launch Chrome with the flag --allow-file-access-from-files.
Possible solution
The use case is to style the charts (not necessarily the chart itself but at least the chart container) that have been embedded in the final html. The more specific use case is when adding a plotly table, it comes with a border and padding which makes the table look like it wants nothing to do with everything around it.
I'm not sure this is an antipattern or if this can be achieved some other way, but what good is an html element that can't be styled?
This is only a proposal, just wanted to know what you think about it.
Hey,
I got Plotly
and 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
A relative, not absolute, link is given to the javascript that renders the chart.
Say you have a non-root page at
examples/look_at_my_charts.rst
And it includes a chart whose json is kept alongside the .rst file:
examples/chart_to_look_at.json
sphinx-charts
will place the json file at _charts/examples/chart_to_look_at.json
but the browser can't find it because the path isn't necessarily correctly resolved... The browser will try to fetch:
examples/_charts/examples/chart_to_look_at.json
Fix can be inspired by the Include directive which shows the path resolution:
class Include(BaseInclude, SphinxDirective):
"""
Like the standard "Include" directive, but interprets absolute paths
"correctly", i.e. relative to source directory.
"""
def run(self) -> List[Node]:
if self.arguments[0].startswith('<') and \
self.arguments[0].endswith('>'):
# docutils "standard" includes, do not do path processing
return super().run()
rel_filename, filename = self.env.relfn2path(self.arguments[0])
self.arguments[0] = filename
self.env.note_included(filename)
return super().run()
This is outstanding for some time, and has been hidden because readthedocs doesn't automatically update 'latest' to the default branch on github.
There's a problem with rendering some charts. Here, the top one renders but the bottom one doesn't:
Looking in the devtools, there seems to be this problem with the javascript:
plotly-2.8.3.min.js:37 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Queue')
at plotly-2.8.3.min.js:37:682866
at plotly-2.8.3.min.js:37:683951
at new Promise (<anonymous>)
at Object.r.convertToTspans (plotly-2.8.3.min.js:37:682716)
at A (plotly-2.8.3.min.js:37:480640)
at Array.w (plotly-2.8.3.min.js:37:479904)
at Array.Y.call (plotly-2.8.3.min.js:7:51643)
at SVGGElement.<anonymous> (plotly-2.8.3.min.js:37:483252)
at plotly-2.8.3.min.js:7:51569
at ut (plotly-2.8.3.min.js:7:47935)
The specific plotly version is referred to in
But, it changes and is now out of date. At the time of writing we use 2.11.1, while 1.55 and 2.8.3 are both referred to.
We should remove all references to specific plotly versions where they're hard coded. Perhaps we could parameterise and include in the docs?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.