<?php
// @see http://code.google.com/apis/ajax/playground/?type=visualization#intensity_map
include_once '../d3.classes.inc.php';
include_once '../google.classes.inc.php';
include_once '../element.php';
$data = array(
array('US', 10000 , 8000),
array('CA', 7000, 5000),
array('CN', 8000, 12000),
array('GB', 7000, 15000)
);
$id = 'intensity_map';
$html = E("html");
$head = $html->head();
$body = $html->body();
$dt = google()->visualization->DataTable()->createVar("dt", true);
$head->script()->addAttribute("src", "//www.google.com/jsapi");
$head->script()->add(google(true)->load("visualization", "1", obj(array("packages"=>array('table', 'gauge', 'intensitymap', 'corechart')))));
stack()->add($dt);
stack()->add(google(true, $dt->getVar())->addColumn("string", "Country"));
stack()->add(google(true, $dt->getVar())->addColumn("number", "Sales"));
stack()->add(google(true, $dt->getVar())->addColumn("number", "Expenses"));
stack()->add(google(true, $dt->getVar())->addRows(count($data)));
foreach($data as $index => $row) {
stack()->add(google(true, $dt->getVar())->setCell($index, 0, $row[0]));
stack()->add(google(true, $dt->getVar())->setCell($index, 1, $row[1]));
stack()->add(google(true, $dt->getVar())->setCell($index, 2, $row[2]));
}
$imap = google()->visualization->IntensityMap(document()->getElementById($id))->createVar("imap", true);
stack()->add($imap);
stack()->add(google(true, $imap->getVar())->draw($dt->getVar()));
$f = func()->name("drawIntensityMap")->add(stack());
$head->script()->add($f);
$head->script()->add(google(true)->setOnLoadCallback($f->getVar("drawIntensityMap")->getVar()));
$body->toBody("div", array("id" => $id));
echo $html;
|