Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio timelyportfolio/code.R
Last active Aug 29, 2015

Embed
What would you like to do?
rCharts Polycharts Heatmap Issue # 77
data.new <- data.frame(id = 1:1000)
data.new$Employer <- c("aaa","bbb","ccc","ddd","eee")[runif(n=1000,min=1,max=6)]
data.new$Type <- c("Nonacademic", "Postdoc", "Fixed Term Academic", "Other Tenure Track", "Research University")[runif(n=1000,min=1,max=6)]
data.new$Year <- c("2010","2011","2012","2013")[runif(n=1000,min=1,max=5)]
data.new <-
data.frame(xtabs( ~ Employer + Type + Year, data = data.new))
colnames(data.new)[4] <- "Value"
require(rCharts)
hmap <- rPlot(height=350,
width=615,
x="Employer",
y="Type",
color="Value",
data = data.new,
type = "tile",
tooltip = "#! function(item){
return item.Employer}
!#")
hmap$set(legendPosition = 'none')
hmap$set(title = "Initial Placements")
hmap$guides("{color: {scale: {type: gradient, lower: pink, upper: red}}}")
hmap$guides(x = list(levels = data.new$Employer))
hmap$guides(x = list(title="Year"))
hmap$guides(y = list(title=" "))
hmap$guides(x = list(
min = 1995,
max = 2013,
numticks = 2,
labels = c("1995", "2013")
))
hmap$guides(y = list(levels = c("Nonacademic", "Postdoc", "Fixed Term Academic", "Other Tenure Track", "Research University")))
hmap
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body >
<div id = 'chart7ec42f1503' class = 'rChart polycharts'></div>
<script type='text/javascript'>
var chartParams = {
"dom": "chart7ec42f1503",
"width": 800,
"height": 400,
"layers": [
{
"x": "Employer",
"y": "Type",
"data": {
"Employer": [ "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee" ],
"Type": [ "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Research University", "Research University", "Research University", "Research University", "Research University", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Research University", "Research University", "Research University", "Research University", "Research University", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Research University", "Research University", "Research University", "Research University", "Research University", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Fixed Term Academic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Nonacademic", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Other Tenure Track", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Postdoc", "Research University", "Research University", "Research University", "Research University", "Research University" ],
"Year": [ "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2010", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2011", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2012", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013", "2013" ],
"Value": [ 9, 12, 11, 7, 11, 13, 14, 9, 9, 6, 7, 7, 7, 6, 10, 2, 9, 11, 9, 17, 10, 11, 10, 10, 8, 13, 10, 7, 9, 10, 7, 6, 9, 8, 9, 21, 8, 11, 6, 7, 9, 8, 10, 10, 6, 8, 14, 5, 9, 12, 11, 7, 13, 11, 13, 14, 7, 10, 15, 9, 9, 11, 7, 14, 17, 9, 15, 12, 14, 10, 8, 5, 9, 12, 10, 13, 11, 12, 13, 11, 5, 11, 11, 10, 8, 13, 10, 6, 11, 14, 11, 10, 10, 10, 11, 10, 10, 9, 10, 11 ]
},
"facet": null,
"height": 350,
"width": 615,
"color": "Value",
"type": "tile",
"tooltip": function(item){
return item.Employer}
}
],
"facet": [],
"guides": {
"color": {
"scale": {
"type": "gradient",
"lower": "pink",
"upper": "red"
}
},
"x": {
"levels": [ "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee", "aaa", "bbb", "ccc", "ddd", "eee" ],
"title": "Year",
"min": 1995,
"max": 2013,
"numticks": 2,
"labels": [ "1995", "2013" ]
},
"y": {
"title": " ",
"levels": [ "Nonacademic", "Postdoc", "Fixed Term Academic", "Other Tenure Track", "Research University" ]
}
},
"coord": [],
"legendPosition": "none",
"title": "Initial Placements",
"id": "chart7ec42f1503"
}
_.each(chartParams.layers, function(el){
el.data = polyjs.data(el.data)
})
var graph_chart7ec42f1503 = polyjs.chart(chartParams);
</script>
<script></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.