2012-06-28 23:06:07 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<meta charset="utf-8">
|
2012-07-13 19:25:19 +00:00
|
|
|
<link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
|
2012-06-28 23:06:07 +00:00
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
overflow-y:scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font: 12px sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<svg id="test1"></svg>
|
2012-06-29 19:28:08 +00:00
|
|
|
<svg id="test2"></svg>
|
2012-06-28 23:06:07 +00:00
|
|
|
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
|
|
<script src="../nv.d3.js"></script>
|
2012-07-01 05:39:53 +00:00
|
|
|
<script src="../src/models/legend.js"></script>
|
2012-06-28 23:06:07 +00:00
|
|
|
<script src="../src/models/pie.js"></script>
|
|
|
|
<script src="../src/models/pieChart.js"></script>
|
2012-07-26 12:23:20 +00:00
|
|
|
<script src="../src/utils.js"></script>
|
2012-06-28 23:06:07 +00:00
|
|
|
<script>
|
|
|
|
|
|
|
|
var testdata = [
|
|
|
|
{
|
|
|
|
key: "One",
|
|
|
|
y: 5
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Two",
|
|
|
|
y: 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Three",
|
|
|
|
y: 9
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Four",
|
|
|
|
y: 7
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Five",
|
|
|
|
y: 4
|
|
|
|
},
|
|
|
|
{
|
2012-06-29 19:57:39 +00:00
|
|
|
key: "Six",
|
|
|
|
y: 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Seven",
|
|
|
|
y: .5
|
2012-06-28 23:06:07 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2012-07-01 05:39:53 +00:00
|
|
|
|
|
|
|
historicalBarChart = [
|
|
|
|
{
|
|
|
|
key: "Cumulative Return",
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
"label" : "CDS / Options" ,
|
|
|
|
"value" : 29.765957771107
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Cash" ,
|
|
|
|
"value" : 0
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Corporate Bonds" ,
|
|
|
|
"value" : 32.807804682612
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Equity" ,
|
|
|
|
"value" : 196.45946739256
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Index Futures" ,
|
|
|
|
"value" : 0.19434030906893
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Options" ,
|
|
|
|
"value" : 98.079782601442
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Preferred" ,
|
|
|
|
"value" : 13.925743130903
|
|
|
|
} ,
|
|
|
|
{
|
|
|
|
"label" : "Not Available" ,
|
|
|
|
"value" : 5.1387322875705
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-28 23:06:07 +00:00
|
|
|
nv.addGraph(function() {
|
|
|
|
var width = 500,
|
|
|
|
height = 500;
|
|
|
|
|
|
|
|
var chart = nv.models.pieChart()
|
2012-07-01 05:39:53 +00:00
|
|
|
.x(function(d) { return d.label })
|
|
|
|
.y(function(d) { return d.value })
|
2012-06-28 23:06:07 +00:00
|
|
|
//.showLabels(false)
|
2012-06-29 18:28:46 +00:00
|
|
|
.color(d3.scale.category10().range())
|
2012-06-28 23:06:07 +00:00
|
|
|
.width(width)
|
|
|
|
.height(height);
|
|
|
|
|
|
|
|
d3.select("#test1")
|
2012-07-01 05:39:53 +00:00
|
|
|
.datum(historicalBarChart)
|
|
|
|
//.datum(testdata)
|
2012-06-28 23:06:07 +00:00
|
|
|
.transition().duration(1200)
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
return chart;
|
2012-06-29 19:28:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
nv.addGraph(function() {
|
|
|
|
var width = 500,
|
|
|
|
height = 500;
|
2012-06-28 23:06:07 +00:00
|
|
|
|
2012-06-29 19:28:08 +00:00
|
|
|
var chart = nv.models.pieChart()
|
2012-07-01 05:46:39 +00:00
|
|
|
.x(function(d) { return d.key })
|
|
|
|
//.y(function(d) { return d.value })
|
|
|
|
.values(function(d) { return d })
|
|
|
|
//.labelThreshold(.08)
|
2012-06-29 19:28:08 +00:00
|
|
|
//.showLabels(false)
|
|
|
|
.color(d3.scale.category10().range())
|
|
|
|
.width(width)
|
|
|
|
.height(height)
|
|
|
|
.donut(true);
|
|
|
|
|
|
|
|
d3.select("#test2")
|
2012-07-01 05:46:39 +00:00
|
|
|
//.datum(historicalBarChart)
|
|
|
|
.datum([testdata])
|
2012-06-29 19:28:08 +00:00
|
|
|
.transition().duration(1200)
|
|
|
|
.attr('width', width)
|
|
|
|
.attr('height', height)
|
|
|
|
.call(chart);
|
|
|
|
|
|
|
|
return chart;
|
|
|
|
});
|
2012-06-28 23:06:07 +00:00
|
|
|
|
|
|
|
</script>
|