hrbrmstr / metricsgraphics

:chart_with_upwards_trend: htmlwidget interface to the MetricsGraphics.js D3 chart library
http://hrbrmstr.github.io/metricsgraphics/
Other
132 stars 35 forks source link

Allow explicit variable names #31

Closed jrowen closed 9 years ago

jrowen commented 9 years ago

This should fix #18. I included a new test, and the shiny example below works as expected.

library(shiny)
library(metricsgraphics)

ui = shinyUI(
  fluidPage(
    sidebarPanel(
      selectInput("x", "X", colnames(mtcars), "wt"),
      selectInput("y", "Y", colnames(mtcars), "mpg")
    ),
    mainPanel(
      metricsgraphicsOutput('mjs1')
    )
  )
)

server = function(input, output) {
  output$mjs1 <- renderMetricsgraphics({
    mtcars %>%
      mjs_plot(x=input$x, y=input$y, width=400, height=300) %>%
      mjs_point(color_accessor=carb, size_accessor=carb) %>%
      mjs_labs(x="Weight of Car", y="Miles per Gallon")
  })
}

shinyApp(ui = ui, server = server)