Code Monkey home page Code Monkey logo

dygraphs's Introduction

dygraphs for R

CRAN status R-CMD-check codecov

The dygraphs package is an R interface to the dygraphs JavaScript charting library. It provides rich facilites for charting time-series data in R, including:

  • Automatically plots xts time series objects (or any object convertible to xts).
  • Highly configurable axis and series display (including optional second Y-axis).
  • Rich interactive features including zoom/pan and series/point highlighting.
  • Display upper/lower bars (e.g. prediction intervals) around series.
  • Various graph overlays including shaded regions, event lines, and point annotations.
  • Use at the R console just like conventional R plots (via RStudio Viewer).
  • Seamless embedding within R Markdown documents and Shiny web applications.

Installation

The dygraphs package depends on the development version of the htmlwidgets package so you need to install both packages. You can do this using the devtools package as follows:

devtools::install_github(c("ramnathv/htmlwidgets", "rstudio/dygraphs"))

Usage

If you have an xts-compatible time-series object creating an interactive plot of it is as simple as this:

dygraph(nhtemp, main = "New Haven Temperatures")

You can also further customize axes and series display as well as add interacitve features like a range selector:

dygraph(nhtemp, main = "New Haven Temperatures") %>%
  dyAxis("y", label = "Temp (F)", valueRange = c(40, 60)) %>%
  dyOptions(fillGraph = TRUE, drawGrid = FALSE) %>%
  dyRangeSelector()

See the online documentation for the dygraphs package for additional details and examples.

dygraphs's People

Contributors

bthieurmel avatar charlesbordet avatar danielkrizian avatar dgromer avatar hdrab127 avatar jeffreyhanson avatar jjallaire avatar jrowen avatar klaukh avatar londonrockslive avatar michelk avatar mpastell avatar ntwi avatar przmv avatar renkun-ken avatar timelyportfolio avatar wdwatkins avatar yihui 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  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  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

dygraphs's Issues

Second Y-Axis with dygraphs

I'm wondering if it's possible to plot something like this in case I want to have a secondary axis? Precipitation/rainfall was plotted from the top with type = "h". Thank you very much!

topmodel_calibration_0103_final

Disabling scientific notation?

If I set options(scipen=500) I still end up using scientific notation in dygraphs for numbers below that limit (but above the default). Is this a dygraph bug, a non-configurable option, ...?

Viewer problem using a loop ?

Hi,

Trying to print several dygraphs plot in a loop, nothing appear. It's seems it's not a dygraphs problem, but perhaps more globally a viewer problem. Can you ever heard about that ?

for(i in 1:2){
  lungDeaths <- cbind(mdeaths, fdeaths)
  dygraph(lungDeaths)
  readline(prompt = "next : ")
}

group option may kill your browser in Shiny apps

Hi,

thanks for the great work on making the dygraphs functionality available in Shiny!

I came across some unexpected behavior of the dygraph package which kills your browser session (I tried the most recent versions of Firefox, Chrome and IE).

What I basically do is use renderUI to dynamically create a set of dygraphs.

Let's say I have an appropriate xts object called DD, which has as rownames the time information and a set of 10 columns containing some data. Now let's say I want to dynamically construct a set of 10 separate dygraphs i.e. one for each column in DD.

This code chunk works just fine:

# ui.r 
uiOutput(Charts)

# server.r
output$Charts <- renderUI({

  # insert some code here to construct an xts object called DD

  L <- lapply(1:10, function(i){
    # generate a chart ID
    ID   <- paste0("Chart",i)

   # use it to directly assign a dygraph to output
    output[[ID]] <- renderDygraph({
      dygraph(dd[,i], main = "") 
    })

   # put ui.r related calls in a list
    return(dygraphOutput(outputId = ID, height = "150px"))
  })

  # return the list
  return(L)
})

