98 |
- |
1 |
<?php
|
|
|
2 |
# PHPlot / contrib / prune_labels : Example
|
|
|
3 |
# $Id: prune_labels.example.php 453 2009-12-09 03:45:53Z lbayuk $
|
|
|
4 |
# This produces 250 data points with date-formatted labels, and sets
|
|
|
5 |
# a max of 20 labels to display.
|
|
|
6 |
|
|
|
7 |
require_once 'phplot.php';
|
|
|
8 |
require_once 'prune_labels.php';
|
|
|
9 |
|
|
|
10 |
$base = mktime(12, 0, 0, 1, 1, 2000);
|
|
|
11 |
$data = array();
|
|
|
12 |
for ($i = 0; $i < 250; $i++) {
|
|
|
13 |
$data[] = array(86400 * $i + $base, $i, $i * 0.20);
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
# Show no more than 20 labels:
|
|
|
17 |
prune_labels($data, 20);
|
|
|
18 |
|
|
|
19 |
$p = new PHPlot(800, 600);
|
|
|
20 |
$p->SetTitle('Example - pruned data labels');
|
|
|
21 |
$p->SetDataType('data-data');
|
|
|
22 |
$p->SetDataValues($data);
|
|
|
23 |
$p->SetXLabelType('time', '%Y-%m-%d');
|
|
|
24 |
$p->SetXLabelAngle(90);
|
|
|
25 |
$p->SetXDataLabelPos('plotdown');
|
|
|
26 |
$p->SetXTickLabelPos('none');
|
|
|
27 |
$p->SetXTickPos('none');
|
|
|
28 |
$p->SetDrawXGrid(False);
|
|
|
29 |
$p->SetDrawYGrid(False);
|
|
|
30 |
$p->SetPlotType('lines');
|
|
|
31 |
$p->DrawGraph();
|