Giter Site home page Giter Site logo

dygraph-extra's Introduction

dygraph-extra

A modified version of the original dygraph-extra JavaScript library that adds the ability to export dygraph plots as a png image, among other things. Intended to be used in shiny with dygraphs for R, but dygraph-extra.js does work as a standalone.

Refer to the shiny-example for the actual files and an example of basic usage.

Dependencies:

  • jQuery (loaded by shiny automatically)
  • JSZip (only required if downloading multiple dygraphs in a single link)

License:

dygraph-extra.js

This is a modified version of dygraph-extra.js originally released in 2011 by Juan Manuel Caicedo Carvajal.

The modifications are:

  • Fixed y label positioning.
  • Automatic detectection of fonts for the labels, rather than relying on predefined or user-supplied fonts. This still isn't perfect, but should be closer to the actual dygraph.
  • Fix overflow of legends for too many series (legends now wrap).
  • A method for registering dygraphs via a drawcallback, primarily useful for those using the R version of dygraphs.
  • A function for downloading one or more registered dygraphs where the dygraphs to download are identified by their id and where multiple plots are zipped together using JSZip.
  • Functions to address some bugs/annoyances with dygraphs:
    • correct automatic resize on visiblity change.
    • correct clearance of selection on mouseleave.

dygraph-extra-shiny.R

Contains a number of R functions that make it easier to use dygraph-extra.js in shiny.

Example: dyDownload

dyDownload-Button.png

dyDownload("dyout", "Download Plot", asbutton = TRUE)

Example: dyDownloadGroup

dyDownloadGroup.png

dyDownloadGroup("oecoDyDownloads", "Download Plots:", c(
      "Value added by tourism as a percentage of GDP" = "oecogdpperc",
      "Value added by tourism" = "oecogdp",
      "Tourism employment as a percentage of total employment" = "oecoempperc",
      "Tourism employment" = "oecoemp",
      "International tourism as a percentage of total exports" = "oecoexpperc",
      "Total expenditure" = "oecospend"
   ))

dygraph-extra's People

Contributors

joh024 avatar jstagge avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

dygraph-extra's Issues

can't download when you add annotation [dyAnnotation]

hello

when i add annotation to the dygraphwith dyAnnotationdownload doesnt work
i just add one annotation to your example :

library(shiny)
library(dygraphs)
source("dygraph-extra-shiny.R")

shinyServer(function(input, output, session){
  ## Using one of the demos from https://rstudio.github.io/dygraphs/
  ## Only addition is the line adding the callback
  ##  to register the dygraph with dygraph-extra
  hw <- HoltWinters(ldeaths)
  predicted <- predict(hw, n.ahead = 72, prediction.interval = TRUE)

  outdy = dygraph(predicted, main = "Predicted Lung Deaths (UK)") %>%
    dyAxis("x", drawGrid = FALSE) %>%
   dySeries(c("lwr", "fit", "upr"), label = "Deaths") %>%
    dyOptions(colors = RColorBrewer::brewer.pal(3, "Set1")) %>% 
    dyAnnotation(as.POSIXlt("1985-02-14") ,
                 text = paste("birthday"),
                 attachAtBottom = F,
                 width = 60,
                 height = 25)%>%
    dyCallbacks(drawCallback = dyRegister())

     output$dyout = renderDygraph(outdy)
    })

the script run no R error or warning but there is a javascript error :
TypeError: Dygraph.Export.putLabelAnn is not a function

thank you

issue with dyDownload

Hi, I am using dygraphs to create dinamic graphics and I want to save the output as png. I have discovered the dyDownload from you, and it works at some extent, although the output that I get does not look exactly how it should (the years should appear in the same location as the grey vertical lines)
ts136099413609941111ts8c355c
Do you know where the issue could be?
Thank you in advance and best regards

local storage

Hello!

Thank you for the great tool. I would have one question. I use shiny locally and would need this function to save dygraphs on my hard disk. Everytime on the same place with the same name (so the downlaod path selection dialogue would not be neede). I tried to find out, where i could change the code to do so (more are less pass a fixed path from shiny to the javascript or so) but i got lost totally. I have never worked with javascript so maybe you can give me a hint?

Greets and thanks ikua

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.