r - NVD3 Bullet Chart with rCharts -


wondering if possible produce nvd3 bullet chart (http://nvd3.org/examples/bullet.html) directly via rcharts ?

poking around seems nvd3.r might lack ability pass required (ranges, measures, , markers) arguments down d3 - i'm not sure.

thanks !

here 18 examples ramnath rcharts package related java scriptnvd3 package, no sign of bullet chart, guess not there.

## {title: scatter chart} p1 <- nplot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterchart')   p1$xaxis(axislabel = 'weight') p1   ## {title: multibar chart} hair_eye = as.data.frame(haireyecolor)   p2 <- nplot(freq ~ hair, group = 'eye', data = subset(hair_eye, sex == "female"), type = 'multibarchart') p2$chart(color = c('brown', 'blue', '#594c26', 'green')) p2  ## {title: multibar horizontal chart}    p3 <- nplot(~ cyl, group = 'gear', data = mtcars, type = 'multibarhorizontalchart') p3$chart(showcontrols = f) p3  ## {title: pie chart}   p4 <- nplot(~ cyl, data = mtcars, type = 'piechart') p4  ## {title: donut chart}    p5 <- nplot(~ cyl, data = mtcars, type = 'piechart') p5$chart(donut = true) p5  ## {title: line chart} data(economics, package = 'ggplot2')   p6 <- nplot(uempmed ~ date, data = economics, type = 'linechart') p6  ## {title: line focus chart } ecm <- reshape2::melt(economics[,c('date', 'uempmed', 'psavert')], id = 'date')   p7 <- nplot(value ~ date, group = 'variable', data = ecm, type = 'linewithfocuschart') #test format dates on xaxis #also test of javascript functions parameters #dates r json come on number of days since 1970-01-01 #so convert milliseconds 86400000 in day , format d3 #on linewithfocuschart type xaxis set x2axis unless specified p7$xaxis( tickformat="#!function(d) {return d3.time.format('%b %y')(new date( d * 86400000 ));}!#" ) #test xaxis sets x2axis p7 #now test setting x2axis different #test format dates on x2axis #test show %y format different xaxis p7$x2axis( tickformat="#!function(d) {return d3.time.format('%y')(new date( d * 86400000 ));}!#" ) p7 #test set xaxis again make sure not override set x2axis p7$xaxis( null, replace = t) p7  ## {title: stacked area chart} dat <- data.frame(t=rep(0:23,each=4),var=rep(letters[1:4],4),val=round(runif(4*24,0,50)))    p8 <- nplot(val ~ t, group =  'var', data = dat, type = 'stackedareachart', id = 'chart') p8   ## {title: interactiveguidline(multi-tooltips) on line}   p9 <- nplot(value ~ date, group = 'variable', data = ecm, type = 'linechart') p9$xaxis( tickformat="#!function(d) {return d3.time.format('%b %y')(new date( d * 86400000 ));}!#" ) #try new interactive guidelines feature p9$chart(useinteractiveguideline=true) p9   ## {title: interactiveguidline(multi-tooltips) on stack}   p10 <- p8 p10$chart(useinteractiveguideline=true) p10  ## {title: showdistx , showdisty}   p11 <- p1 p11$chart(showdistx = true, showdisty = true) p11  ## {title: multichart}   p12 <- nplot(value ~ date, group = 'variable', data = ecm, type = 'multichart')    p12$params$multi = list(   uempmed = list(type="area",yaxis=1),   psavert = list(type="line",yaxis=2) ) p12$settemplate(script = system.file(   "/libraries/nvd3/layouts/multichart.html",   package = "rcharts" )) p12  ## {title: facets}    p13 <- nplot(mpg ~ wt, data = mtcars, group = "gear", type = "scatterchart") p13$params$facet = "cyl" p13$templates$script = system.file(   "/libraries/nvd3/layouts/nvd3facetplot.html",   package = "rcharts" ) p13  hair_eye = as.data.frame(haireyecolor)    p14 <- nplot(freq ~ hair, group = 'sex', data = hair_eye, type = 'multibarchart') p14$params$facet="eye" p14$templates$script = system.file(   "/libraries/nvd3/layouts/nvd3facetplot.html",   package = "rcharts" )   p14     p15 <- nplot(freq ~ hair, group = 'eye', data = hair_eye, type = 'multibarchart') p15$params$facet="sex" p15$templates$script = system.file(   "/libraries/nvd3/layouts/nvd3facetplot.html",   package = "rcharts" ) p15   ## {title: sparklines}     p16 <- nplot(uempmed ~ date, data = economics, type = 'sparklineplus',height=100,width=500) p16$chart(xtickformat="#!function(d) {return d3.time.format('%b %y')(new date( d * 86400000 ));}!#") p16 ## semi replicate sparkline full nvd3 model setting short height , turning off lots of things    p17 <- nplot(   x = "date",   y = "volume",   data = spy.df,   type = "multibarchart",   height = 200) p17$chart(showcontrols = false, showlegend = false, showxaxis = false, showyaxis = false)  p17$xaxis(tickformat =    "#!function(d) {return d3.time.format('%y-%m-%d')(new date(d * 24 * 60 * 60 * 1000));}!#" )    p17   ## {title: ohlcbar} ## ohlcbar not implemented on nvd3 side, no axes or interactive controls ## note not melt if using ohlcbar require(quantmod)  spy <- getsymbols("spy",auto.assign=false,from="2013-01-01") colnames(spy) <- c("open","high","low","close","volume","adjusted")  spy.df <- data.frame(index(spy),spy) colnames(spy.df)[1] <- "date"  p18 <- nplot(   x = "date",   y = "close",   data = spy.df,   type = "ohlcbar" ) p18 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -