Exemplo n.º 1
0
    function test_LineChart()
    {
        $lineChart = new gLineChart(300, 300);
        $lineChart->addDataSet(array(112, 315, 66, 40));
        $lineChart->addDataSet(array(212, 115, 366, 140));
        $lineChart->addDataSet(array(112, 95, 116, 140));
        $lineChart->setLegend(array("first", "second", "third", "fourth"));
        $lineChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));
        $lineChart->setVisibleAxes(array('x', 'y'));
        $lineChart->setDataRange(30, 400);
        $lineChart->addAxisRange(0, 1, 4, 1);
        $lineChart->addAxisRange(1, 30, 400);
        $lineChart->addBackgroundFill('bg', 'EFEFEF');
        $lineChart->addBackgroundFill('c', '000000');
        $text = <<<END
newLineChart: 300,300
addDataSet: 112,315,66,40
addDataSet: 212,115,366,140
addDataSet: 112,95,116,140
setLegend: first, second, third, fourth
setColors: ff3344, 11ff11, 22aacc, 3333aa
setVisibleAxes: x, y
setDataRange: 30, 400
addAxisRange: 0, 1, 4, 1
addAxisRange: 1, 30, 400
addBackgroundFill: bg, EFEFEF
addBackgroundFill: c, 000000
END;
        $parser = new gChartPhpDSLParser();
        $parser->parse($text);
        $this->assertEqual($lineChart->getUrl(), $parser->getUrl());
    }
Exemplo n.º 2
0
$CPChart->addLegend(array('1a', '2a', '3a', '4a'));<br>
</code>
</p>
<h2>Line Chart</h2>
<?php 
$lineChart = new gLineChart(300, 300);
$lineChart->addDataSet(array(112, 315, 66, 40));
$lineChart->addDataSet(array(212, 115, 366, 140));
$lineChart->addDataSet(array(112, 95, 116, 140));
$lineChart->setLegend(array("first", "second", "third", "fourth"));
$lineChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));
$lineChart->setVisibleAxes(array('x', 'y'));
$lineChart->setDataRange(30, 400);
$lineChart->addAxisRange(0, 1, 4, 1);
$lineChart->addAxisRange(1, 30, 400);
$lineChart->addBackgroundFill('bg', 'EFEFEF');
$lineChart->addBackgroundFill('c', '000000');
?>
<img src="<?php 
print $lineChart->getUrl();
?>
" /> <br> line chart using the gLineChart class.
<p>
<em>code:</em><br>
<code>
$lineChart = new gLineChart(300,300);<br>
$lineChart->addDataSet(array(112,315,66,40));<br>
$lineChart->addDataSet(array(212,115,366,140));<br>
$lineChart->addDataSet(array(112,95,116,140));<br>
$lineChart->setLegend(array("first", "second", "third","fourth"));<br>
$lineChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));<br>
Exemplo n.º 3
0
 public static function build_pireptable($pilotid, $days = '30', $color = '000000', $background = 'EFEFEF', $width = '950', $height = '260')
 {
     #make sure $days is even - if not add 1
     if ($days & 1) {
         $days++;
     }
     $output = array();
     #set current date
     $month = date("m");
     $day = date("d");
     $year = date("Y");
     #set todays date
     $output[] = date('m-d', mktime(0, 0, 0, $month, $day, $year));
     #loop through days
     for ($i = 1; $i <= $days - 1; $i++) {
         $output[] = date('m-d', mktime(0, 0, 0, $month, $day - $i, $year));
     }
     #reverse the days for chart
     $output = array_reverse($output);
     #set baseline values
     $labels = array();
     $points = array();
     $xTotal = 0;
     $yTotal = 0;
     $dataPoint = array();
     $data = PIREPData::getIntervalDataByDays(array('p.pilotid' => $pilotid), $days);
     if ($data) {
         foreach ($data as $dat) {
             $points[] = $dat->total;
             #get highest y-axis value for chart
             if ($dat->total > $total) {
                 $yTotal = $dat->total;
             }
             $date = '';
             $date = explode('-', $dat->ym);
             $labels[] = $date[1] . '-' . $date[2];
             $xTotal++;
             $z = new stdClass();
             $z->label = $date[1] . '-' . $date[2];
             $z->point = $dat->total;
             $dataPoint[] = $z;
         }
     }
     $fLabels = array();
     $fPoints = array();
     $arraySpot = '0';
     foreach ($output as $num => $point) {
         #display every x-axis label on charts 10 days or less
         if ($days < 11) {
             if (in_array($point, $labels)) {
                 $fLabels[] = $dataPoint[$arraySpot]->label;
                 $fPoints[] = $dataPoint[$arraySpot]->point;
                 $arraySpot++;
             } else {
                 $fLabels[] = $point;
                 $fPoints[] = '0';
             }
         } else {
             if (in_array($point, $labels)) {
                 if ($num & 1) {
                     $fLabels[] = $dataPoint[$arraySpot]->label;
                 } else {
                     $fLabels[] = '';
                 }
                 $fPoints[] = $dataPoint[$arraySpot]->point;
                 $arraySpot++;
             } else {
                 if ($num & 1) {
                     $fLabels[] = $point;
                 } else {
                     $fLabels[] = '';
                 }
                 $fPoints[] = '0';
             }
         }
     }
     #build chart params
     $lineChart = new gLineChart($width, $height);
     $lineChart->addDataSet($fPoints);
     $lineChart->setColors(array($color));
     $lineChart->setVisibleAxes(array('x', 'y'));
     $lineChart->setDataRange(0, $yTotal + 1);
     $lineChart->addAxisRange(0, 1, $days, 1);
     $lineChart->addAxisRange(1, 0, $yTotal + 1, 1);
     $lineChart->setlineMarkers('6');
     $lineChart->setlineWidth('1');
     $lineChart->setaxisStyle('0', $color, '10');
     $lineChart->addAxisLabel(0, $fLabels);
     $lineChart->setGridLines(100 / 29, 100 / ($yTotal + 1), 4, 2, 0, 0);
     $lineChart->setTitle("Last " . $days . " Days PIREPS");
     $lineChart->setTitleOptions($color, '18');
     $lineChart->setChartMargins(array(20, 20, 20, 20));
     $lineChart->addBackgroundFill('bg', $background);
     return $lineChart->getUrl();
 }