Skip to content

Instantly share code, notes, and snippets.

@englianhu englianhu/index.html
Created Apr 25, 2016

Embed
What would you like to do?
n1
<!doctype HTML>
<html>
<head>
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script>
<script src='//nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script>
<style>
.chart_container {
position: relative;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
}
.rChart {
display: inline-block;
margin-left: 40px;
}
.yAxis {
position: absolute;
top: 0;
bottom: 0;
width: 40px;
}
.legend {
position: absolute;
top: 0;
right: -160px;
vertical-align: top;
}
.slider {
margin-left: 40px;
margin-top: 12px;
}
</style>
</head>
<body>
<div class='chart_container'>
<div id='yAxisiframesrc' class='yAxis'></div>
<div id='iframesrc' class='rChart rickshaw'></div>
<div id='xAxisiframesrc' class='xAxis'></div>
<div id='legendiframesrc' class='legend'></div>
<div id='slideriframesrc' class='slider'></div>
</div>
<script type='text/javascript'>
$(document).ready(function(){
drawiframesrc()
});
function drawiframesrc(){
var opts = {
"dom": "iframesrc",
"width": 600,
"height": 400,
"x": "Group + Term",
"y": "Freq",
"group": "Group",
"type": "multiBarChart",
"id": "iframesrc"
},
data = [
{
"Group": "blogs",
"Term": "hut",
"Freq": 7
},
{
"Group": "news",
"Term": "hut",
"Freq": 7
},
{
"Group": "twitter",
"Term": "hut",
"Freq": 7
},
{
"Group": "blogs",
"Term": "ignorieren",
"Freq": 4
},
{
"Group": "news",
"Term": "ignorieren",
"Freq": 4
},
{
"Group": "twitter",
"Term": "ignorieren",
"Freq": 4
},
{
"Group": "blogs",
"Term": "ignoriert",
"Freq": 8
},
{
"Group": "news",
"Term": "ignoriert",
"Freq": 8
},
{
"Group": "twitter",
"Term": "ignoriert",
"Freq": 8
},
{
"Group": "blogs",
"Term": "mittag",
"Freq": 14
},
{
"Group": "news",
"Term": "mittag",
"Freq": 14
},
{
"Group": "twitter",
"Term": "mittag",
"Freq": 14
},
{
"Group": "blogs",
"Term": "probieren",
"Freq": 6
},
{
"Group": "news",
"Term": "probieren",
"Freq": 6
},
{
"Group": "twitter",
"Term": "probieren",
"Freq": 6
},
{
"Group": "blogs",
"Term": "typen",
"Freq": 5
},
{
"Group": "news",
"Term": "typen",
"Freq": 5
},
{
"Group": "twitter",
"Term": "typen",
"Freq": 5
},
{
"Group": "blogs",
"Term": "woher",
"Freq": 11
},
{
"Group": "news",
"Term": "woher",
"Freq": 11
},
{
"Group": "twitter",
"Term": "woher",
"Freq": 11
}
]
if(!(opts.type==="pieChart" || opts.type==="sparklinePlus" || opts.type==="bulletChart")) {
var data = d3.nest()
.key(function(d){
//return opts.group === undefined ? 'main' : d[opts.group]
//instead of main would think a better default is opts.x
return opts.group === undefined ? opts.y : d[opts.group];
})
.entries(data);
}
if (opts.disabled != undefined){
data.map(function(d, i){
d.disabled = opts.disabled[i]
})
}
nv.addGraph(function() {
var chart = nv.models[opts.type]()
.width(opts.width)
.height(opts.height)
if (opts.type != "bulletChart"){
chart
.x(function(d) { return d[opts.x] })
.y(function(d) { return d[opts.y] })
}
d3.select("#" + opts.id)
.append('svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
};
</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.