You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't reproduce an example from https://plot.ly/r/LaTeX/ with latest versions of R, RStudio and all packages on Windows (including development version of plotly). It looks like something wrong with MathJax support in the current version of package.
I have provided some screenshots in my question on Russian StackOverflow: http://ru.stackoverflow.com/questions/478133/latex-%D0%B2-plotly-r/
Mathjax is too big to bundle with the R package, so we're looking at a situation similar to #302, where we want to conditionally download/include relevant stuff under https://github.com/plotly/plotly.js/tree/master/dist before rendering
The thing is, with the current interface, there is no way to detect whether MathJax is needed. Maybe we provide a simple function, say
tex<-function(x) {
structure(x, class="LaTeX")
}
which could then be used essentially as a flag to include MathJax:
Would it be reasonable to expect RStudio and rmarkdown availability? If so, perhaps we could leverage the rmarkdown:::pandoc_mathjax_local_path() function or just educate users on mathjax: local option in html_document. Then we wouldn't have to worry about doing all that RStudio does (see lines).
So, this works for me
---
title: "MathJax Test"
runtime: shiny
output:
html_document:
mathjax: local
---
$$
\frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x).
$$
```{r, echo=FALSE}
sliderInput("x", label = "Value:", min = 1, max = 10, value = 5)
renderText({
input$x
})
```
To confirm local, here is a screenshot of the network request.
Then the trick becomes how do we know to add mathjax if not in rmarkdown. We could employ a method like crosstalk to add dependencies with a add_mathjax() function.
Would it be reasonable to expect RStudio and rmarkdown availability?
I wouldn't mind adding an rmarkdown dependency if need be, but I know there will be Jupyter/IPython/non-RStudio users that will want to generate static HTML that can be viewed locally.
We also need some way of including geoassets (#356), for local preview, if a geo or choropleth trace type is used. Unfortunately, due to the size of the external files, I think the best way to go about this is to require a clone of plotly.js, or at least a path to its distributed files, and add them add dependencies when need be.
I was also thinking that, similar to rmarkdown, users should be able to specify whether or not they want to use local MathJax or the cdn, so something like:
Any updates on this? I'm a big fan of ggplot2 and plotly, but it's a real shame to lose figure titles, axis labels, and/or legends that use plotmath expressions when attempting to add interactive features with ggplotly. Workaround hacks very welcome.
Reacted by Matthew Wilkins, PhD and Marcel Schilling
I'm likely going to create another R package, which will make easy to control plotly.js dependencies tied to R plotly objects, which will hopefully solve this and #356. The idea is to include just what you need from dist/ (and I might even do minimized bundles for each trace type to help minimize the file size)
@baptiste we looked at KaTeX, but there's still a lot of MathJax functionality that would need to be filled-in. Unfortunately it looks like the project is largely inactive right now.
Activity
artemklevtsov commentedon Dec 26, 2015
Should be fixed if add mathjax library to the package and htmlwidgets config.
cpsievert commentedon Dec 26, 2015
Mathjax is too big to bundle with the R package, so we're looking at a situation similar to #302, where we want to conditionally download/include relevant stuff under https://github.com/plotly/plotly.js/tree/master/dist before rendering
The thing is, with the current interface, there is no way to detect whether MathJax is needed. Maybe we provide a simple function, say
which could then be used essentially as a flag to include MathJax:
Any thoughts @chriddyp @cldougl @etpinard?
cpsievert commentedon Mar 11, 2016
@timelyportfolio a while ago I tried to resolve this in #411. I'm sure you can come up with a better approach :)
timelyportfolio commentedon Mar 15, 2016
Would it be reasonable to expect RStudio and
rmarkdownavailability? If so, perhaps we could leverage thermarkdown:::pandoc_mathjax_local_path()function or just educate users onmathjax: localoption inhtml_document. Then we wouldn't have to worry about doing all that RStudio does (see lines).So, this works for me
To confirm local, here is a screenshot of the network request.
Then the trick becomes how do we know to add
mathjaxif not inrmarkdown. We could employ a method likecrosstalkto add dependencies with aadd_mathjax()function.cpsievert commentedon Mar 15, 2016
That would certainly be nice if we could let rmarkdown do its thing in Rmd docs, but unfortunately, plotly.js doesn't seem play nicely.
I wouldn't mind adding an rmarkdown dependency if need be, but I know there will be Jupyter/IPython/non-RStudio users that will want to generate static HTML that can be viewed locally.
We also need some way of including geoassets (#356), for local preview, if a geo or choropleth trace type is used. Unfortunately, due to the size of the external files, I think the best way to go about this is to require a clone of plotly.js, or at least a path to its distributed files, and add them add dependencies when need be.
I was also thinking that, similar to rmarkdown, users should be able to specify whether or not they want to use local MathJax or the cdn, so something like:
versus
baptiste commentedon Oct 4, 2016
FWIW KaTeX may be a good alternative to Mathjax,
https://khan.github.io/KaTeX/
(one of its strengths is that it's light, self-contained and easy to bundle)
dswatson commentedon Mar 29, 2017
Any updates on this? I'm a big fan of ggplot2 and plotly, but it's a real shame to lose figure titles, axis labels, and/or legends that use plotmath expressions when attempting to add interactive features with ggplotly. Workaround hacks very welcome.
jackparmer commentedon Apr 4, 2017
Similar discussion and solution proposal for the offline Python library:
plotly/plotly.py#515
cpsievert commentedon Apr 4, 2017
I'm likely going to create another R package, which will make easy to control plotly.js dependencies tied to R plotly objects, which will hopefully solve this and #356. The idea is to include just what you need from
dist/(and I might even do minimized bundles for each trace type to help minimize the file size)jackparmer commentedon Apr 5, 2017
Any companies out there interested in sponsoring this one?
https://plot.ly/products/consulting-and-oem/
@baptiste we looked at KaTeX, but there's still a lot of MathJax functionality that would need to be filled-in. Unfortunately it looks like the project is largely inactive right now.
add support for local MathJax; introduce TeX(); closes #375