Skip to content

Instantly share code, notes, and snippets.

@cddesja
Created December 11, 2014 12:02
Show Gist options
  • Save cddesja/e6c66a930bc424f9c8e6 to your computer and use it in GitHub Desktop.
Save cddesja/e6c66a930bc424f9c8e6 to your computer and use it in GitHub Desktop.
chart2
<!doctype HTML>
<meta charset = 'utf-8'>
<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>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body >
<div id = 'chart14a635c033aa' class = 'rChart nvd3'></div>
<script type='text/javascript'>
$(document).ready(function(){
drawchart14a635c033aa()
});
function drawchart14a635c033aa(){
var opts = {
"dom": "chart14a635c033aa",
"width": 800,
"height": 400,
"x": "Time",
"y": "value",
"group": "variable",
"type": "multiBarChart",
"id": "chart14a635c033aa"
},
data = [
{
"Time": 0,
"variable": "RelFCD",
"value": 1
},
{
"Time": 364,
"variable": "RelFCD",
"value": 0.780363
},
{
"Time": 365,
"variable": "RelFCD",
"value": 0.780369
},
{
"Time": 728,
"variable": "RelFCD",
"value": 0.730291
},
{
"Time": 730,
"variable": "RelFCD",
"value": 0.730304
},
{
"Time": 1092,
"variable": "RelFCD",
"value": 0.689377
},
{
"Time": 1095,
"variable": "RelFCD",
"value": 0.689415
},
{
"Time": 1456,
"variable": "RelFCD",
"value": 0.659339
},
{
"Time": 1460,
"variable": "RelFCD",
"value": 0.659458
},
{
"Time": 1820,
"variable": "RelFCD",
"value": 0.625151
},
{
"Time": 1825,
"variable": "RelFCD",
"value": 0.625358
},
{
"Time": 2184,
"variable": "RelFCD",
"value": 0.594461
},
{
"Time": 2190,
"variable": "RelFCD",
"value": 0.594756
},
{
"Time": 2548,
"variable": "RelFCD",
"value": 0.553515
},
{
"Time": 2555,
"variable": "RelFCD",
"value": 0.553914
},
{
"Time": 2912,
"variable": "RelFCD",
"value": 0.519356
},
{
"Time": 2920,
"variable": "RelFCD",
"value": 0.519864
},
{
"Time": 3276,
"variable": "RelFCD",
"value": 0.47415
},
{
"Time": 3285,
"variable": "RelFCD",
"value": 0.474779
},
{
"Time": 3640,
"variable": "RelFCD",
"value": 0.43621
},
{
"Time": 3650,
"variable": "RelFCD",
"value": 0.43697
},
{
"Time": 4004,
"variable": "RelFCD",
"value": 0.388856
},
{
"Time": 4015,
"variable": "RelFCD",
"value": 0.389743
},
{
"Time": 4368,
"variable": "RelFCD",
"value": 0.351384
},
{
"Time": 4380,
"variable": "RelFCD",
"value": null
},
{
"Time": 0,
"variable": "RelFCA",
"value": 1
},
{
"Time": 364,
"variable": "RelFCA",
"value": 0.420971
},
{
"Time": 365,
"variable": "RelFCA",
"value": 0.420958
},
{
"Time": 728,
"variable": "RelFCA",
"value": 0.169095
},
{
"Time": 730,
"variable": "RelFCA",
"value": 0.169135
},
{
"Time": 1092,
"variable": "RelFCA",
"value": 0.152744
},
{
"Time": 1095,
"variable": "RelFCA",
"value": 0.152859
},
{
"Time": 1456,
"variable": "RelFCA",
"value": 0.11547
},
{
"Time": 1460,
"variable": "RelFCA",
"value": 0.11562
},
{
"Time": 1820,
"variable": "RelFCA",
"value": 0.031151
},
{
"Time": 1825,
"variable": "RelFCA",
"value": 0.031198
},
{
"Time": 2184,
"variable": "RelFCA",
"value": 0.001235
},
{
"Time": 2190,
"variable": "RelFCA",
"value": 0.001237
},
{
"Time": 2548,
"variable": "RelFCA",
"value": 0.000165
},
{
"Time": 2555,
"variable": "RelFCA",
"value": 0.000165
},
{
"Time": 2912,
"variable": "RelFCA",
"value": 5e-06
},
{
"Time": 2920,
"variable": "RelFCA",
"value": 5e-06
},
{
"Time": 3276,
"variable": "RelFCA",
"value": 0
},
{
"Time": 3285,
"variable": "RelFCA",
"value": 0
},
{
"Time": 3640,
"variable": "RelFCA",
"value": 0.189643
},
{
"Time": 3650,
"variable": "RelFCA",
"value": 0.189995
},
{
"Time": 4004,
"variable": "RelFCA",
"value": 0.226043
},
{
"Time": 4015,
"variable": "RelFCA",
"value": 0.227335
},
{
"Time": 4368,
"variable": "RelFCA",
"value": 0.218343
},
{
"Time": 4380,
"variable": "RelFCA",
"value": null
},
{
"Time": 0,
"variable": "RelWMW",
"value": 1.014513
},
{
"Time": 364,
"variable": "RelWMW",
"value": 1.007023
},
{
"Time": 365,
"variable": "RelWMW",
"value": 1.007024
},
{
"Time": 728,
"variable": "RelWMW",
"value": 1.002756
},
{
"Time": 730,
"variable": "RelWMW",
"value": 1.002758
},
{
"Time": 1092,
"variable": "RelWMW",
"value": 0.999113
},
{
"Time": 1095,
"variable": "RelWMW",
"value": 0.999116
},
{
"Time": 1456,
"variable": "RelWMW",
"value": 0.995774
},
{
"Time": 1460,
"variable": "RelWMW",
"value": 0.995778
},
{
"Time": 1820,
"variable": "RelWMW",
"value": 0.992577
},
{
"Time": 1825,
"variable": "RelWMW",
"value": 0.992581
},
{
"Time": 2184,
"variable": "RelWMW",
"value": 0.988004
},
{
"Time": 2190,
"variable": "RelWMW",
"value": 0.988009
},
{
"Time": 2548,
"variable": "RelWMW",
"value": 0.983473
},
{
"Time": 2555,
"variable": "RelWMW",
"value": 0.983479
},
{
"Time": 2912,
"variable": "RelWMW",
"value": 0.979621
},
{
"Time": 2920,
"variable": "RelWMW",
"value": 0.979627
},
{
"Time": 3276,
"variable": "RelWMW",
"value": 0.976358
},
{
"Time": 3285,
"variable": "RelWMW",
"value": 0.976363
},
{
"Time": 3640,
"variable": "RelWMW",
"value": 0.973548
},
{
"Time": 3650,
"variable": "RelWMW",
"value": 0.973553
},
{
"Time": 4004,
"variable": "RelWMW",
"value": 0.970862
},
{
"Time": 4015,
"variable": "RelWMW",
"value": 0.970867
},
{
"Time": 4368,
"variable": "RelWMW",
"value": 0.968603
},
{
"Time": 4380,
"variable": "RelWMW",
"value": null
}
]
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>
<script></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment