i working nvd3 on rcharts , wondering if there way customize axes lower view finder graph on linewithfocuschart. have provided reproducible example below, customize x , y axes have commas separating thousands place, formatting not show on lower view finder chart. how solved? thank you!
library(rcharts) temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000))) g <- nplot(y ~ x, group = "z", data = temp, type = "linewithfocuschart") g$templates$script <- "http://timelyportfolio.github.io/rcharts_nvd3_templates/chartwithtitle_styled.html" g$set(title = "example") g$chart(transitionduration = -1, tooltipcontent = "#! function(key, x, y) { return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y }!#", showlegend = false, margin = list(left = 200, right = 100, bottom = 100, top = 100)) g$xaxis(axislabel = "x", tickformat = "#!function(x) {return d3.format(',.0f')(x);}!#") g$yaxis(axislabel = "y", width = 100, tickformat = "#!function(y) {return d3.format(',.0f')(y);}!#", showmaxmin = false) g
i discovered looking @ unanswered questions tagged r. sorry missed it. rcharts has stalled, new version based on more flexible htmlwidgets infrastructure. sure answer far late, have changed template allow formatting y2axis.
# uncomment install fix #devtools::install_github("timelyportfolio/rcharts") library(rcharts) temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000))) g <- nplot(y ~ x, group = "z", data = temp, type = "linewithfocuschart") g$templates$script <- "c:/users/kent.tleavell_nt/dropbox/development/r/rcharts_nvd3_templates/chartwithtitle_styled.html" g$set(title = "example") g$chart(transitionduration = -1, tooltipcontent = "#! function(key, x, y) { return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y }!#", showlegend = false, margin = list(left = 200, right = 100, bottom = 100, top = 100)) g$xaxis(axislabel = "x", tickformat = "#!function(x) {return d3.format(',.0f')(x);}!#") g$yaxis(axislabel = "y", width = 100, tickformat = "#!function(y) {return d3.format(',.0f')(y);}!#", showmaxmin = false) g$x2axis(tickformat = "#!function(x) {return d3.format('1.2s')(x);}!#") # have new y2axis function g$y2axis( tickformat = "#!function(y) {return d3.format('1.2s')(y);}!#" ) g
Comments
Post a Comment