Login   Register  
PHP Classes
elePHPant
Icontem

File: demos/014.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  d3Google  >  demos/014.php  >  Download  
File: demos/014.php
Role: Example script
Content type: text/plain
Description: Create annotated timeline
Class: d3Google
Generate JavaScript to show Google charts and maps
Author: By
Last change: fix
Date: 1 year ago
Size: 2,415 bytes
 

Contents

Class file image Download
<?php 

include_once '../d3.classes.inc.php';
include_once 
'../google.classes.inc.php';
include_once 
'../element.php';

# how to create chart options
# with the IDE autocompleter

$results = array(
    array(new 
Date(2008,1), 30000nullnull40645nullnull),
    array(new 
Date(2008,2), 14045nullnull20374nullnull),
    array(new 
Date(2008,3), 55022nullnull50766nullnull),
    array(new 
Date(2008,4), 75284nullnull14334'Out of Stock''Ran out of stock on pens at 4pm'),
    array(new 
Date(2008,5), 41476'Bought Pens''Bought 200k pens'66467nullnull),
    array(new 
Date(2008,6), 33322nullnull39463nullnull)
);

# chart option definition
$timelineOptions google::options()->AnnotatedTimeline;
$timelineOptions->displayAnnotations true;


# html definition
$html E("html");
$head $html->head();
$body $html->body();
$div $body->toBody("div", array("id"=>"chart"));
$div->css(array("width"=>"800px""height"=>"400px"));

# chart definition
$f func()->name("drawTable");

$head->script()->addAttribute("src""//www.google.com/jsapi");
$head->script()->add(google(true)->load("visualization""1"obj(array("packages"=>array('annotatedtimeline')))));
$head->script()->add($f)->linebreak()->add(google(true)->setOnLoadCallback($f->getVar("drawTable")->getVar()));

$data google()->visualization->DataTable()->createVar("data"true);
stack()->add($data);

    
stack()->addgoogle(true$data->getVar())->addColumn("date""Date") );
    
stack()->addgoogle(true$data->getVar())->addColumn("number""Sold Pencils") );
    
stack()->addgoogle(true$data->getVar())->addColumn("string""title1") );
    
stack()->addgoogle(true$data->getVar())->addColumn("string""text1") );
    
stack()->addgoogle(true$data->getVar())->addColumn("number""Sold Pens") );
    
stack()->addgoogle(true$data->getVar())->addColumn("string""title2") );
    
stack()->addgoogle(true$data->getVar())->addColumn("string""text2") );
    
    
stack()->addgoogle(true$data->getVar())->addRows($results));

    
$timeline google()->visualization->AnnotatedTimeLine(document()->getElementById("chart"))->createVar("annotatedtimeline"true);
    
stack()->add$timeline );
    
stack()->addgoogle(true$timeline->getVar())->draw($data->getVar(), $timelineOptions) );
    
$f->add(stack());
    

echo 
$html;