-1
output$plot3 <- renderChart2({
    dat <- candyData[candyData$candyChoice %in% input$candyChoice, ]
    if(!is.na(dat)){ 
      n <- nPlot(freq ~ purchase_month, group = 'candy choice', data=dat, type = "lineChart")
    }
  })

My dates, when printed in my console, are shown like this:

"2014-04-01" "2014-05-01" "2014-06-01" "2014-07-01" "2014-08-01" "2014-09-01" "2014-10-01"
"2014-11-01" "2014-12-01" "2015-01-01" "2015-02-01" "2015-03-01" "2015-04-01" "2015-05-01"
"2015-06-01" "2015-07-01" "2015-08-01"

My dates on the plot are showing up like this: enter image description here

Any suggestions on how to fix this would be warmly welcomed!

Update 2 The graph lines don't match up with the nPlot interactive tooltip. Do you know how to fix this? enter image description here

Gary
  • 2,137
  • 3
  • 23
  • 41
  • 2
    [How to make a great R reproducible example?](http://stackoverflow.com/questions/5963269) – zx8754 Oct 20 '15 at 20:02

1 Answers1

1

Format your xaxis

n$xAxis(tickFormat ="#! function(d) {return d3.time.format('%Y/%m')(new Date(d*1000*3600*24));} !#")
Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • 1
    its just how R talks to JS, I think you need this operation to convert datetime objects from R to JS – Pork Chop Oct 21 '15 at 14:23
  • Thanks for your help, Pork Chop. For some reason, the graphs on the chart don't line up with the values on the x-axis. Do you know how to fix this? I've attached a photo above to illustrate. Thanks! – Gary Oct 21 '15 at 20:51
  • Tooltop issue is a different question, I think you should create another question as this one is closed and will confuse users – Pork Chop Oct 22 '15 at 08:44