table_iconex1.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65

    <?php // content="text/plain; charset=utf-8"
    require_once 'jpgraph/jpgraph.php';
    require_once 'jpgraph/jpgraph_canvas.php';
    require_once 'jpgraph/jpgraph_table.php';
    require_once 'jpgraph/jpgraph_iconplot.php';
    require_once 'jpgraph/jpgraph_flags.php';

    // Create a canvas graph where the table can be added
    $graph = new CanvasGraph(700,300);

    // Setup the basic table
    $data = array(
        array('',        'April', 'May','June','July','August'),
        array('',        'Triumph', 'Triump','Triumph','Triumph','Triumph'),
        array('2005',7,13,17,15,8),
        array('2006',7,34,35,26,20),
        array('2007',7,41,43,49,45),
        array('Sum:',21,88,95,90,73)
        );

    // Setup the basic table and default font
    $table = new GTextTable();
    $table->Set($data);
    $table->SetFont(FF_TIMES,FS_NORMAL,11);

    // Setup default horizontal ad vertical alignment
    $table->SetAlign('left','top');

    // Header row
    $table->SetRowFont(0,FF_ARIAL,FS_BOLD,12);
    $table->SetRowColor(0,'white');
    $table->SetRowAlign(0,'center');
    $table->SetRowFillColor(0,'darkorange');

    // Set text color
    $table->SetRowFont(1,FF_ARIAL,FS_BOLD,12);
    $table->SetRowColor(1,'white');

    //Set summary row format
    $table->SetRowFont(5,FF_ARIAL,FS_BOLD,12);

    // Setup overall grid
    $table->SetGrid(1);

    ///$table->SetRowFillColor(4,'lightgray@0.5');
    $table->SetColFillColor(0,'lightgray@0.5');
    $table->SetFillColor(0,0,4,0,'lightgray@0.5');

    // Setup column = 2 minimum width to 100 pixels regardeless of content
    $table->SetMinColWidth(2,100);

    // Add images of motorcycles to the top row
    $table->SetRowAlign(1,'center','top');
    for( $i=1; $i <= 5; ++$i ) {
        $table->SetCellImage(1,$i,"tr$i.jpg");
        $table->SetCellImageConstrain(1,$i,TIMG_HEIGHT,80);
    }

    // Add table to the graph
    $graph->Add($table);

    // send it back to the client
    $graph->Stroke();

    ?>