Esempio n. 1
0
function plotGraph($data)
{
    //Define the object
    $plot = new PHPlot();
    $example_data = $data;
    $plot->SetDataValues($example_data);
    $plot->SetDataType('data-data');
    //Set titles
    $plot->SetTitle("temp and humi");
    $plot->SetXTitle('time');
    $plot->SetYTitle('Y Data');
    $legend = array('temp', 'humi');
    $plot->SetLegend($legend);
    $plot->SetXDataLabelAngle(90);
    //$plot->SetXGridLabelType("time");
    $plot->SetXTickLabelPos('xaxis');
    $plot->SetXTickPos('plotdown');
    $plot->SetXLabelType('time', '%H:%M');
    $plot->TuneXAutoTicks(10, 'date');
    //	$plot->SetXTickIncrement(.5);
    //$plot->SetXTickIncrement(60 * 24);
    $plot->SetPlotType('lines');
    //$plot->SetPlotAreaWorld(strtotime('00:00'), null, strtotime('23:59'), null);
    $plot->SetDrawXGrid(true);
    //Draw it
    $plot->DrawGraph();
}
Esempio n. 2
0
<?php

include "./data_date2.php";
include "../phplot.php";
$graph = new PHPlot(600, 400);
$graph->SetPrintImage(0);
//Don't draw the image yet
$graph->SetDataType("data-data-error");
//Must be called before SetDataValues
$graph->SetNewPlotAreaPixels(90, 40, 540, 190);
$graph->SetDataValues($example_data);
$graph->SetXGridLabelType("time");
$graph->SetXDataLabelAngle(90);
$graph->SetXLabel("");
$graph->SetYLabel("Price");
$graph->SetVertTickIncrement(20);
$graph->SetHorizTickIncrement(2679000);
$graph->SetXTimeFormat("%b %y");
$graph->SetPlotType("lines");
$graph->SetErrorBarShape("line");
$graph->SetPointShape("halfline");
$graph->SetYScaleType("log");
$graph->SetLineWidth(1);
$graph->SetPlotAreaWorld(883634400, 1, 915095000, 140);
$graph->DrawGraph();
//Now do the second chart on the image
unset($example_data);
$graph->SetPrintImage(1);
//Now draw the image
$graph->SetYScaleType("linear");
include "./data_date.php";
Esempio n. 3
0
$plot->SetImageBorderType('plain');
// For presentation in the manual
$plot->SetTitle('Hourly Data Example Plot');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('lines');
# Make the X tick marks (and therefore X grid lines) 24 hours apart:
$plot->SetXTickIncrement(60 * 60 * 24);
$plot->SetDrawXGrid(True);
# Anchor the X tick marks at midnight. This makes the X grid lines act as
# separators between days of the week, regardless of the starting hour.
# (Except this messes up around daylight saving time changes.)
$plot->SetXTickAnchor($tick_anchor);
# We want both X axis data labels and X tick labels displayed. They will
# be positioned in a way that prevents them from overwriting.
$plot->SetXDataLabelPos('plotdown');
$plot->SetXTickLabelPos('plotdown');
# Increase the left and right margins to leave room for weekday labels.
$plot->SetMarginsPixels(50, 50);
# Tick labels will be formatted as date/times, showing the date:
$plot->SetXLabelType('time', '%Y-%m-%d');
# ... but then we must reset the data label formatting to no formatting.
$plot->SetXDataLabelType('');
# Show tick labels (with dates) at 90 degrees, to fit between the data labels.
$plot->SetXLabelAngle(90);
# ... but then we must reset the data labels to 0 degrees.
$plot->SetXDataLabelAngle(0);
# Force the Y range to 0:100.
$plot->SetPlotAreaWorld(NULL, 0, NULL, 100);
# Now draw the graph:
$plot->DrawGraph();
Esempio n. 4
0
function guifi_stats_chart07()
{
    include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php';
    $gDirTTFfonts = drupal_get_path('module', 'guifi') . '/contrib/fonts/';
    if (isset($_GET['width'])) {
        $gwidth = $_GET['width'];
    } else {
        $gwidth = 500;
    }
    if (isset($_GET['height'])) {
        $gheight = $_GET['height'];
    } else {
        $gheight = 450;
    }
    $today = getdate();
    $year = $today[year];
    $month = $today[mon];
    $month = $month - 12;
    $n = 0;
    $tot = 0;
    if ($month < 1) {
        $year = $year - 1;
        $month = 12 + $month;
    }
    $datemin = mktime(0, 0, 0, $month, 1, $year);
    if (isset($_GET['zone'])) {
        $zone_id = $_GET['zone'];
        if ($zone_id == "0") {
            $zone_id = "0";
        }
        //"3671";
    } else {
        $zone_id = "0";
    }
    $avalue = array();
    $adata = array();
    for ($i = 0; $i < 10; $i++) {
        $adata[] = array(0, 0);
    }
    $vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n      from {guifi_location}\n      where status_flag='Working' ";
    if ($zone_id != "0") {
        $achilds = guifi_zone_childs($zone_id);
        $v = "";
        foreach ($achilds as $key => $child) {
            if ($v == "") {
                $v .= "zone_id=" . $child;
            } else {
                $v .= " or zone_id=" . $child;
            }
        }
        $vsql .= "AND (" . $v . ") ";
    }
    $vsql .= "GROUP BY zone_id ";
    $result = db_query($vsql);
    while ($record = db_fetch_object($result)) {
        if ($record->total >= 20) {
            $vn = $record->num / $record->total * 100;
            $vmin = 0;
            for ($i = 1; $i < 10; $i++) {
                if ($adata[$vmin][1] > $adata[$i][1]) {
                    $vmin = $i;
                }
            }
            if ($vn > $adata[$vmin][1]) {
                $adata[$vmin][0] = $record->zone_id;
                $adata[$vmin][1] = $vn;
            }
        }
    }
    for ($i = 0; $i < 10; $i++) {
        if ($adata[$i][1] != 0) {
            $avalue[$adata[$i][0]] = $adata[$i][1];
        }
    }
    arsort($avalue);
    foreach ($avalue as $key => $value) {
        if ($value != 0) {
            $data[] = array(substr(guifi_get_zone_name($key), 0, 20) . "  �", $value);
        }
    }
    $shapes = array('none');
    $plot = new PHPlot($gwidth, $gheight);
    $plot->SetPlotAreaWorld(0, 0, NULL, NULL);
    $plot->SetFileFormat('png');
    $plot->SetDataType("text-data");
    $plot->SetDataValues($data);
    $plot->SetPlotType("bars");
    $plot->SetXTickIncrement(1);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetTickLength(0);
    //$plot->SetXTickPos('none');
    $plot->SetYDataLabelPos('plotin');
    $plot->SetYLabelType('data', 0);
    $plot->SetTickColor('grey');
    $plot->SetTTFPath($gDirTTFfonts);
    $plot->SetFontTTF('title', 'Vera.ttf', 12);
    $plot->SetFontTTF('x_label', 'Vera.ttf', 8);
    if (isset($_GET['title'])) {
        $plot->SetTitle("guifi.net      \n" . t($_GET['title']));
    } else {
        if ($zone_id == "0") {
            $plot->SetTitle("guifi.net      \n" . t('Largest annual increase'));
        } else {
            $plot->SetTitle("guifi.net    " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Largest annual increase'));
        }
    }
    //$plot->SetXTitle(t('Zones'));
    $plot->SetYTitle(t('% increase'));
    $plot->SetXDataLabelPos('plotdown');
    //$plot->SetXLabelAngle(45);
    $plot->SetXDataLabelAngle(75);
    $plot->SetGridColor('red');
    $plot->SetPlotBorderType('left');
    $plot->SetDataColors(array('orange'));
    $plot->SetTextColor('DimGrey');
    $plot->SetTitleColor('DimGrey');
    $plot->SetLightGridColor('grey');
    $plot->SetBackgroundColor('white');
    $plot->SetTransparentColor('white');
    $plot->SetIsInline(TRUE);
    $plot->DrawGraph();
}
Esempio n. 5
0
<?php

# $Id$
# Testing phplot - OHLC - all up/down combos - candlesticks
if (empty($plot_type)) {
    $plot_type = 'candlesticks';
}
require_once 'phplot.php';
/*
Testing all cases as follows. There are 16 combinations but 4 duplicates
L = Low, O = Open, C = Close, H = High.
              Data order:  Open, High, Low, Close
*/
$data = array(array('L < O < C < H', 2, 4, 1, 3), array('L < O < C = H', 2, 3, 1, 3), array('L < O = C < H', 2, 3, 1, 2), array('L < O = C = H', 2, 2, 1, 2), array('L = O < C < H', 1, 3, 1, 2), array('L = O < C = H', 1, 2, 1, 2), array('L = O = C < H', 1, 2, 1, 1), array('L = O = C = H', 1, 1, 1, 1), array('L < C < O < H', 3, 4, 1, 2), array('L < C < O = H', 3, 3, 1, 2), array('L < C = O < H', 2, 3, 1, 2), array('L < C = O = H', 2, 2, 1, 2), array('L = C < O < H', 2, 3, 1, 1), array('L = C < O = H', 2, 2, 1, 1), array('L = C = O < H', 1, 2, 1, 1), array('L = C = O = H', 1, 1, 1, 1));
$p = new PHPlot(800, 600);
$p->SetTitle("OHLC Plots, All Data Order Cases\nPlot type: {$plot_type}");
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotType($plot_type);
$p->SetXTickPos('none');
$p->SetXDataLabelAngle(90);
$p->SetPlotAreaWorld(NULL, 0, NULL, 5);
$p->SetDrawYGrid(False);
$p->SetLineWidths(array(2, 3));
$p->DrawGraph();
Esempio n. 6
0
    $data = $data1;
} elseif ($tp['datasign'] < 0) {
    $data = $data2;
} else {
    $data = array_merge($data1, $data2);
}
$p = new PHPlot(800, 800);
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetXTitle('This is the X Axis Title');
$p->SetYTitle('This is the Y Axis Title');
$p->SetDataValues($data);
$p->SetDataType('text-data-yx');
$p->SetPlotType('bars');
$p->SetXDataLabelPos('plotin');
if (isset($tp['shade'])) {
    $p->SetShading($tp['shade']);
}
if ($tp['ttf']) {
    $p->SetFontTTF('x_label', $phplot_test_ttfdir . $phplot_test_ttfonts['sans'], 10);
}
if ($tp['yaxis0']) {
    $p->SetYAxisPosition(0);
}
if (isset($tp['labelangle'])) {
    $p->SetXDataLabelAngle($tp['labelangle']);
}
if ($tp['labelformat']) {
    $p->SetXDataLabelType('data', 1, '', '%');
}
$p->SetYTickPos('none');
$p->DrawGraph();
Esempio n. 7
0
$p->SetXTickIncrement(1);
$p->SetYTickIncrement(10);
if ($enable_y_data_labels) {
    $p->SetYDataLabelPos('plotin');
}
$p->SetPlotAreaWorld(NULL, 0, NULL, 109);
# Use this TrueType font and make labels bigger:
$p->SetDefaultTTFont($phplot_test_ttfdir . $phplot_test_ttfonts['sans']);
$p->SetFont('x_label', '', 10);
$p->SetFont('y_label', '', 10);
# Options: X
if (isset($tp['x_angle'])) {
    $p->SetXLabelAngle($tp['x_angle']);
}
if (isset($tp['xd_angle'])) {
    $p->SetXDataLabelAngle($tp['xd_angle']);
}
if (isset($tp['x_type'])) {
    $p->SetXLabelType($tp['x_type'], $tp['x_type_arg']);
}
if (isset($tp['xd_type'])) {
    $p->SetXDataLabelType($tp['xd_type'], $tp['xd_type_arg']);
}
if (isset($tp['xt_pos'])) {
    $p->SetXTickLabelPos($tp['xt_pos']);
}
if (isset($tp['xd_pos'])) {
    $p->SetXDataLabelPos($tp['xd_pos']);
}
# Options: Y
if (isset($tp['y_angle'])) {