Comments (10)
As of now, there is no support for this in htmlwidgets
, but there are some hacks. See #1 as the only reference that I remember. The desire to support multiple contexts in htmlwidgets
makes this very difficult.
from htmlwidgets.
However, I should note that htmltools
does support url assets, but href
does not work in YAML
for the htmlwidget
.
library(htmltools)
tg <- tags$div()
tg <- attachDependencies(
tg,
htmlDependency(
name="d3"
,version = 3.4
,src = c(href = "http://d3js.org")
,script = "d3.v3.min.js"
)
)
from htmlwidgets.
@timelyportfolio I understand the implications of supporting multiple contexts, but it does not seem to me a blocking issue.
On the other hand a R function could - just when shiny is running - call a tags$script as appropriate, right?
from htmlwidgets.
Yes, but tags$script
does not handle multiple synonymous dependencies, such as different versions of jquery
or d3
that will inevitably come with different packages/widgets/themes, so I would use it very carefully, and recommend strongly against making it part of the behavior of your htmlwidget
. As to "not a blocking issue", Pandoc (on which rmarkdown
relies) will not work with these url assets, so I would say that it is a blocking issue.
from htmlwidgets.
@smartinsightsfromdata I would like to better understand the compelling reasons to load from a CDN. The design decision to have everything reside locally was made so that widgets work seamlessly in multiple contexts without any issues. If there are strong reasons where loading from a CDN is preferred, I would like to understand the use cases in depth.
from htmlwidgets.
@ramnathv It is very simple: I have done the wrapper for the js library pivottable by Nicolas Kruchten. The author has implemented a renderer using GoogleCharts, which does not allow for local storing of the library.
Originally I thought not to implement any renderer beyond the standard one (as similar results can be achieved with other packages).
Then users showed interest in the D3 renderer for Treemap, implemented very simply. This made me think to find ways to add - probably optionally - the Google Chart renderer.
I'm perfectly aware that this renderer would work only on shiny - and when an online connection is available. To be clear because of these reasons I wouldn't consider this high priority but a "nice to have" feature: it may well be that applies only to the Google Charts use case.
from htmlwidgets.
The GoogleCharts loader is a hot mess--it really foils the htmltools/htmlwidgets dependency loader. It's really quite tricky to combine a page of GoogleCharts visualizations that don't know about each other, since their loader wants to be called a single time with all the plugins you want to use.
from htmlwidgets.
@jcheng5 please consider that most of the "mechanism" is fully transparent for the widget: it is the pivottable code that manages the calling etc. The only thing it needs is the actual library loaded. An example here.
from htmlwidgets.
I am closing this issue, since allowing cdn based assets can create problems as outlined above. If there is a strong need to revisit this issue, feel free to reopen.
from htmlwidgets.
@ramnathv, I am a relative htmlwidgets noob, but I have one more use case to add to this issue. In order to support install_github
, right now I believe the built JS library needs to be checked into the Git repository. It is not a good practice in general to place built resources in a Git repo, since they can accumulate over time with different versions and make cloning/installing more resource intensive. Supporting CDN scripts would resolve this issue for me.
from htmlwidgets.
Related Issues (20)
- Pandoc 2.19 has deprecated --self-contained HOT 1
- Move rmarkdown back to Suggests
- Binding resize method is never called. HOT 3
- Change between versions 1.5.4 and 1.6.0: Plotly output in nested tables is not showing HOT 1
- Use system2 to avoid shell injection HOT 5
- What's the License? HOT 1
- S3 generic/method consistency
- Accessibility support HOT 5
- `shouldEval()` probably shouldn't recurse over list-like structures that aren't actually lists
- JSON conversion is not consistent
- 1.6.2 from tags lies about its version HOT 3
- Release htmlwidgets 1.6.3
- Call "JS function" Incompatibility with other package (reactable) HOT 6
- Release htmlwidgets 1.6.4
- htmlwidgets 1.6.3 breaks sortable v0.5.0 bucket and rank lists HOT 2
- How to pass information into the ellipsis argument of the widget's custom HTML function?
- R not installing package HOT 1
- Add support for Observable Plot? HOT 5
- No Shiny reactivity HOT 1
- Sum of value showing NaN in summarywidget HOT 2
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 htmlwidgets.