153 lines
2.8 KiB
HTML
153 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
|
|
<style>
|
|
|
|
body {
|
|
overflow-y:scroll;
|
|
}
|
|
|
|
text {
|
|
font: 12px sans-serif;
|
|
}
|
|
|
|
</style>
|
|
<body>
|
|
|
|
<svg id="test1"></svg>
|
|
<svg id="test2"></svg>
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
<script src="../nv.d3.js"></script>
|
|
<script src="../src/models/legend.js"></script>
|
|
<script src="../src/models/pie.js"></script>
|
|
<script src="../src/models/pieChart.js"></script>
|
|
<script src="../src/utils.js"></script>
|
|
<script>
|
|
|
|
var testdata = [
|
|
{
|
|
key: "One",
|
|
y: 5
|
|
},
|
|
{
|
|
key: "Two",
|
|
y: 2
|
|
},
|
|
{
|
|
key: "Three",
|
|
y: 9
|
|
},
|
|
{
|
|
key: "Four",
|
|
y: 7
|
|
},
|
|
{
|
|
key: "Five",
|
|
y: 4
|
|
},
|
|
{
|
|
key: "Six",
|
|
y: 3
|
|
},
|
|
{
|
|
key: "Seven",
|
|
y: .5
|
|
}
|
|
];
|
|
|
|
|
|
|
|
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
|
|
}
|
|
]
|
|
}
|
|
];
|
|
|
|
|
|
|
|
nv.addGraph(function() {
|
|
var width = 500,
|
|
height = 500;
|
|
|
|
var chart = nv.models.pieChart()
|
|
.x(function(d) { return d.label })
|
|
.y(function(d) { return d.value })
|
|
//.showLabels(false)
|
|
.color(d3.scale.category10().range())
|
|
.width(width)
|
|
.height(height);
|
|
|
|
d3.select("#test1")
|
|
.datum(historicalBarChart)
|
|
//.datum(testdata)
|
|
.transition().duration(1200)
|
|
.attr('width', width)
|
|
.attr('height', height)
|
|
.call(chart);
|
|
|
|
return chart;
|
|
});
|
|
|
|
nv.addGraph(function() {
|
|
var width = 500,
|
|
height = 500;
|
|
|
|
var chart = nv.models.pieChart()
|
|
.x(function(d) { return d.key })
|
|
//.y(function(d) { return d.value })
|
|
.values(function(d) { return d })
|
|
//.labelThreshold(.08)
|
|
//.showLabels(false)
|
|
.color(d3.scale.category10().range())
|
|
.width(width)
|
|
.height(height)
|
|
.donut(true);
|
|
|
|
d3.select("#test2")
|
|
//.datum(historicalBarChart)
|
|
.datum([testdata])
|
|
.transition().duration(1200)
|
|
.attr('width', width)
|
|
.attr('height', height)
|
|
.call(chart);
|
|
|
|
return chart;
|
|
});
|
|
|
|
</script>
|