If I add some options to the dygraphs all goes well, until you say you want to use the group statement to link the zoom behavior of multiple dygraphs. When you do this and run the code your browser is dead :-(

That is, if you were to use e.g.

output[[ID]] <- renderDygraph({
      dygraph(dd[,i], main = "", group = "Source") 
  })

I think this is a bug.

kind regards, Herman

saveDygraph function to save to a html file?

Should there be a dedicated function to save a dygraph to html?
I know there's saveWidget, but other widgets like networkD3 have dedicated functions as well (saveNetwork in this case).

I'm asking primarily because my dygraph saved with saveWidget didn't look as nice as in the RStudio Viewer (the legend text was'nt styled), and thought a proper saveDygraph function might do a better job.

Issue with datatable (DT) and dygraph (dygraphs) in same Rmd

I am running into issues when trying to produce a DT::datatable and a dygraphs::dygraph in the same R markdown file. Upon rendering, the dygraph is not present in the HTML file. Below is a minimally reproducible example of my R code and my Rmd file (test.Rmd).

library(rmarkdown)
render("./test.Rmd")


---
title: "test"
author: "Mr. Test"
date: "Tuesday, April 14, 2015"
output: html_document

---

```{r}
# R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
# Copyright (C) 2014 The R Foundation for Statistical Computing
# Platform: x86_64-w64-mingw32/x64 (64-bit)

# DT version is: 0.0.25
library(DT)

# dygraphs version is: 0.4.3
library(dygraphs)
```


```{r}
datatable(iris)
```

```{r}
dygraph(mdeaths)
```

access information on user interaction with dygraph?

Is it possible to access information on the user's input to dyRangeSelector or the brushed range? Suppose, for example, the available data ranges from 2001-2010 and the user has selected 2002-2005 using the range selector or brushing. Is that information accessible from R (Shiny)?

Thanks for a fantastic library!

Error in Shiny output rendering permanently breaks dygraph

Once an error occurs, the error message never goes away and the dygraph never comes back. This is because the default behavior of Shiny output bindings is to render errors by replacing the contents of the DOM element with the error message.

This is not a great default for htmlwidgets, I'm looking into what we can do differently there.

library(shiny)
library(dygraphs)

ui <- fluidPage(
  checkboxInput("error", "Error?"),
  dygraphOutput("dy")
)

server <- function(input, output, session) {
  output$dy <- renderDygraph({
    if (input$error)
      stop("Boom")
    dygraph(nhtemp, main = "New Haven Temperatures", ylab = "Temp (F)") 
  })
}

shinyApp(ui, server)

slow rendering in fill graph

My graph has 8760 points and with fillGraph option it is slow to zoom and select range with range selector option.
This is fixed in dygraphs.js 1.1.0 version. Becareful though dygraph 1.1.0 has shrunk it's size and moved code to an addition "extra" code

Use + instead of %>%

I feel no problem with %>%, but those who use ggplot2 may be familiar with + to add layers.

What do you think about implementing +.dygraph, like ggplot2?

How to ensure correct formatting to able to process a data.frame

Sorry to bother you on a simple issue but I am keen to use dygraphs and I'm having problem getting an object I can process.
Here is an example data.frame of a few scores by time, in minutes and seconds elapsed for a basketball game

df <- structure(list(time = c("0:00", "0:15", "0:37", "0:46", "1:04",
"1:04"), hScore = c(0L, 3L, 3L, 5L, 5L, 5L), aScore = c(0L, 0L,
2L, 2L, 2L, 2L)), row.names = c(NA, -6L), class = "data.frame", .Names = c("time",
"hScore", "aScore"))

library(dygraphs)
library(dplyr)

df %>%
dygraphs()

Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
I've tried a few things without success

Disabling scientific format in dygraphs

Hi @jjallaire. I would like to disabling scientific format in Dyphaphs. I tried to use options (digits and scipen). However it didn't work.

Here my example:

nhtemp2<-nhtemp*1000000
dygraph(nhtemp2, main = "New Haven Temperatures", ylab = "Temp (F)")

Dynamic resizing for static plots

It would be useful if static plots in a Shiny app (i.e., not used with dygraphOutput) could resize automatically to their enclosing div. For example:

shinyApp(
  ui = bootstrapPage(div(
    dygraph(nhtemp, main = "New Haven Temperatures")
  )),
  server = function(input, output) { }
)

Is there a way to plot multiple charts in RStudio's viewer?

Sorry if I am posting at the wrong place. What I want is a stock price chart above a trading volume chart. I know that you can use group to synchronize them, but in RStudio two dygraphs are plotted separately into different pages. Is there a way to put these two (or even more) charts on the same plot in RStudio's viewer, like ggplot2's facets?

retainDateWindow = FALSE same as TRUE?

I installed today's build (devtools::install_github(c("ramnathv/htmlwidgets", "rstudio/dygraphs") on R 3.2/Windows 8.1 and the option doesn't appear to work as expected. Code below.

Thanks,
Stephen

library(shiny)
library(dygraphs)
library(datasets)

ui = fluidPage(

titlePanel("Predicted Deaths from Lung Disease (UK)"),

sidebarLayout(
sidebarPanel(
numericInput("months", label = "Months to Predict",
value = 72, min = 12, max = 144, step = 12),
selectInput("interval", label = "Prediction Interval",
choices = c("0.80", "0.90", "0.95", "0.99"),
selected = "0.95"),
checkboxInput("showgrid", label = "Show Grid", value = TRUE),
hr(),
div(strong("From: "), textOutput("from", inline = TRUE)),
div(strong("To: "), textOutput("to", inline = TRUE)),
br(),
helpText("Click and drag to zoom in (double click to zoom back out).")
),
mainPanel(
dygraphOutput("dygraph")
)
)
)

server = function(input, output) ({

predicted <- reactive({
hw <- HoltWinters(ldeaths)
predict(hw, n.ahead = input$months,
prediction.interval = TRUE,
level = as.numeric(input$interval))
})

output$dygraph <- renderDygraph({
dygraph(predicted(), main = "Predicted Deaths/Month") %>%
dySeries(c("lwr", "fit", "upr"), label = "Deaths") %>%
dyOptions(drawGrid = input$showgrid, retainDateWindow = FALSE)
})

output$from <- renderText({
if (!is.null(input$dygraph_date_window)) strftime(input$dygraph_date_window[[1]], "%d %b %Y")
})

output$to <- renderText({
if (!is.null(input$dygraph_date_window)) strftime(input$dygraph_date_window[[2]], "%d %b %Y")
})
})

shinyApp( ui=ui, server=server)

Previous dygraph properties are not deleted when the dygraph is redrawn in shiny

Here is my shiny app code, ui.R:

library(dygraphs)

shinyUI(fluidPage(

  titlePanel("Predicted Deaths from Lung Disease (UK)"),

  sidebarLayout(
    sidebarPanel(
        checkboxInput("do_roll",label="Do rolling",value=FALSE),
        conditionalPanel(condition='$("#do_roll").prop("checked")',
                         numericInput("roll", label = "Rolling period", value = 12, min = 1, max = 24, step = 1)
                         ),
        width=2
    ),
    mainPanel(
        dygraphOutput("dygraph1",height="200px"),
        dygraphOutput("dygraph2",height="200px")
    )
  )
))

server.R:

library(dygraphs)
library(datasets)

shinyServer(function(input, output) {

  do_graph <- function(x,title) {
      g <- dygraph(x, main = title, group="activity")
      if(input$do_roll) {
          g <- g %>% dyRoller(rollPeriod = input$roll)
      }
      g
  }

  output$dygraph1 <- renderDygraph({
      do_graph(mdeaths,"Male")
  })

  output$dygraph2 <- renderDygraph({
      do_graph(fdeaths,"Female")
  })
})

I want rolling to be optional. If I check the "Do rolling" checkbox, rolling appears, but when I uncheck it, it does not dissappear, although the graph is redrawn from the scratch. At least it should be redrawn judging from the code. This behaviour works with ggvis plots, in case where you want to change colors or add labels based on user input.

Auto-refresh seems to confuse dygraphs

We have some shiny-based dashboards where we refresh some standard R graphs on a refresh timers -- this works great but is not interactive.

Trying such code with dygraphs does not work so well. The x-axis seems frozen to the old range.

Is this a known issue (I could not find any tickets) or a new one? I could possibly mock something up.

how-can-i-get-tooltips-showing-in-dygraphs-without-annotation

asked in SO http://stackoverflow.com/questions/27671576/how-can-i-get-tooltips-showing-in-dygraphs-without-annotation
but no response

library(dygraphs)

dygraph(presidents, main = "Presidential Approval") %>%
dyAxis("y", valueRange = c(0, 100)) %>%
dyAnnotation("1950-7-1", text = "A", tooltip = "Korea") %>%
dyAnnotation("1965-1-1", text = "B",  tooltip = "Vietnam")

rplot

Hovering over the 'A' produces a tooltip with 'Korea'

I am keen to have a tooltip for every point preferably dispensing entirely with the text requirement - though setting text to "" with minimal height/width values might suffice. I would also want to attach the dyAnnotations programmatically from a file with date and tooltip columns

df <- data.frame(date=as.Date(c("1950-7-1","1965-1-1")),tooltip=c("Korea","Vietnam"))

Is this feasible,and, if so, how? TIA

Datetimes displays in different time zone

Hi,

When I load a time series with an specific time zone in R and I plot it using dygraphs, time zones are displayed in sistem time zone (or browser time zone not sure which value is getting). Therefore time zone information of the ts object seems to be discarded.

library(dygraphs)
library(xts)
datetimes<-seq.POSIXt(as.POSIXct("2015-01-01",tz="GMT"),
                      as.POSIXct("2015-01-07",tz="GMT"),by="3 hours")
values<-rnorm(length(datetimes))

serie<-xts(values,order.by = datetimes,tz="GMT")
head(serie)
dygraph(serie)

Synchronization of dygraphs in Shiny apps

Plotting a single dygraph in a Shiny app works really well. However, when trying to plot several dygraphs (and using the group option to synchronize them as shown in the doc) doesn't seem to work.

graphs do not display with shiny

Hi all,

Altough I have no problem using dygrpah from Rstudio normally, none of the dygraph display once I use shiny.

I am using a MacbookPro 10.10 (but similar issue on mac desktop).
I have tried to use both your example of shiny (the one here: https://rstudio.github.io/dygraphs/shiny.html),
I have also try to use my own (http://stackoverflow.com/questions/30176303/using-dygraph-with-shiny/30178925?noredirect=1#comment48475753_30178925)

But none of the graph display, although the whole shiny app display correctly. (just the graph is not there :-(

Version:

version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 2.0
year 2015
month 04
day 16
svn rev 68180
language R
version.string R version 3.2.0 (2015-04-16)
nickname Full of Ingredients

dygraph taken from github.

Any idea why the graphs are not displaying?
Thanks

Problem with the example with the last version of quantmod

I'm reporting than Quantmod changes its defaults (auto.assign and env changes)
This code can replicate your example on the documentation (http://rstudio.github.io/dygraphs/gallery-upper-lower-bars.html)

library(quantmod)
getSymbols(c("MSFT", "HPQ"), from = "2014-06-01",auto.assign=TRUE,
env=parent.frame())

[1] "MSFT" "HPQ"

stocks <- cbind(MSFT[,2:4], HPQ[,2:4])
dygraph(stocks, main = "Microsoft and HP Share Prices") %>%
dySeries(c("MSFT.Low", "MSFT.Close", "MSFT.High"), label = "MSFT") %>%
dySeries(c("HPQ.Low", "HPQ.Close", "HPQ.High"), label = "HPQ")

ISO date format

Hi!

On windows (R version 3.0.2) I get only empty graph. After some debugging I am pretty sure it is because "my" format.POSIXct returns empty string when formated as "%F".

Maybe the asISO8601Time function in dygraphs/R/utils.R could be changed to

asISO8601Time <- function(x) {
  if (!inherits(x, "POSIXct"))
    x <- as.POSIXct(x)
  format(x, format="%Y-%m-%dT%H:%M:%SZ")
}

For now my workaround is:

res1 <- dygraph(nhtemp, main = "New Haven Temperatures",  ylab = "Temp (F)") 
res1$x$data[[1]] <- format( attr(res1$x, "time"), "%Y-%m-%dT%H:%M:%SZ")
res1

Dare

Loading new data into an existing dygraph does not refresh input$<dygraphId>_data_window property

Good Day

First some preliminaries, I am using:

Rstudio v 0.98.1103; R v 3.1.3 (32 bit), Shiny v 0.11.1, dygraphs v 0.4.3 ; this is on windows 8.1.

I would appreciate any help with respect to the issue of resetting the input$_date_window property (referred to as '_date_window' property here on) in shiny.

When my shiny application loads up and the first instance of the dygraph is created the '_date_window' property is responsive and outputs the correct dates pertaining to the graph. Further when highlighting the graph to zoom in and double clicking on the graph to reset the zoom the '_date_window' property is responsive and changes accordingly.

The problem arises when I attempt to load a different data set into the graph. For some reason, beyond my abilities to understand, the '_date_window' property retains the previous data set's dates. That is, when the new data set is included and the graph renders a new picture, everything looks good except for the simple fact that the '_date_window' property will not change to reflect the new data's dates.

I have included a one file demonstration of this problem below, that can be copied and pasted directly into the interactive console.

The code below, downloads prices for General Electric (GE) and Facebook (FB). Then plots the returned 'Close' prices to the dygraph of the selected entry in the selectInput object.

The point to note is that once a time series is loaded the respective start and end dates are shown in the textOutput objects. Therefore you can see how these respective start and end dates don't change when a new stock code is selected. Thus prompting the application to redraw the closing prices, but for some reason not updating the '_data_window' property.

Any guidance with respect to this issue would be appreciated, as I really do like using dygraphs!

*********************************************************************

library(quantmod)
library(dygraphs)

getSymbols(c("GE", "FB"), src = "yahoo")

portf <- list()

portf$FB <- FB$FB.Close
portf$GE <- GE$GE.Close

server <- function(input, output) {

output$dygraph <- renderDygraph({

    input$scode
    dygraph(portf[[input$scode]])

})

output$frmDate <- renderText({

    if (!is.null(input$dygraph_date_window))
        strftime(input$dygraph_date_window[[1]], "%d %b %Y")   

})

output$toDate <- renderText({

    if (!is.null(input$dygraph_date_window))
        strftime(input$dygraph_date_window[[2]], "%d %b %Y")   

})

}

ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("scode", "Code", choices = c("FB", "GE")),
textOutput("frmDate"),
textOutput("toDate")
),
mainPanel(
dygraphOutput("dygraph")
)
)
)

shinyApp(ui = ui, server = server)

'#######################################################

dateWindow to return only the final date

Hi,

Using the range selector, I am controlling multiple other objects in shiny.
The datewindow values changes constantly even though the user did not release the cursor.
Therefore those objects have to be updated for every change when actually only the last date returned by the range selector is of importance.
Is there a way to only output the last date/ time?

Thanks

Feature Request: Millisecond Plotting

Hi,

Great graphing tool, thank you.
I believe you are already incorporating rChartsDygraphs from danielkrizian.

Someone previously discussed millisecond plotting with that library.
It would be very useful if the rstudio version of dygraphs could automatically detect and correctly plot
millisecond (or microsecond) level XTS data.

For example, the following is a microsecond stamped XTS series which gets pruned down to per second data

len <- 60 * 60  + 10
RDData <- xts(runif(len,0,1), seq(as.POSIXct("2015-04-01 10:00:00"),  as.POSIXct("2015-04-02 15:00:00"), length = len),tz="GMT")
dygraph(RDData) %>%  dyOptions(useDataTimezone = TRUE)

The dygraphs workaround is to use axisLabelFormatter and valueFormatter but I don't see these parameters supported in the current rstudio implementation.

Thanks

Cannot set strokeWidth per-series

First, a big thank you for this great R package!

I can't manage to set the strokewidth per-series and it is mentioned in the help page that one can do it.

For instance, I believe the short code snippet under should set the strokewidth per series (as it is with colours)

library(dygraphs)
dygraph(cbind(ldeaths, mdeaths, fdeaths), main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(colors = c("green", "blue", "red"), strokeWidth = c(1,3,5))

The resulting line chart with the code above have all the same strokeWidth. But setting strokeWidth globally for all series works:

library(dygraphs)
dygraph(cbind(ldeaths, mdeaths, fdeaths), main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(colors = c("green", "blue", "red"), strokeWidth = 10)

Graphing negative and positive numbers?

I'm trying to graph data with negative and positive numbers. In this example of daily high and low temperatures in Fargo, ND - csv file here - my graph y axis is just showing 1 to -13 and the data is not showing properly.

fargo <- read.csv("fargoTemps2014.csv", colClasses = c("Date", "integer", "integer"))
fargo_for_graph <- xts::xts(fargo, order.by = fargo$Date)
dygraph(fargo_for_graph)

fargograph

Implement option `visibility` to toggle series visibility on/off

This is just an enhancement/feature request to implement existing JavaScript visibility option:

From http://dygraphs.com/tests/visibility.html :

new Dygraph(
            document.getElementById("div_g"),
            NoisyDataABC, {
              rollPeriod: 7,
              errorBars: true,
              visibility: [false, true, true]
            }
          );

In R dygraphs it doesn't work yet:

library(dygraphs)

lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(visibility=c(TRUE,FALSE, TRUE))

Should be also a per-series option:

dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries(name='mdeaths", visibility=FALSE)

Thank you

Extras/plugins

Hi,
we have developed couple of specialized extras/plugins to the dygraphs library, such as crosshair, straw-broom/rebase chart type, ribbon, canvas annotations with popup window, candlestick chart with monthly/weekly/daily compression..., see:
https://github.com/danielkrizian/dygraphs/issues?q=is%3Aissue+is%3Aclosed

They have been made available and tested in R through the rChartsDygraphs library.
Would it be possible to merge those features into your project and thus enrich the possibilities?
Thanks!

Show and hide series via the legend

Hello,

Could you consider adding the following functionnality: show and hide series by clicking on their names in the legend ?

Thanks,
Matt

Update dygraph-combined.js and dygraphs on CRAN

Can you think about updating dygraph-combined.js to 1.1.0 ? Can have some cool improvement (I think about fill charts, which can be long actually...)

  • dygraphs is now "retina" compatible.
  • Dramatically improved performance for filled charts (i.e. fillGraph)
  • More sensible date ticks: "Jan 08"→"Jan 2008", "29Jan"→"29 Jan"
  • Using a non-existent option now throws (w/ dygraph-combined-dev.js)
  • x-axis log scales
  • The labelsUTC option forces UTC formatting for all labels.
  • The new DataHandler system allows for more flexibility in data loading.
  • "this" is set to the dygraph in all callbacks.
  • dygraphs has shrunk, because we moved some stuff into "extras" (133kb→122kb)

And, when the next CRAN update ? (I think to useDataTimezone to...)

Option to allow loading new data into an existing dygraph -AND- refreshing input$<dygraphId>_data_window property

Hi JJ,

First, great work on this project! Beautiful.

I would ask you to consider addressing issue #43 with a new option defaulted to keep the behavior as you have designed. There is a whole class of problems in the data exploration space (vs real-time monitoring space) that would benefit from this enhancement.

I would suggest the option dateWindowRefresh = FALSE by default and dateWindowRefresh = TRUE, which would allow the user to stay zoomed in -and- the input$_date_window to continue updating on data refresh.

Range selector not working after recomputing the data

Hi,
I am trying to control an external network graph using the dygraph range selector.
On my shiny app, I have some checkbox. When I check or uncheck the boxes, it changes the data on the dygraph.
However, after the first time I check one box, the dygraph range selector does not output the right start and end value anymore.

See the reproducible example here:
library(shiny)
library(dygraphs)
library(xts)

ui <- shinyUI(fluidPage(

    ## Application title
    title = "Dygraph Demo",
    titlePanel("Dygraph Demo"),

    fluidRow(
            dygraphOutput("dygraph1", height = '350px') ,
            fluidRow(column(7, verbatimTextOutput("fromY1"))),
            checkboxGroupInput("datachoice", label = "Data Choice",
                               choices = c("+10"  = 1, "+20" = 2, 
                                           "+30" = 3),
                               selected = 1)
    )

))

server <- function(input, output, session) {

    data <- reactive({
            lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
            for (k in seq_along(as.numeric(input$datachoice))){
                    lungDeaths <- lungDeaths + 10*k   
            }
            lungDeaths

    })

    output$dygraph1 <- renderDygraph( {
            X <- data()
            dg <- dygraph(X) 
            dg <- dyRangeSelector(dg,dateWindow = NULL,height = 40,fillColor = " #A7B1C4", strokeColor = "#808FAB") 
    } )
    output$fromY1 <- renderText({
            if (!is.null(input$dygraph1_date_window)){

                    paste(strftime(input$dygraph1_date_window[[1]], '%Y-%m-%d'),
                          strftime(input$dygraph1_date_window[[2]], '%Y-%m-%d'), sep = ' to ')

            }


    })

}

shinyApp(ui = ui, server = server)

You will see the data change if you do not check any of the boxes. However as soon as you change the boxes the date does not change anymore.
I am not sure why this is happening.

Thanks.

graph not showing

Dygraphs looks fantastics. Just installed it from github and tried:

library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths)

I get a blank webpage in Rstudio, Chrome, and Safari. When I go to the js console the following message is show:

image

R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] dygraphs_0.2

loaded via a namespace (and not attached):
[1] digest_0.6.4 grid_3.1.2 htmltools_0.2.6 htmlwidgets_0.2.4 lattice_0.20-29 magrittr_1.0.1 RJSONIO_1.3-0 xts_0.9-7 yaml_2.1.13
[10] zoo_1.7-11

dygraphs is not working well

Hi @jjallaire, thanks for creating this package. It's awesome 😄 (as all the packages from RStudio)

I know this package is under development as htmlwidget... My problem is about showing the "line" (I don't know what word to use)
See the photo below
image

I don't know if it's a bug from htmlwidget or dygraphs.

I installed this package about 5 days ago and it didn't work well. Today, I reinstalled both packages and it's having the same problem.
I don't know if it's related with the last commit of htmlwidget. (https://github.com/ramnathv/htmlwidgets/branches)
I tried to use other branches of htmlwidget but it's still not working well. Actually it doesn't work at all. I mean it does't show anything (unless using the master branch, you can see the "plot" but not the "line")

my sessioInfo

R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Spanish_Peru.1252 LC_CTYPE=Spanish_Peru.1252 LC_MONETARY=Spanish_Peru.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Peru.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] htmlwidgets_0.2.3 dygraphs_0.1

loaded via a namespace (and not attached):
[1] animint_2014.6.10 colorspace_1.2-4 devtools_1.5 dichromat_2.0-0 digest_0.6.4
[6] evaluate_0.5.3 formatR_0.10 ggplot2_0.9.3.1.99 grid_3.1.0 gtable_0.1.2
[11] htmltools_0.2.6 httr_0.4 knitr_1.6 labeling_0.2 lattice_0.20-29
[16] magrittr_1.1.0 MASS_7.3-31 memoise_0.1 munsell_0.4.2 packrat_0.4.0.12
[21] parallel_3.1.0 plyr_1.8.1 proto_0.3-10 RColorBrewer_1.0-5 Rcpp_0.11.1
[26] RCurl_1.95-4.1 reshape2_1.2.2 RJSONIO_1.0-3 scales_0.2.3 stringr_0.6.2
[31] tools_3.1.0 whisker_0.3-2 xts_0.9-7 yaml_2.1.11 zoo_1.7-11

Is it possible to draw candlestick graph?

Financial time series is an important category of time series data. Is it possible for dygraphs to draw candlesticks given open, high, low, close data (matrix or data frame)?

If there's a demo, that would be great!

Potential bug in color option in dySeries

The following code from the tutorial

dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("mdeaths", drawPoints = TRUE, color = "blue") %>%
  dySeries("fdeaths", stepPlot = TRUE, fillGraph = TRUE, color = "red")

does not result in the specified colors for the two series. Specifying dyOptions(colors = c('red', 'blue')) works. Is this a bug?

How to use dygraphs in slidify?

Hi! I'm trying to use the package dygraphs into my slidify presentation in R. However, it seems it's not as straightforward as I thought. Is there any extra command I need to add in order to use the htmlwidgets produced by the dygraphs() commands?

Thanks!

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.