Some forks and experiments with the very fine work from Ben Moore http://rcharts.io/viewer/?6c9ed5eed37fe3c03fa5. For details on the original, please see the author’s blog post http://benjaminlmoore.wordpress.com/2014/05/05/what-are-the-most-overrated-films/.
#forked from http://rcharts.io/viewer/?6c9ed5eed37fe3c03fa5
#for details see the post
#http://benjaminlmoore.wordpress.com/2014/05/05/what-are-the-most-overrated-films/
require(rCharts)
require(jsonlite)
#get data extracted from the index.html
movieData <- fromJSON("data.json")
options(viewer=NULL)
rChartsObjeq <- setRefClass(
"rChartsObjeq",
contains = "Dimple",
methods = list(
initialize = function(){
callSuper();
},
render = function(chartId = NULL, cdn = F, static = T){
params$dom <<- chartId %||% params$dom
template = read_file(getOption('RCHART_TEMPLATE', templates$page))
assets = Map("c", get_assets(LIB, static = static, cdn = cdn), html_assets)
html = render_template(template, list(
params = params,
assets = assets,
chartId = params$dom,
script = .self$html(params$dom),
CODE = srccode,
lib = LIB$name,
tObj = tObj,
container = container
))
}
))
objeqPlot <- function(x, data, ...){
myChart <- rChartsObjeq$new()
myChart$getChartParams(x, data, ...)
return(myChart$copy())
}
d5 <- objeqPlot(
x = "Critics score (%)",
y = "Audience liked it (%)",
color = "Cols",
groups = c( "Title", "Difference" , "Range" ),
data = movieData,
type = "bubble",
facet = list( y = "Range" ),
query =
"Difference >= 20",
defaultColors = "d3.scale.category20()",
height = 800,
width = 800,
margins = list( bottom = 10, left = 30, top = 30, right = 30)
)
d5$xAxis (
type = "addMeasureAxis"
#,outputFormat = ".2%"
)
d5$yAxis ( type = "addMeasureAxis" )
d5$setLib("http://timelyportfolio.github.io/rCharts_objeq/examples")
d5$templates$page = "http://timelyportfolio.github.io/rCharts_objeq/examples/rCharts_objeq.html"
d5$templates$script = "http://timelyportfolio.github.io/rCharts_objeq/examples/chart_objeq_facet.html"
d5
d5$save( "index.html", cdn = T)