multileveltreemap.php
Back to Chart Graphics
addTitle("Animal Kingdom Census", "Arial Bold Italic", 18);
# Set the plotarea at (30, 30) and of size 540 x 540 pixels
$c->setPlotArea(30, 30, 540, 540);
# Obtain the root of the tree map, which is the entire plot area
$root = $c->getRootNode();
# Add first level nodes to the root. We do not need to provide data as they will be computed as the
# sum of the second level nodes.
$root->setData(null, $animals, $colors);
# Add second level nodes to each of the first level node
$root->getNode(0)->setData($fish_data, $fish_names);
$root->getNode(1)->setData($amphibian_data, $amphibian_names);
$root->getNode(2)->setData($reptile_data, $reptile_names);
$root->getNode(3)->setData($bird_data, $bird_names);
$root->getNode(4)->setData($mammal_data, $mammal_names);
# Get the prototype (template) for the first level nodes.
$nodeConfig = $c->getLevelPrototype(1);
# Set the label format for the nodes to show the label with 8pt Arial Bold font in semi-transparent
# black color (0x77000000). Put the text at the top left corner of the cell.
$nodeConfig->setLabelFormat("{label}", "Times New Roman Bold Italic", 18, 0x77000000, TopLeft);
# Set the border color to white (ffffff)
$nodeConfig->setColors(-1, 0xffffff);
# Get the prototype (template) for the second level nodes.
$nodeConfig2 = $c->getLevelPrototype(2);
# Set the label format for the nodes to show the label and value with 8pt Arial Bold font. Put the
# text at the center of the cell.
$nodeConfig2->setLabelFormat("{label}<*br*>{value}", "Arial Bold", 8, TextColor, Center);
# Set the border color to white (ffffff)
$nodeConfig2->setColors(-1, 0xffffff);
# Output the chart
$viewer = new WebChartViewer("chart1");
$viewer->setChart($c, SVG);
# Include tool tip for the chart
$viewer->setImageMap($c->getHTMLImageMap("", "", "title='<*cdml*>{label}: {value}'"));
?>
Multi Level Tree Map
Multi Level Tree Map
renderHTML(); ?>