Code Monkey home page Code Monkey logo

rhighcharts's Introduction

rHighcharts: An R wrapper for Highcharts JS

Created by Thomas Reinholdsson ([email protected]).


NOTE

The functionality within this R package has been implemented into rCharts created by Ramnath Vaidyanathan. Please see rCharts for further development.


rHighcharts package is an R wrapper for the Highcharts JS, which is a JavaScript charting library based on SVG and VML rendering by Highsoft Solutions AS. Highcharts JS is not free for commercial use, so make sure you have a valid license to use it.

rHighcharts is packaged with Highcharts JS v3.0.0.

Installation

library(devtools)
install_github("rHighcharts", "metagraf")

How to use

See instructions on the following page: http://glimmer.rstudio.com/reinholdsson/rHighcharts/.

Examples

Use with Shiny

server.R

library(rHighcharts)
shinyServer(function(input, output) {
    output$chart <- renderChart({
        a <- rHighcharts:::Chart$new()
        a$title(text = "Fruits")
        a$data(x = c("Apples","Bananas","Oranges"), y = c(15, 20, 30), type = "pie", name = "Amount")
        return(a)
    })
})

ui.R

library(rHighcharts)
shinyUI(bootstrapPage(
    chartOutput("chart")
))

See also

License

rHighcharts is licensed under GPL-2. However, the Highcharts JavaScript library that is included in this package is not free for commercial use. Read more about its license at http://www.highcharts.com/license.

rhighcharts's People

Contributors

oskbor avatar reinholdsson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rhighcharts's Issues

rHighcharts with events not working correctly

I've been trying to use rHighcharts with events in Shinydashboard, but I couldn't get things right. It will show the "pointer", but not the alert window. Can anyone help?

Thanks!!

server.R

require(rHighcharts)

server <- shinyServer(function(input, output) {
output$myChart2 <- renderChart({
h1 <- rHighcharts:::Chart$new()
h1$chart(type = "column", polar = FALSE)
h1$plotOptions(
series = list(
cursor = 'pointer',
point = list(
events = list(
click = "function () {alert('value: ' + this.y);}"
)
)
)
)
h1$data(c(1, 3, 2, 4, 5, 4, 6, 2, 3, 5, NA), dashStyle = "longdash")
h1$data(c(NA, 4, 1, 3, 4, 2, 9, 1, 2, 3, 4), dashStyle = "shortdot")
h1$legend(symbolWidth = 80)

return(h1)
})
})
ui.R

require(googleVis)
shinyUI(pageWithSidebar(
headerPanel("", windowTitle="Example googleVis with interaction"),
sidebarPanel(
tags$head(tags$style(type='text/css', "#selected{ display: none; }")),
selectInput("dataset", "Choose a dataset:",
choices = c("pressure", "cars")),
uiOutput("selectedOut")
),
mainPanel(
tabsetPanel(
tabPanel("Main",
htmlOutput("view"),
plotOutput("distPlot", width="300px", height="200px")),
tabPanel("About", 'http://www.google.com'
))))
)

rHighcharts issue : bar chart

Hello,

I post an issue concerning rcharts (highchart) library and shinydashboard in rCharts repository. I need this kind of visualisation and I didn't find a solution. Here, the problem :

This is an example of application mixing shinydashboard and Highchart. There are two problems :
-first, with an initial input of 50, the app doesn't display the plot. The user must click on the label "Series 1" to load the plot. Not intuitive.
-with a variable numeric input, the plot is totally blank and doesn't response anymore to the input user.
The problem is the same when using an action button and isolate function or not.

library(shiny)
library(shinydashboard)
library(rCharts)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(title = "Slider", status = "primary",sliderInput("slider", "Slider input:", 1, 100, 50)),
      box(title = "Load", status = "primary",actionButton("actionButton","Load",icon=icon("refresh"))),
      box(title = "Plot", status = "primary",showOutput("chart", "highcharts"))
      )
    )
  )
)

server <- function(input, output) {
output$chart <- renderChart2({
input$actionButton
a <- Highcharts$new()
a$chart(width=500,height=500)
a$series(data = list(
list(x = 0, y = isolate(input$slider), capital = "Stockholm", country = "Sweden"),
list(x = 1, y = isolate(input$slider)+10, capital = "Copenhagen", country = "Denmark"),
list(x = 2, y = isolate(input$slider)+20, capital = "Oslo", country = "Norway")
), type = "bar"
)
a$xAxis(categories = c("Sweden", "Denmark", "Norway"))
a$addParams(dom = "chart")
return(a)
})
}
shinyApp(ui, server)

Maybe it's a bad interaction between shinydashboard and rCharts ? this app works well using a classic shiny structure or a type of graph "column".

Besides, i would know if it's possible to draw in this kind of graph a vertical (for a bar chart) or horizontal (column chart), parallel to x axis, as a limit ? I saw something with the plotLines command in highcharts js. In the same way, is it possible to add text on chart with R ?

Thanks a lot,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.