anychart.onDocumentReady(function () {
var chart = anychart.pyramid([
{name: "Fantasy", value: 637166, custom_field: "info 1"},
{name: "Science Fiction", value: 721630, custom_field: "info 2"},
{name: "Detective", value: 148662, custom_field: "info 3"},
{name: "Classics", value: 78662, custom_field: "info 4"},
{name: "Textbooks", value: 90000, custom_field: "info 5"}
chart.labels().useHtml(true);
chart.tooltip().useHtml(true);
chart.labels().format(function() {
var percentOfTotal = (this.getData("value")*100)/this.getStat("sum");
return "<span style='color:#dd2c00;font-weight:bold'>" +
this.name + ": " + percentOfTotal.toFixed(1) + "%</span>";
return this.name + ": " +percentOfTotal.toFixed(1) + "%";
chart.tooltip().format(function() {
var percentOfTotal = (this.getData("value")*100)/this.getStat("sum");
return "<span style='font-size:18'>" +
percentOfTotal.toFixed(1) + "% (" +
this.value + ")</span><br><br>" +
this.getData("custom_field");
return percentOfTotal.toFixed(1) + "% (" + this.value +
")<br><br>" + this.getData("custom_field");
chart.container("container");