Open mortonanalytics opened 6 years ago
Added draggable lines; able to return new data points.
TODO: calculate linear estimates; return data to Shiny (if needed)
Completed with f6788699d9f53e1c9c602284c5bab8c22ce20d93.
Sends points and regression output to Shiny as server inputs: myIOpoints
and myIOregression
.
Sorry this took so long. I'll put a demo up tomorrow.
Resize is not right, but it corrects after dragging a point. I'll have to debug this later though or just trigger a full redraw. In the meantime, the demo app has an example: http://www.morton-analytics.com/shiny/myio_demo/ (under the line chart > regression line tabs).
Usage in app looks like this with magittr piping:
output$regLine <- renderMyIO({
myIO() %>%
addIoLayer(type = 'point',
color = 'steelblue',
label = 'MPG',
data = mtcars[order(mtcars$mpg),],
mapping = list(x_var = "wt",
y_var = "mpg")) %>%
myIO::dragPoints()
})
output$dragPoints <- renderTable({
req(input$myIOpointsX)
data.frame(x = input$myIOpointsX,
y = input$myIOpointsY,
estimate = input$myIOpointsEst)
})
Per: https://stackoverflow.com/questions/47280032/draggable-line-chart-in-rshiny