-
Notifications
You must be signed in to change notification settings - Fork 20
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
in Shiny
JS
getting passed as a string
#6
Comments
It works for me. What error are you talking about? |
So you get two parcoords? If so this is what I feared and will make things more difficult. I and another user get an empty box on top (see #4). I just hopped off my computer but the error I get is colorScale not a function because it is a string. |
Yes. I get two parcoords. My version of |
never mind the
|
I am able to reproduce this error with CONFIRMED: It works with all versions prior to this commit. |
Yes, I'm pretty sure we will need a few changes in our widget packages after switching to jsonlite. |
Sure. I will start working on a |
Ok, good to know. I thought @yihui already had a |
cc @wch |
I just rebased ramnathv/htmlwidgets#28 and I will have to figure out the consequences of switching to jsonlite in htmlwidgets. |
Great! We can test things out with your |
I think I've found the difference. Inspecting the JSON in the static version (generated by RJSONIO?), I see:
And for the Shiny version, with
This probably has to do with the behavior when Previously, Shiny used I've encountered two other issues for jsonlite that could potentially cause problems. One of them is easy to work around (and I've already added the workaround in shiny): jeroen/jsonlite#71. The other one is harder to work around: jeroen/jsonlite#76. But neither of them seem to be at issue here. |
I think the difference is in how The htmlwidgets code uses str(I("options.color.colorScale"))
# Class 'AsIs' chr "options.color.colorScale" Here's how the two packages convert this differently: RJSONIO:::toJSON(list(evals = I("options.color.colorScale")))
# [1] "{\n \"evals\": [ \"options.color.colorScale\" ] \n}"
# This wraps jsonlite::toJSON with various extra args
shiny:::toJSON(list(evals = I("options.color.colorScale")))
# {"evals":"options.color.colorScale"} Without the RJSONIO:::toJSON(list(evals = "options.color.colorScale"))
# [1] "{\n \"evals\": \"options.color.colorScale\" \n}"
shiny:::toJSON(list(evals = "options.color.colorScale"))
# {"evals":"options.color.colorScale"} The question is, which behavior makes more sense? I don't see any reason why |
In htmlwidgets, we need auto_unbox = FALSE in this particular case. The reason is here: https://github.com/ramnathv/htmlwidgets/blob/921ba807c85404f6b8b16a8adb15c4401cf1a922/inst/www/htmlwidgets.js#L379-L381 We need This issue should be easy to solve in htmlwidgets, and I'll send a PR shortly. |
fixes timelyportfolio/parcoords#6: make sure data.evals is an array
That's simply how you opt out of auto-unboxing on a per-vector basis in RJSONIO. From
|
OK, that sounds like something that should be added to jsonlite's |
Update: The dev version of jsonlite now has the same behavior that RJSONIO does. In other words, the |
@jcheng5, @ramnathv, @yihui | I wondered if you might be able to add some insight on this strange situation. When using
parcoords
, theJS_EVALS
get passed as acharacter
and fail when rendered withrenderParcoords
in Shiny, but work perfectly even in Shiny when rendered statically withparcoords
. Here is a simple example that fails on my machine.sessionInfo()
pasted below code. I'll keep digging but I have not found anything so far.The text was updated successfully, but these errors were encountered: