1 nv.addGraph(function() {
2 var chart = nv.models.pieChart()
3 .x(function(d) { return d.label })
4 .y(function(d) { return d.value })
5 .showLabels(true);
6
7 d3.select("#chart svg")
8 .datum(exampleData())
9 .transition().duration(1200)
10 .call(chart);
11
12 return chart;
13 });
14
15 nv.addGraph(function() {
16 var chart = nv.models.pieChart()
17 .x(function(d) { return d.label })
18 .y(function(d) { return d.value })
19 .showLabels(true)
20 .labelThreshold(.05)
21 .donut(true);
22
23 d3.select("#chart2 svg")
24 .datum(exampleData())
25 .transition().duration(1200)
26 .call(chart);
27
28 return chart;
29 });
30
31
32
33 function exampleData() {
34 return [
35 {
36 key: "Cumulative Return",
37 values: [
38 {
39 "label" : "CDS / Options" ,
40 "value" : 29.765957771107
41 } ,
42 {
43 "label" : "Cash" ,
44 "value" : 0
45 } ,
46 {
47 "label" : "Corporate Bonds" ,
48 "value" : 32.807804682612
49 } ,
50 {
51 "label" : "Equity" ,
52 "value" : 196.45946739256
53 } ,
54 {
55 "label" : "Index Futures" ,
56 "value" : 0.19434030906893
57 } ,
58 {
59 "label" : "Options" ,
60 "value" : 98.079782601442
61 } ,
62 {
63 "label" : "Preferred" ,
64 "value" : 13.925743130903
65 } ,
66 {
67 "label" : "Not Available" ,
68 "value" : 5.1387322875705
69 }
70 ]
71 }
72 ];
73 }