Hi Dan,
This solution worked perfectly for me to choose the tickers for my Dygraph. I choose my tickers to appear every month, however, when I change the dateRange to be displayed, the xlabels become too crowded and I would prefer if only a few of them showed up. Here is my code:
getMonth <- 'function(d){
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var day = d.getUTCDate();
var month = d.getMonth();
var year = d.getYear()-100;
return monthNames[d.getMonth()] + year;
}'
getMonthDay <- 'function(d) {
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
date = new Date(d);
return monthNames[date.getMonth()] + " " +date.getFullYear(); }'
tickMonth<- 'function (a, b, pixels, opts, dygraph, vals) {
return Dygraph.getDateAxis(a, b, Dygraph.MONTHLY, opts, dygraph);
}'
dygraph(shopping, main="Monthly", xlab="Date", ylab="Index") %>% dyAxis("x", valueFormatter=JS(getMonthDay), axisLabelFormatter=JS(getMonth), ticker=JS(tickMonth), pixelsPerLabel=50, rangePad=20, drawGrid = FALSE) %>% dyAxis("y", valueRange = c((min(selecteddates$Index)-3), (max(selecteddates$Index)+3))) %>% dyLegend(show="onmouseover", width=200) %>% dyOptions(axisLabelFontSize=10)
It seems like once I choose the tickers, pixelsPerLabel is ignored fully.