Ниже представлен прототип моего Shiny app
с использованием библиотеки highchart
js
в R
library("shiny")
library("highcharter")
library("viridis")
data("vaccines")
ui <- fluidPage(
h1("Highcharter Demo"),
fluidRow(
column(width = 8,
highchartOutput("hcontainer",height = "500px")
),
div(style = "height: 100px; width: 100px; background-color: rgba(0,0,0,.5);", HTML("Put legend here"))
)
)
server = function(input, output) {
output$hcontainer <- renderHighchart({
fntltp <- JS("function(){
return this.point.x + ' ' + this.series.yAxis.categories[this.point.y] + ':<br>' +
Highcharts.numberFormat(this.point.value, 2);
}")
plotline <- list(
color = "#fde725", value = 1963, width = 2, zIndex = 5,
label = list(
text = "Vaccine Intoduced", verticalAlign = "top",
style = list(color = "#606060"), textAlign = "left",
rotation = 0, y = -5)
)
hchart(vaccines, "heatmap", hcaes(x = year, y = state, value = count)) %>%
hc_colorAxis(stops = color_stops(10, rev(inferno(10))),
type = "logarithmic") %>%
hc_yAxis(reversed = TRUE, offset = -20, tickLength = 0,
gridLineWidth = 0, minorGridLineWidth = 0,
labels = list(style = list(fontSize = "8px"))) %>%
hc_tooltip(formatter = fntltp) %>%
hc_xAxis(plotLines = list(plotline)) %>%
hc_title(text = "Infectious Diseases and Vaccines") %>%
hc_legend(layout = "vertical", verticalAlign = "top",
align = "right", valueDecimals = 0) %>%
hc_size(height = 800)
})
}
shinyApp(ui = ui, server = server)
Мне интересно, можно ли отделить legend box
от диаграммы и поместите его в другой div
?
Любой указатель будет высоко оценен.