3

I have got a data.frame which is created with the following code. The variable "Kreationen" contains links to different videos.

df <- rawdata %>%
    mutate(Euro = as.numeric(Euro)) %>%
    group_by(Firma, Marke, Kreationen, Mediengruppe) %>%
    summarize(Total = sum(Euro)) %>%
    select(Firma, Marke, Mediengruppe, Kreationen, Total) %>%
    head(5)

Now I want to create a Columnchart, which renders the video in a div, which i created before and is empty.

    highchart() %>%
        hc_chart(type = "column") %>%
        hc_add_series(data = df$Total) %>%
        hc_tooltip(formatter = JS(paste0('function() {var html = `<object width="1000" height="700" data="', df$Kreationen[1], '"></object>`; var x = document.getElementById("videos"); x.innerHTML = html}'))) 

The code works absolutely fine for the one Element of the data.frame, but I have no clue how to pass the code dynamically. When the user hovers over the first bar, the first video shall be rendered, when he hovers the second bar, the second video shall be rendered and so on.

0 Answers0