var bigData = [
{
data: [[0, 6]],
label: 'a',
sub: [{ // sub pie data
data: [[0, 2]],
label: 'a1'
}, {
data: [[0, 4]],
label: 'a2'
}]
}, {
data: [[0, 4]],
label: 'b',
sub: [{ // sub pie data
data: [[0, 3]],
label: 'b1'
}, {
data: [[0, 1]],
label: 'b2'
}]
}
];
(function basic(container, data) {
var graph;
// Draw Graph
graph = Flotr.draw(container, data, {
title: 'Click a slice to see the details',
pie: {
show: true
},
mouse: {
track: true,
trackFormatter: function (obj) {
return obj.series.label + ': ' + obj.y;
}
}
});
graph.observe(container, 'flotr:click', function (position) {
var obj = position.hit; // hit information when there is a hit.
if (obj && obj.series && obj.series.sub) {
return basic(container, obj.series.sub);
} else {
return basic(container, bigData);
}
});
})(document.getElementById("example"), bigData);
<div id="example"></div>
#example {
width: 400px;
height: 300px;
}
External resources loaded into this fiddle: