When a ggvis plot in shiny contains special characters, like the Umlaut ä, the plot looks good on screen. If I download the plot as SVG using the wheel in the upper right corner, the generated SVG-file is encoded using ISO-8859 instead of UTF-8:
TestPlot.svg: ISO-8859 text, with very long lines, with no line terminators
.
This yields to an error if one tries to view it:
XML Parsing Error: not well-formed
Location: file:///home/thn/Downloads/TestPlot.svg
Line Number 1, Column 4855:
After changing the encoding to utf-8 (iconv -f ISO-8859-1 -t utf-8 ...
), the SVG is displayed properly.
Here the R code:
library(ggvis)
library(shiny)
ui <- fluidPage(fluidRow(column(width=12,ggvisOutput(plot_id="TestPlot"))))
server <- function(input, output) {
observe(x={
data.frame(x=c(0,1,2,3,4),y=c(6,4,7,8,0)) %>%
ggvis(~x, ~y) %>%
layer_points() %>%
add_axis(type="x",title="Umlaut ä") %>%
bind_shiny("TestPlot")})
}
shinyApp(ui,server)
Can anybody indicate any help?
Would it be possible to pipe the SVG to iconv within shiny?