Skip to content

Instantly share code, notes, and snippets.

@gshotwell
Created February 25, 2015 17:35
Show Gist options
  • Save gshotwell/554cca4e40882248c354 to your computer and use it in GitHub Desktop.
Save gshotwell/554cca4e40882248c354 to your computer and use it in GitHub Desktop.
Seasonal Dygraph Question
library("dygraphs")
library("lubridate")
library("xts")
months <- data.frame(month = 1:12, year_1 = 401:412, year _2 = 501:512)
test$month<- paste("2000-", test$month, "-01")
test$month<- ymd(test$month)
dygraph(xts(test[, 2:3], test$month ))
@timelyportfolio
Copy link

library("dygraphs")
library("lubridate")
library("xts")

test <- data.frame(month = 1:12, year_1 = 401:412, year_2 = 501:512)
test$month<- paste("2000-", test$month, "-01")
test$month<- ymd(test$month)
dygraph(xts(test[, 2:3], test$month )) %>%
  dyAxis(
    "x"
    ,axisLabelFormatter = htmlwidgets::JS(
      'function(d){
        var d = new Date(d);
              return d.strftime("%b")
      }'
    )
    ,valueFormatter = htmlwidgets::JS(
      'function(d){
        debugger;
        var d = new Date(d);
              return d.strftime("%b")
      }'
    )
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment