简体   繁体   中英

Using highcharter and r shiny with reactiveValues()

I was successfull to use plotly with reactive values, but having trouble using highcharter. I'm trying to use itin my shiny app, though I can't seem to give it the inputs from reactiveValues()

Here is the code:

output$highchartGraph <- renderHighchart({
    hchart(rv$userTable, "scatter", hcaes(x = rv$ColnameX,
                                          y = rv$ColnameY)
    )

rv$userTable looks different depending on user input, similar to this:

         "Date" "sulfate" "nitrate" "ID"
32 "2002-02-01"      2.07     0.774    8
38 "2002-02-07"      3.25     1.280    8
44 "2002-02-13"      1.68     1.140    8
62 "2002-03-03"      1.85     1.310    8
74 "2002-03-15"      5.72     0.599    8
80 "2002-03-21"      6.71     1.390    8

rv$ColnameX/Y have the values of needed columns to visualise, respectively.

If needed any more info, please tell.

Maybe

   output$highchartGraph <- renderHighchart({
       userTable <- rv$userTable
       ColnameX <- rv$ColnameX
       ColnameY <- rv$ColnameY
       hchart(userTable, "scatter", hcaes(x = ColnameX,
                                             y = ColnameY)
       )
   })

Is gut to test print(class(userTable)), print(class(ColnameX))

Managed to make it work like this:

highchartGraph <- renderHighchart({
        userTable <- rv$userTable
        X <- rv$ColnameX
        Y <- rv$ColnameY
        outp <- highchart() %>%
            hc_title(text = "highcharter") %>%
            hc_add_series(data = cbind(userTable[[X]], userTable[[Y]]),
                          type = "scatter")
        outp
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM