-
-
Notifications
You must be signed in to change notification settings - Fork 225
Interactive graphs with plotly #6031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
|
Great, this is what I have always wanted to do!👍 |
|
Yes and maybe we can also depend on their respective source repositories as submodules or something, so we can stay up to date easier and with more easily traceable origins |
Or simply copy them form somewhere while building. |
Sounds like a good idea! For what it's worth, I currently just copied these from a plotly not-standalone export. Basically, in R, export a figure as a not-standalone html which produces an html file and separate includes. The includes I copied over in this PR. Doing this generically is probably possible, although I'm not entirely sure how this will work when in the future people an install a newer or older version of a module, which uses a newer or older version of plotly. |
| // Then create new plot | ||
| Plotly.newPlot(targetEl, payload.data, payload.layout) | ||
| .then(() => { | ||
| console.log("Plotly chart rendered successfully"); | ||
| // Mark the element as having a valid Plotly chart | ||
| targetEl._plotlyInitialized = true; | ||
| }) | ||
| .catch((err) => { | ||
| console.error("Plotly rendering failed:", err); | ||
| targetEl._plotlyInitialized = false; | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JorisGoosen you need to adjust this part if you want to pass the plot differently.
|
Ok, ive changed the code to use files as the basis of the plots so the results-json is nice and clean. |
|
I'll take a look tomorrow, should be some boolean somewhere that's default should be flipped. |
|
I found the way to switch and everything seems to work. |
|
If I export to pdf it seems the interactive plot is exported, is that what we want? Ill add a basic preference to show/hide interactive plots by default |
|
I love how smooth resizing the interactive plots feel btw ❤️ |
Also if there is no dataset yet it should still be attempted to load it... insert json slyly into json going to js decode columnnames in json rename menu entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend we could just pack https://github.com/plotly/plotly.R/tree/master/inst/htmlwidgets to a htmlwidgets.zip file. and unzip it to cmake build dir and pack it into .qrc while building JASP. To make build clean and simple. Jquery is not necessary cause we already have it as library.
|
That sounds reasonable, but the plotly version used by R and the js need to be kept in sync somehow, so perhaps not just plotly@master but rather a specific tag or commit. I do remember running into issues with jquery somehow, either they or we (probably we) used an older version which caused some issue. Keeping this working while allowing for different versions of |
yes, I had tried that but cannot push to this pr then i made that comment above,it was because we already have jquery even that htmlwidgets doesn't include jquery, so plotly.r should never need it. |
Requires jasp-stats/jaspBase#178 and jasp-stats/jaspGraphs#125
Probably best to discuss some of the implementation details in person or via video call or so, but in a nutshell:
There are quite some rough edges though:
Nevertheless, I think this draft PR is far enough for:
Known issues: