This shows how to destroy and recreate the pie chart.
var pie = null;
function create() {
pie = new d3pie("pie", {
header: {
title: {
text: "A Very Simple Pie"
}
},
data: {
content: [
{ label: "JavaScript", value: 264131 },
{ label: "Ruby", value: 218812 },
{ label: "Java", value: 157618}
]
}
});
}
$(function() {
create();
// assign event handlers for the demo
$("#destroyBtn").on("click", function(e) {
if (pie !== null) {
pie.destroy();
pie = null;
}
});
$("#recreateBtn").on("click", function(e) {
create();
});
});