Comments (16)
It seems that something like https://github.com/aulneau/next.js-with-react-plotly.js is the best we can do at the moment for SSR using this component. @etpinard you're right that this is a thornier problem than I anticipated :)
from react-plotly.js.
I'd be happy to help you with this if I could get a few more details about how you're using the library, bundling it, serving it etc. We successfully use this library with React 16.2.0 in e.g. the https://github.com/plotly/react-plotly.js-editor project so I doubt the issue is with the React version per se.
from react-plotly.js.
@akhilesh26 are you by chance using server side rendering at all? node ./lib/server/app.js
, if that is the case, the error: ReferenceError: window is not defined
would make sense because there is no global window object on the server.
I've run into that issue before using various libraries and packages with SSR that don't support it. A possible fix would be to prevent the components from being loaded on the server, and only load them on the client. I use next.js a lot and they have baked in a dynamic import solution that solves this.
from react-plotly.js.
I have this same issue, im doing server side rendering with react 16.2
from react-plotly.js.
Basically this library doesn't support SSR at the moment, so it's nothing to do with the React version per se :) see also #21
from react-plotly.js.
Upon further discussion with @aulneau I think it should be possible for SSR to work with this library... stay tuned for a fix!
from react-plotly.js.
@etpinard it seems that this line is causing a problem with SSR: https://github.com/plotly/plotly.js/blob/master/src/lib/is_plain_object.js#L19 ... would it be possible to change to use typeof
instead?
from react-plotly.js.
@aulneau I think it should be possible for SSR to work with this library.
Really?!? How?
Using jsdom
can get you close (see example and maybe closer now using the latest jsdom version), but you can expect plotly.js to work in outside of browser-like environments at the moment.
For more on the topic, see:
https://github.com/plotly/plotly.js/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aclosed+jsdom
from react-plotly.js.
from react-plotly.js.
Is there a solution to this problem ? plotly.js and next.js ??
from react-plotly.js.
No, there is no known way to integrate these together.
from react-plotly.js.
this is a thornier problem than I anticipated :)
@nicolaskruchten Out of curiosity, could you explain what makes SSR support in react-plotly.js
hard to implement?
from react-plotly.js.
@janosh yes: plotly.js uses many browser APIs while rendering, which are very hard if not impossible to make available in an SSR environment. For example, it adds SVG elements to the DOM and then queries browser APIs for bounding boxes, and that sort of thing. In addition, certain trace types open WebGL contexts, which are also difficult to make available outside of a browser.
Our standard solution to headless rendering is a system called Orca which solves this problem the hard way by wrapping up a browser in an Electron app and handles the rendering that way: https://github.com/plotly/orca
from react-plotly.js.
Ah yes, I've used Orca in Python for saving plots to files. So there's no addon or plugin like Orca for plotly.js to enable SSR?
from react-plotly.js.
We haven't built anything like that, no.
from react-plotly.js.
@nicolaskruchten Thanks for explaining!
from react-plotly.js.
Related Issues (20)
- How do I configure spikedistance? HOT 1
- Depreciated in favor of Angular? HOT 2
- Update plotly.js to include the latest version HOT 1
- onDoubleClick does not work in 3D mesh HOT 1
- Support Synchronizing of zoom & hover for multiple charts on the same page HOT 1
- ranges does not get computed when same data is used but Plot is updated
- Can't resolve 'react-plotly.js' in HOT 1
- onUpdate - reset the zoom in Nextjs (React) HOT 2
- Rangeselector buttons flashing
- Plotly.restyle breaks onClick handlers
- Can't disable sunburst default animation HOT 1
- Is layout.height really disallowed when layout.autosize=true ?
- Axis `automarging` does not work HOT 6
- Need to extract `.default` before using `createPlotlyComponent` HOT 1
- Request for Kernel Density Estimate Plot Feature in react-plotly HOT 1
- Chart is cropped. HOT 1
- How can I use animate method ?
- How do I use Plotly.Fx.hover with react-plotly.js?
- Heatmap not showing HOT 1
- Clickmode "event+select" activated and Clicking outside of Graph calls onUpdate incorrectly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-plotly.js.