Skip to content

Commit

Permalink
Merge pull request novus#909 from liquidpele/fix_piegrow
Browse files Browse the repository at this point in the history
Fix for where pie chart changes...
  • Loading branch information
robinfhu committed Mar 21, 2015
2 parents b2f19be + 93af505 commit d24d2d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 48 deletions.
65 changes: 20 additions & 45 deletions examples/donutChart.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
svg {
display: block;
float: left;
}
#test2 {
height: 350px !important;
width: 350px !important;
}

#test3 {
height: 500px !important;
width: 500px !important;
#test1 {
height: 350px !important;
width: 350px !important;
}

html, body {
Expand All @@ -44,8 +45,6 @@
</head>
<body class='with-3d-shadow with-transitions'>

<svg id="test3" class="mypiechart"></svg>

<svg id="test1" class="mypiechart"></svg>

<svg id="test2" class="mypiechart"></svg>
Expand All @@ -61,14 +60,15 @@
{key: "Four", y: 7},
{key: "Five", y: 4},
{key: "Six", y: 3},
{key: "Seven", y: 0.5},
{key: "Seven", y: 0.5}
];

var height = 350;
var width = 350;

var chart1;
nv.addGraph(function() {
var chart = nv.models.pieChart()
var chart1 = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
.donut(true)
Expand All @@ -78,22 +78,23 @@
.cornerRadius(5)
.id('donut1'); // allow custom CSS for this one svg

chart.title("100%");
chart.pie.donutLabelsOutside(true).donut(true);
chart1.title("100%");
chart1.pie.donutLabelsOutside(true).donut(true);

d3.select("#test1")
.datum(testdata)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);
.call(chart1);

//nv.utils.windowResize(chart1.update);

return chart;
return chart1;

});


var chart2;
nv.addGraph(function() {
var chart = nv.models.pieChart()
var chart2 = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
//.labelThreshold(.08)
Expand All @@ -107,45 +108,19 @@
.title("woot");

// MAKES IT HALF CIRCLE
chart.pie
chart2.pie
.startAngle(function(d) { return d.startAngle/2 -Math.PI/2 })
.endAngle(function(d) { return d.endAngle/2 -Math.PI/2 });

d3.select("#test2")
//.datum(historicalBarChart)
.datum(testdata)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);
.call(chart2);

return chart;
return chart2;
});

nv.addGraph(function() {
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
.donut(true)
.width(width)
.height(height)
.padAngle(.08)
.cornerRadius(5)
.id('donut1'); // allow custom CSS for this one svg

chart.title("100%");
chart.pie.donutLabelsOutside(true).donut(true);

d3.select("#test3")
.datum(testdata)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);

return chart;

});

</script>
</body>
Expand Down
7 changes: 4 additions & 3 deletions src/models/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ nv.models.pie = function() {
, dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')
;

var arcs = [];
var arcsOver = [];

//============================================================
// chart function
Expand Down Expand Up @@ -84,9 +86,8 @@ nv.models.pie = function() {
});
});

var arcs = [];
var arcsOver = [];

arcs = [];
arcsOver = [];
for (var i = 0; i < data[0].length; i++) {

var arc = d3.svg.arc().outerRadius(arcsRadiusOuter[i]);
Expand Down

0 comments on commit d24d2d9

Please sign in to comment.