Step 1
You will need to enable jQuery since qTip is dependent on jQuery.
Step 2
Save the tooltip information inside some attribute, here I use the name of the attribute name
.attr("title", function(d) {
return "" + d.Total.toFixed(2);
})
Add a class bound to the path.
.attr("class", "tooltipped")
Step 3
Using a jQuery selector to append this to an entire path that has a class tooltipped
$(".tooltipped").qtip({
overwrite: true,
content: {
text: function(d) {
return ($(this).attr("title"));
}
},
position: {
at: "top middle"
},
style: {
classes: "qtip-light"
}
});
:
var store = [{
Name: "Item 1",
Total: 18.73424242
}, {
Name: "Item 2",
Total: 7.34311
}, {
Name: "Item 3",
Total: 3.1235535
}, {
Name: "Item 4",
Total: 12.763574
}];
var colorScale = new Plottable.Scales.Color();
var legend = new Plottable.Components.Legend(colorScale);
var pie = new Plottable.Plots.Pie()
.attr("fill", function(d) {
return d.Name;
}, colorScale)
.addDataset(new Plottable.Dataset(store))
.attr("title", function(d) {
return "" + d.Total.toFixed(2);
})
.attr("class", "tooltipped")
.sectorValue(function(d) {
return d.Total;
})
.labelsEnabled(true);
new Plottable.Components.Table([
[pie, legend]
]).renderTo("#chart");
$(".tooltipped").qtip({
overwrite: true,
content: {
text: function(d) {
return ($(this).attr("title"));
}
},
position: {
at: "top middle"
},
style: {
classes: "qtip-light"
}
});
<link href="https://rawgithub.com/palantir/plottable/develop/plottable.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.1/basic/jquery.qtip.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://rawgithub.com/palantir/plottable/develop/plottable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.1/basic/jquery.qtip.js"></script>
<div id="container">
<svg id="chart" width="350" height="350"></svg>
</div>
Hide result