1. Go to this page and download the library: Download codeagent/treemap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codeagent / treemap example snippets
use codeagent\treemap\Treemap;
// your data in consistent format
$data = [["value" => 2, "children" => [...]], ["value" => "4", "children" => [...]], [...], ...];
$presenter = Treemap::html($data, 1200, 800);
echo $presenter->render();
$presenter = new HtmlPresenter($treemap);
echo $presenter->render();
use codeagent\treemap\Treemap;
use codeagent\treemap\presenter\HtmlPresenter;
use codeagent\treemap\presenter\NestedHtmlPresenter;
use codeagent\treemap\presenter\CanvasPresenter;
use codeagent\treemap\presenter\ImagePresenter;
$data = [...]; // your hierarhical data
const WIDTH = 1200;
const HEIGHT = 800;
$treemap = new Treemap($data, WIDTH, HEIGHT);
$html = (new HtmlPresenter($treemap))->render();
// same as $html = Treemap::html($data, WIDTH, HEIGHT)->render();
echo $html;
$canvas = (new CanvasPresenter($treemap))->render();
// same as $canvas = Treemap::canvas($data, WIDTH, HEIGHT)->render();
echo $canvas;
$image = (new ImagePresenter($treemap, "png"))->render();
// same as $image = Treemap::image($data, WIDTH, HEIGHT, "png")->render();
header("Content-Type: image/png");
echo $image;
use codeagent\treemap\Treemap;
use codeagent\treemap\presenter\HtmlPresenter;
use codeagent\treemap\presenter\NodeInfo;
$presenter = Treemap::html($data, $width, $height)
->render(function(NodeIndo $node){
$data = $node->data();
$node->content()->html("<span>{$data['name']}</span>");
$node->background("calculated_color_here");
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.