This post is an extension to the post where we now plot multiple lines and each line is draggable.
Highcharter library returning data to page with draggable points
Thanks to the SO post by jbkunst.
server.R
ui.R
Highcharter library returning data to page with draggable points
Thanks to the SO post by jbkunst.
server.R
library(shiny)
library(highcharter)
library(data.table)
myData <- data.table(x=2012:2016, data.frame(myYax = c(3900, 4200, 5700, 8500, 11900), myZax=c(3900, 4200, 500, 800, 1000)))
shinyServer(function(input, output) {
#Make a copy of the data table. It will be run only once when use opens the application
m_data <- myData
output$text1 <- renderText({
paste("You have selected ",input$xaxis_name)
})
output$text2 <- renderText({
paste("You have selected ",input$yaxis_name)
})
output$view <- renderTable({
colname <- ifelse(input$hcinput$id == "myYax", "myYax", "myZax")
m_data[x==input$hcinput$x][[colname]] <<- input$hcinput$y
m_data})
output$hcontainer <- renderHighchart({
hc <- highchart() %>%
hc_chart(type = "line", animation=FALSE) %>%
hc_title(text = "A simple demo") %>%
hc_subtitle(text = "A subtitle") %>%
hc_xAxis(categories = m_data$x) %>%
hc_plotOptions(
series = list(
point = list(
events = list(
drop = JS("function(){
Shiny.onInputChange('hcinput', { id: this.series.name, x: this.category, y: this.y})
}")))
,stickyTracking = FALSE
),
column = list(
stacking = "normal"
),
line = list(
cursor = "ns-resize"
)) %>%
hc_add_series(
data = m_data$myYax , name = "myYax",draggableY = TRUE
) %>%
hc_add_series(
data = m_data$myZax , name = "myZax",draggableY = TRUE
)
hc
})
})
ui.R
library(shiny)experiment_code.R
shinyUI(
fluidPage(
titlePanel("High Charter plotting"),
highchartOutput("hcontainer",height = "500px"),
textOutput("text1"),
textOutput("text2"),
tableOutput("view")
)
)
library(shiny)
library(highcharter)
runApp("experiment3")
Thanks For sharing the blog..Watingfor next update..
ReplyDeleteTypes of digital marketing
What is Digital Marketing?