Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 - 1
<?php
2
# $Id: data_table.example3.php 999 2011-08-05 19:00:48Z lbayuk $
3
# phplot / contrib / data_table example 3:  Pie chart with data table
4
require_once 'phplot.php';
5
require_once 'data_table.php';
6
 
7
// Note column 0, labels, are not used by PHPlot itself, but are
8
// displayed in the data table, and extracted for the legend.
9
$data = array(
10
   array('Gold', 20),
11
   array('Silver', 40),
12
   array('Platinum', 30),
13
   array('Tin', 70),
14
);
15
 
16
// The $settings array configures the data table:
17
// Width and height are auto-calculated, and position defaults to 0,0.
18
$settings = array(
19
    'headers' => array('Metal', 'Amount'),
20
    'data' => $data,
21
);
22
 
23
$plot = new PHPlot(600, 400);
24
$plot->SetTitle('Pie Chart with Legend and Data Table');
25
$plot->SetDataValues($data);
26
$plot->SetDataType('text-data-single');
27
$plot->SetPlotType('pie');
28
foreach ($data as $row) $plot->SetLegend($row[0]);
29
$plot->SetCallback('draw_graph', 'draw_data_table', $settings);
30
$plot->DrawGraph();