Skip to content

Conversation

vandenman
Copy link
Contributor

@vandenman vandenman commented Sep 24, 2025

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:

  • if possible, show plots as interactive plots by default (for now).
  • switching between the static and interactive version of a plot is possible through the dropdown of a plot.
  • resizing sort of works.

There are quite some rough edges though:

  • For some plots the static version looks fine but the interactive version could use some tweaks (For example, more space between axis title and axis tick labels).
  • The updating of the axes needs to be polished. Right now it can cause flickering when there are many plots.
  • Passing the data now happens through the json directly (as it is json). However, the objects can be very large and make the logs hard if not impossible to read. Perhaps this should be saved as a separate object on disk and loaded in by js to keep the json messages from the desktop/ engine readable.
  • I did not look at html/pdf export. The pdf should just use the static plots. But the html could, in theory, use the standalone feature from plotly. That way most interactivity is retained, although the file size can become quite large.

Nevertheless, I think this draft PR is far enough for:

  1. An initial review.
  2. A starting point for changes to the R analyses related to interactive figures. For example, the analyses in R need to decide what to show in the tooltip that is shown on hover (right now this is just whatever plotly does by default) and also need to check how the variables are named (right now this uses the internal aestethic names, which is what plotly does by default).

Known issues:

  • ggplot2 objects with polar coordinates do not work, see Support for arbitrary coordinate systems plotly/plotly.R#878. This is a problem, because any pie chart (e.g., those in descriptives, but also the BF pizza) is currently implemented in polar coordinates. It's unclear what the best way is to fix this. plotly does support both polar coordinates, and has a separate 'pie' trace type. Both can do exactly what we need, but there is no automatic conversion from ggplot. It's not easy to see from the ggplot object that when we are creating a pie chart, because the ggplot object just contains a bar graph shown in polar coordinates. Possible solutions:
    • Fix the polar coordinate conversion.
    • Inside jaspGraphs, add special plotly code to everything that returns a pie chart, so that instead of calling ggplotly we use the custom plotly code (hacky).

@shun2wang
Copy link
Contributor

Great, this is what I have always wanted to do!👍
A suggestion: It seems that we can streamline some js dependencies. For example, for the jquery library, we can only keep *.min.js instead of .js and .map in the production environment, and only keep those redundant things in the development environment.

@JorisGoosen
Copy link
Contributor

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

@shun2wang
Copy link
Contributor

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.

@shun2wang shun2wang self-requested a review September 25, 2025 12:46
@vandenman
Copy link
Contributor Author

It seems that we can streamline some js dependencies.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants