I am attempting to create a flexdashboard that uses an event (map_marker_click) in Leaflet to show a highcharts column chart in another chart on the same page. I have taken from other examples and cannot find quite what I am looking for in the Flexdashboards tutorials or examples. This is very close to what I am wanting without the shiny inputs or plot.ly integration and using markers instead of polygons (much less going on).
I have the following code for a flexdashboard in R:
title: "Flexdashboards and Leaflet"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
runtime: shiny
---
```{r,include=FALSE}
library(flexdashboard)
library(shiny)
library(leaflet)
library(highcharter)
```
```{r,include=FALSE}
latitude<-c(35.94077, 35.83770, 35.84545, 35.81584, 35.79387, 36.05600)
longitude<-c(-78.58010, -78.78084, -78.72444, -78.62568, -78.64262,-78.67600)
amounts1<-c(27, 44, 34, 46, 25, 15)
amounts2<-c(34, 52, 35, 78, 14, 24)
ids<-c("a", "b", "c", "d", "e", "f")
df<-data.frame(ids,amounts1,amounts2,latitude,longitude)
renderLeaflet({
leaflet() %>%
addTiles() %>%
addMarkers(lng=c(longitude),lat=c(latitude))
})
observeEvent(input$map_marker_click,{
click<-input$map_marker_click
if(is.null(click))
return()
})
```
```{r}
renderHighchart({
highchart() %>%
hc_chart(type = 'column')%>%
hc_add_series(name=amounts1, data=click())
hc_add_series(name=amounts2, data=click())
})
```
I am wondering if this could be accomplished in a flexdashboard with or without shiny integration.