$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("Company A", "Serie1");
$DataSet->SetSerieName("Company B", "Serie2");
$DataSet->SetYAxisName("Product sales");
$DataSet->SetYAxisUnit("k");
$DataSet->SetSerieSymbol("Serie1", "Sample/Point_Asterisk.gif");
$DataSet->SetSerieSymbol("Serie2", "Sample/Point_Cd.gif");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(65, 30, 650, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the title
$Test->setFontProperties("Fonts/pf_arma_five.ttf", 6);
$Title = "Comparative product sales for company A & B  ";
$Test->drawTextBox(65, 30, 650, 45, $Title, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Draw the legend
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(80, 60, $DataSet->GetDataDescription(), 255, 255, 255);
// Render the chart
$Test->Render("example22.png");
Beispiel #2
0
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->setGraphArea(120, 20, 675, 190);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Draw the title
$Title = "  Average Temperatures during\r\n  the first months of 2008  ";
$Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
// Draw the legend
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
// Render the picture
$Test->addBorder(2);
$Test->Render("example23.png");
Beispiel #3
0
 /**
  * Based on Example24.php
  */
 public function testXYChart()
 {
     // Dataset definition
     $DataSet = new pData();
     // Compute the points
     for ($i = 0; $i <= 360; $i = $i + 10) {
         $DataSet->addPoint(cos($i * 3.14 / 180) * 80 + $i, "Serie1");
         $DataSet->addPoint(sin($i * 3.14 / 180) * 80 + $i, "Serie2");
     }
     $DataSet->setSeriesName("Trigonometric function", "Serie1");
     $DataSet->addSeries("Serie1");
     $DataSet->addSeries("Serie2");
     $DataSet->SetXAxisName("X Axis");
     $DataSet->SetYAxisName("Y Axis");
     // Initialise the graph
     $canvas = new TestCanvas();
     $Test = new pChart(300, 300, $canvas);
     $Test->drawBackgroundGradient(new Color(0), -100);
     // Prepare the graph area
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(55, 30, 270, 230);
     $scaleStyle = new ScaleStyle(SCALE_NORMAL, new Color(213, 217, 221));
     $Test->drawXYScale($DataSet, $scaleStyle, "Serie1", "Serie2", 45);
     $backgroundStyle = new BackgroundStyle(new Color(213, 217, 221), FALSE, new Color(30), -50);
     $Test->drawGraphBackground($backgroundStyle);
     $Test->drawGrid(new GridStyle(4, TRUE, new Color(230), 20));
     // Draw the chart
     $Test->setShadowProperties(2, 2, new Color(0), 60, 4);
     $Test->drawXYGraph($DataSet->GetData(), "Serie1", "Serie2", 0);
     $Test->clearShadow();
     // Draw the title
     $Title = "Drawing X versus Y charts trigonometric functions  ";
     $Test->drawTextBox(new Point(0, 280), new Point(300, 300), $Title, 0, new Color(255), ALIGN_RIGHT, ShadowProperties::FromSettings(1, 1, new Color(0), 100, 0), new Color(0), 30);
     // Draw the legend
     $Test->setFontProperties("Fonts/pf_arma_five.ttf", 6);
     $DataSet->removeSeries("Serie2");
     $Test->drawLegend(160, 5, $DataSet->GetDataDescription(), new Color(0), new Color(0), new Color(255), FALSE);
     file_put_contents(dirname(__FILE__) . '/action_logs/testXYChart', $canvas->getActionLog());
     $this->assertEquals('3c45517b3d9549198ffffaac276ad353', md5($canvas->getActionLog()));
 }
 $DataSet->SetSerieName("Control ({$minquoteamtinmonth})", "Serie2");
 $DataSet->SetYAxisName("Amount({$defcurrencycode})");
 // $DataSet->SetYAxisUnit("RM");
 $Test = new pChart(600, 230);
 $Test->setFontProperties("../simantz/class/pchart/Fonts/tahoma.ttf", 8);
 $Test->setGraphArea(65, 30, 550, 200);
 $Test->drawFilledRoundedRectangle(7, 7, 593, 223, 5, 240, 240, 240);
 $Test->drawRoundedRectangle(5, 5, 595, 225, 5, 230, 230, 230);
 $Test->drawGraphArea(255, 255, 255, TRUE);
 $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
 $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
 $Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1");
 // Draw the title
 $Test->setFontProperties("../simantz/class/pchart/Fonts/pf_arma_five.ttf", 8);
 $Title = "QUotation Amount Vs Time For {$defaultorganization_name}";
 $Test->drawTextBox(65, 10, 550, 25, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30);
 // Draw the line graph
 $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
 $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 254, 254, 254);
 // Draw the legend
 $Test->setFontProperties("../simantz/class/pchart/Fonts/tahoma.ttf", 8);
 $Test->drawLegend(10, 150, $DataSet->GetDataDescription(), 254, 254, 254);
 // Render the chart
 $photofile = $uploadpath . "chartsalequoteamt_6month.png";
 $Test->Render($photofile);
 //	$chart->setTitle("Sales Vs Expenses For $defaultorganization_name");
 //	$chart->getPlot()->setGraphCaptionRatio(0.62);
 //	$chart->render("chart/generated/salesexpenses_6month.png");
 if ($action != "create") {
     header('Content-type: image/png');
     //$photofile="chartcache/chart0.png>";
     $DataSet->SetSerieName($currentseriesname, "Serie" . $z);
 }
 // $DataSet->SetSerieName("Expenses","Serie2");
 $DataSet->SetYAxisName("Amount({$defcurrencycode})");
 $Test = new pChart(800, 330);
 $Test->setFontProperties("../system/class/pchart/Fonts/tahoma.ttf", 8);
 $Test->setGraphArea(65, 30, 650, 300);
 $Test->drawFilledRoundedRectangle(7, 7, 793, 325, 5, 254, 254, 254);
 $Test->drawRoundedRectangle(5, 5, 794, 325, 5, 254, 10, 10);
 $Test->drawGraphArea(254, 254, 254, TRUE);
 $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
 $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
 // Draw the title
 $Test->setFontProperties("../system/class/pchart/Fonts/pf_arma_five.ttf", 10);
 $Title = "Chart Generator From Balance Sheet({$defaultorganization_name})";
 $Test->drawTextBox(65, 12, 650, 25, $Title, 0, 0, 0, 1, ALIGN_CENTER, FALSE, 254, 254, 254, 30);
 // Draw the line graph
 $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
 $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 254, 254, 254);
 // Draw the legend
 $Test->setFontProperties("../system/class/pchart/Fonts/tahoma.ttf", 8);
 $Test->drawLegend(655, 20, $DataSet->GetDataDescription(), 254, 254, 254);
 // Render the chart
 $random = rand();
 $photofile = "chartcache/balancesheetchartgenerated{$random}.png";
 $Test->Render($photofile);
 echo $photofile;
 /*
 echo <<< EOF
 start
 <script type="text/javascript">
for ($i = 0; $i <= 360; $i = $i + 10) {
    $DataSet->AddPoint(cos($i * 3.14 / 180) * 80 + $i, "Serie1");
    $DataSet->AddPoint(sin($i * 3.14 / 180) * 80 + $i, "Serie2");
}
$DataSet->SetSerieName("Trigonometric function", "Serie1");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetXAxisName("X Axis");
$DataSet->SetYAxisName("Y Axis");
// Initialise the graph
$Test = new pChart(300, 300);
$Test->drawGraphAreaGradient(0, 0, 0, -100, TARGET_BACKGROUND);
// Prepare the graph area
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(55, 30, 270, 230);
$Test->drawXYScale($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1", "Serie2", 213, 217, 221, TRUE, 45);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawGraphAreaGradient(30, 30, 30, -50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the chart
$Test->setShadowProperties(2, 2, 0, 0, 0, 60, 4);
$Test->drawXYGraph($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1", "Serie2", 0);
$Test->clearShadow();
// Draw the title
$Title = "Drawing X versus Y charts trigonometric functions  ";
$Test->drawTextBox(0, 280, 300, 300, $Title, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
// Draw the legend
$Test->setFontProperties("Fonts/pf_arma_five.ttf", 6);
$DataSet->RemoveSerie("Serie2");
$Test->drawLegend(160, 5, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 255, 255, 255, FALSE);
$Test->Stroke("example24.png");
Beispiel #7
0
} elseif ($objtype == "pict1c") {
    // Settings
    $wid = 60;
    $hei = 60;
    // light/black
    if ($black == 1) {
        $cbg = 0;
    } else {
        $cbg = 255;
    }
    // Object + GraphArea
    $Test = new pChart($wid, $hei);
    $Test->setGraphArea(0, 0, $wid, $hei);
    // Background
    $Test->drawBackground($cbg, $cbg, $cbg);
    // Draw body
    $Test->drawFilledRoundedRectangle(0, 0, 60, 60, 8, $caR, $caG, $caB);
    // body
    // Draw label
    $Test->setFontProperties("./pChart/Fonts/pictogramz.ttf", 44);
    $Test->drawTextBox(10, 20, 50, 40, "O", 0, 250, 250, 250, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    // end of pict1c
    //---------------------------- Error mess object
} else {
}
// end of ($objtype == "...")
//---------------------------- Final
Header("Content-type:image/png");
imagepng($Test->Picture);
$db->Disconnect();
// closing database connection
function grafico($dados, $eixo, $cor1, $grafico, $situacao, $legenda)
{
    include_once "pChart/pChart/pData.class";
    include_once "pChart/pChart/pChart.class";
    $DataSet = new pData();
    $DataSet->AddPoint($dados, "Serie1");
    $DataSet->AddPoint($eixo, "Serie2");
    $DataSet->AddAllSeries();
    $DataSet->RemoveSerie("Serie2");
    $DataSet->SetAbsciseLabelSerie("Serie2");
    $DataSet->SetSerieName($legenda, "Serie1");
    $Test = new pChart(720, 430);
    $Test->drawGraphAreaGradient($cor1, 173, 131, 50, TARGET_BACKGROUND);
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 8);
    $Test->setGraphArea(50, 80, 675, 390);
    $Test->drawGraphArea(217, 217, 211, FALSE);
    $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
    $Test->drawGraphAreaGradient(163, 203, 167, 50);
    $Test->drawGrid(4, TRUE, 230, 230, 230, 20);
    $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
    $Title = "{$situacao}";
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 14);
    $Test->drawTextBox(0, 0, 700, 60, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 30, 0, 0, 30);
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 9);
    $Test->drawLegend(520, 70, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
    $Test->addBorder(2);
    $Test->Render("images/" . $grafico);
}
 $graph->drawGraphArea(250, 250, 250, true);
 $graph->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, true, 0, 0);
 // $graph->drawGrid(4, true, 230, 230, 230, 100);
 if ($plugin->getID() == GLOBAL_PLUGIN_ID) {
     $statement = get_slave_db_handle()->prepare('SELECT Sum(GlobalHits) FROM Plugin');
     $statement->execute();
     $serverStarts = $statement->fetch()[0];
     $serversLast24Hours = $plugin->countServersLastUpdated(time() - SECONDS_IN_DAY);
 } else {
     $serverStarts = $plugin->getGlobalHits();
     $serversLast24Hours = $plugin->countServersLastUpdated(time() - SECONDS_IN_DAY);
 }
 // Draw the footer
 $graph->setFontProperties('pf_arma_five.ttf', 6);
 $footer = sprintf('%s servers in the last 24 hours with %s all-time server startups  ', number_format($serversLast24Hours), number_format($serverStarts));
 $graph->drawTextBox(60, REAL_IMAGE_HEIGHT - 25, REAL_IMAGE_WIDTH - 20, REAL_IMAGE_HEIGHT - 7, $footer, 0, 255, 255, 255, ALIGN_RIGHT, true, 0, 0, 0, 30);
 // Draw the data
 $graph->drawFilledLineGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 75, true);
 // Draw legend
 $graph->drawLegend(65, 35, $dataSet->GetDataDescription(), 255, 255, 255);
 // Get the center of the image
 $authors = $plugin->getAuthors();
 if (!empty($authors)) {
     $title = $pluginName . ' - ' . $authors;
 } else {
     $title = $pluginName;
 }
 $tahoma = 'tahoma.ttf';
 $bounding_box = imagettfbbox(11, 0, $tahoma, $title);
 $center_x = ceil((REAL_IMAGE_WIDTH - $bounding_box[2]) / 2);
 // Draw the title there
        array_unshift($date, '');
    }
}
$cache_image = IMAGE_PATH . "/progress/trend_{$player}_{$last_time}.png";
if (file_exists($cache_image)) {
    header('Content-type: image/png');
    readfile($cache_image);
    exit;
}
$Chart = new pChart(400, 200);
$Chart->drawBackground($bg_color['red'], $bg_color['green'], $bg_color['blue']);
$Chart->setGraphArea(40, 28, 339, 174);
$Chart->drawGraphAreaGradient(40, 40, 40, -50);
if (count($date) < 2) {
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 11);
    $Chart->drawTextBox(100, 90, 180, 110, "Not Enough Session Data", 0, 0, 0, 0, ALIGN_LEFT, FALSE, 255, 255, 255, 0);
} else {
    $DataSet = new pData();
    $DataSet->AddPoint($skill, 'SerieSkill');
    $DataSet->AddPoint($skill_change, 'SerieSession');
    $DataSet->AddPoint($date, 'SerieDate');
    $DataSet->AddSerie('SerieSkill');
    $DataSet->SetAbsciseLabelSerie('SerieDate');
    $DataSet->SetSerieName('Skill', 'SerieSkill');
    $DataSet->SetSerieName('Session', 'SerieSession');
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 7);
    $DataSet->SetYAxisName('Skill');
    $DataSet->SetYAxisUnit('K');
    $Chart->setColorPalette(0, 255, 255, 0);
    $Chart->drawRightScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, $color['red'], $color['green'], $color['blue'], TRUE, 0, 0);
    $Chart->drawGrid(1, FALSE, 55, 55, 55, 100);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
//$Test->setGraphArea(65, 30, 570, 185);
//$Test->drawFilledRoundedRectangle(7, 7, 800, 223, 5, 240, 240, 240);
//$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
//$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, TRUE, 0, 2, TRUE, 1);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 0);
//$Test->drawGraphAreaGradient(162, 183, 202, 50);
$Test->drawGraphAreaGradient(40, 40, 40, -50);
//$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
$Test->drawGrid(4, TRUE, 230, 230, 230, 10);
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
//$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
// Draw the 0 line
$Test->setFontProperties("../Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
//$DataSet->RemoveSerie("Serie4");
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
//$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
// Finish the graph
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(590, 90, $DataSet->GetDataDescription(), 0, 255, 255);
$Test->setFontProperties("../Fonts/tahoma.ttf", 10);
// Draw the title
$Title = "Comparison of Household fuel usage in 2015";
$Test->drawTextBox(7, 225, 693, 245, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30);
//$Test->drawTitle(60,22,"Comparison Graph",50,50,50,585);
$Test->addBorder(0.5);
$Test->Render("clientsGraph.png");
Beispiel #12
0
 public function build()
 {
     require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pData.php';
     require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pChart.php';
     $dataSet = new pData();
     foreach ($this->lines as $name => $ordinateValues) {
         if (count($ordinateValues) != count($this->absciseValues)) {
             throw new Exception('Count of line "' . $name . '" ordinate points "' . count($ordinateValues) . '" mismatch to abscise points "' . count($this->absciseValues) . '"');
         }
         $dataSet->AddPoint($ordinateValues, $name);
     }
     $dataSet->AddPoint($this->absciseValues, 'Abscise');
     $dataSet->AddAllSeries();
     $dataSet->RemoveSerie('Abscise');
     $dataSet->SetAbsciseLabelSerie('Abscise');
     foreach ($this->lines as $name => $ordinateValues) {
         $dataSet->SetSerieName($name, $name);
     }
     $dataSet->SetYAxisUnit($this->ordinateStepTitle);
     $dataSet->SetXAxisUnit($this->absciseStepTitle);
     $chart = new pChart($this->maxWidth, $this->maxHeight);
     $chart->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
     // Graph area setup
     $chart->setFontProperties(PCHART_FONTS_DIR . DIRECTORY_SEPARATOR . 'tahoma.ttf', 10);
     $chart->setGraphArea($this->graphMargins[0], $this->graphMargins[1], $this->maxWidth - $this->graphMargins[2], $this->maxHeight - $this->graphMargins[3]);
     $chart->drawGraphArea(213, 217, 221, FALSE);
     $ordinateScaleMargin = ($this->getMaxOrdinateValue() - $this->getMinOrdinateValue()) / $this->ordinateDevisions;
     $chart->setFixedScale($this->getMinOrdinateValue() - $ordinateScaleMargin, $this->getMaxOrdinateValue() + $ordinateScaleMargin, $this->ordinateDevisions);
     $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2);
     $chart->drawGraphAreaGradient(162, 183, 202, 50);
     $chart->drawGrid(4, TRUE, 230, 230, 230, 20);
     // Draw the line chart
     //		$chart->setShadowProperties(1, 1, 0, 0, 0, 30, 4);
     $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
     $chart->clearShadow();
     $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 5, 3, -1, -1, -1, TRUE);
     // Draw the legend
     $chart->drawLegend($this->maxWidth - $this->graphMargins[2] + 10, $this->graphMargins[1], $dataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
     // Draw chart title
     if ($this->chartTitle) {
         $chart->drawTextBox(0, $this->maxHeight - 20, $this->maxWidth, $this->maxHeight, $this->chartTitle, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
     }
     // Render the picture
     $chart->addBorder(2);
     $chart->Render($this->outputFilepath);
 }
Beispiel #13
0
    $Test->drawFilledRectangle($d2onx, $s0Ymin, $d2offx, $s0Ymax, 240, 80, 80, FALSE, 100);
    $Test->drawFilledRectangle($d3onx, $s0Ymin, $d3offx, $s0Ymax, 240, 130, 50, FALSE, 100);
    $Test->drawFilledRectangle($d4onx, $s0Ymin, $d4offx, $s0Ymax, 240, 80, 80, FALSE, 100);
    $Test->drawFilledRectangle($d5onx, $s0Ymin, $d5offx, $s0Ymax, 240, 130, 50, FALSE, 100);
    $Test->drawFilledRectangle($d6onx, $s0Ymin, $d6offx - 3, $s0Ymax, 80, 220, 80, FALSE, 100);
    $Test->drawFilledRectangle($d1onx, $bodyYmin, $d1onx + 1, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($d2onx - 1, $bodyYmin, $d2onx, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($d3onx - 1, $bodyYmin, $d3onx, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($d4onx - 1, $bodyYmin, $d4onx, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($d5onx - 1, $bodyYmin, $d5onx, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($d6onx - 1, $bodyYmin, $d6onx, $bodyYmax, 160, 160, 160, FALSE, 100);
    $Test->drawFilledRectangle($bodyXmin + $ttx - 1, $bodyYmin + 3, $bodyXmin + $ttx + 1, $bodyYmax - 3, 220, 220, 220, FALSE, 100);
    $Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 8);
    $Test->drawTextBox($bodyXmin + $d1onx, $bodyYmax, $bodyXmin + $d1onx + 20, $bodyYmax + 18, "0:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    $Test->drawTextBox($bodyXmin + $d2onx - 5, $bodyYmax, $bodyXmin + $d2onx + 5, $bodyYmax + 18, "7:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    $Test->drawTextBox($bodyXmin + $d3onx - 5, $bodyYmax, $bodyXmin + $d3onx + 5, $bodyYmax + 18, "10:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    $Test->drawTextBox($bodyXmin + $d4onx - 5, $bodyYmax, $bodyXmin + $d4onx + 5, $bodyYmax + 18, "17:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    $Test->drawTextBox($bodyXmin + $d5onx - 5, $bodyYmax, $bodyXmin + $d5onx + 5, $bodyYmax + 18, "21:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    $Test->drawTextBox($bodyXmin + $d6onx - 5, $bodyYmax, $bodyXmin + $d6onx + 5, $bodyYmax + 18, "23:00", 0, 125, 125, 125, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
    //$Test->drawTextBox($bodyXmin+10,$bodyYmax+20,$bodyXmin+500,$bodyYmax+38,"",0,125,125,125,ALIGN_CENTER,FALSE,-1,-1,-1,100);
    //end of timeline1
    //======================================================== End ========================================================
    //---------------------------- Error mess object
} else {
}
// end of ($objtype == "...")
//---------------------------- Final
Header("Content-type:image/png");
imagepng($Test->Picture);
$db->Disconnect();
// closing database connection
Beispiel #14
0
 function cartesianChart($type, $x, $y, $w, $h, $imgname = '', $config = array())
 {
     $w -= 4;
     $h -= 4;
     $settings = array('FontName' => 'tahoma.ttf', 'FontSize' => 8, 'LegendFontSize' => 8, 'LegendFontName' => 'tahoma.ttf', 'Logo' => '', 'LogoTransparency' => 20, 'XAxisFormat' => 'number', 'XAxisUnit' => '', 'YAxisFormat' => 'number', 'YAxisUnit' => '', 'XLogo' => 0, 'YLogo' => 0, 'Xlabel' => 'x label', 'XAngle' => 0, 'Ylabel' => 'y label', 'Legend' => '', 'Textbox' => '', 'TextboxFontSize' => 8, 'TextboxFontName' => 'tahoma.ttf', 'ImgR' => 132, 'ImgG' => 173, 'ImgB' => 131, 'Decay' => 80, 'BGR' => 163, 'BGG' => 203, 'BGB' => 167, 'Decay2' => 80, 'Filled' => '', 'DataR' => 191, 'DataG' => 120, 'DataB' => 71, 'LBR' => 226, 'LBG' => 228, 'LBB' => 230, 'LR' => 0, 'LG' => 0, 'LB' => 0);
     // Get the custom settings
     if (is_array($config)) {
         foreach ($config as $key => $val) {
             $settings[$key] = $val;
         }
     }
     $DataSet = new pData();
     $DataSet->AddPoint($y, "Serie1");
     $DataSet->AddPoint($x, "Serie2");
     $DataSet->AddAllSeries();
     $DataSet->RemoveSerie("Serie2");
     $DataSet->SetAbsciseLabelSerie("Serie2");
     $DataSet->SetSerieName($settings['Legend'], "Serie1");
     $DataSet->SetYAxisName($settings['Ylabel']);
     $DataSet->SetXAxisName($settings['Xlabel']);
     $DataSet->SetXAxisFormat($settings['XAxisFormat']);
     if (strlen($settings['XAxisUnit'])) {
         $DataSet->SetXAxisUnit($settings['XAxisUnit']);
     }
     if (strlen($settings['YAxisUnit'])) {
         $DataSet->SetYAxisUnit($settings['YAxisUnit']);
     }
     $DataSet->SetYAxisFormat($settings['YAxisFormat']);
     // Initialise the graph
     $Test = new pChart($w, $h);
     $Test->drawGraphAreaGradient($settings['ImgR'], $settings['ImgG'], $settings['ImgB'], $settings['Decay'], TARGET_BACKGROUND);
     $FontSize = $settings['FontSize'];
     $FontName = $this->_ext_path . "/fonts/" . $settings['FontName'];
     $Test->setFontProperties($FontName, $FontSize);
     //Calc Textbox Height
     if (strlen($settings['Textbox'])) {
         $TextboxFontSize = $settings['TextboxFontSize'];
         $TextboxFontName = $this->_ext_path . "/fonts/" . $settings['TextboxFontName'];
         $Position = imageftbbox($TextboxFontSize, 0, $TextboxFontName, $settings['Textbox']);
         $TextboxHeight = $Position[1] - $Position[7] + 8;
     } else {
         $TextboxHeight = 0;
     }
     // Maximize The graph area
     //on Y axis
     if ($settings['XAxisFormat'] == 'time') {
         $xdata = "99:99:99";
         $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
         $WXmax = $Position[2] - $Position[0];
         $TextHeightX = $Position[1] - $Position[7];
     } elseif ($settings['XAxisFormat'] == 'date') {
         $xdata = "99/99/9999";
         $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
         $WXmax = $Position[2] - $Position[0];
         $TextHeightX = $Position[1] - $Position[7];
     } else {
         $WXmax = 0;
         foreach ($x as $xdata) {
             $xdata .= $settings['XAxisUnit'];
             $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
             $TextWidth = $Position[2] - $Position[0];
             $TextHeightX = $Position[1] - $Position[7];
             $WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax;
         }
     }
     if ($settings['XAngle'] > 0) {
         $sin = abs(sin(deg2rad($settings['XAngle'])));
         $cos = abs(cos(deg2rad($settings['XAngle'])));
         $HXmax = $WXmax * $sin + $TextHeightX * $cos;
     } else {
         $HXmax = $TextHeightX;
     }
     //on Y axis...
     if ($settings['YAxisFormat'] == 'time') {
         $ydata = "99:99:99";
         $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
         $WYmax = $Position[2] - $Position[0];
         $TextHeightY = $Position[1] - $Position[7];
     } elseif ($settings['YAxisFormat'] == 'date') {
         $ydata = "99/99/9999";
         $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
         $WYmax = $Position[2] - $Position[0];
         $TextHeightY = $Position[1] - $Position[7];
     } else {
         $WYmax = 0;
         foreach ($y as $ydata) {
             $ydata .= $settings['YAxisUnit'];
             //echo $ydata."<br>";
             $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
             $TextWidth = $Position[2] - $Position[0];
             $TextHeightY = $Position[1] - $Position[7];
             $WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax;
         }
     }
     $Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20);
     //$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100);
     $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE);
     $Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']);
     $Test->drawGrid(4, TRUE, 230, 230, 230, 20);
     // This will put the picture "logo.png" with transparency
     if (strlen($settings['Logo'])) {
         $XLogo = $WYmax + $TextHeightY + 35 + $settings['XLogo'];
         $YLogo = 20 + $settings['XLogo'];
         $logo = $settings['Logo'];
         //Fing extension of logo : png,gif or jpg
         if ($this->_findexts($logo) == "png") {
             echo "png!";
             $Test->drawFromPNG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         } elseif ($this->_findexts($logo) == "gif") {
             echo "gif!";
             $Test->drawFromGIF($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         } elseif ($this->_findexts($logo) == "jpg") {
             echo "jpg";
             $Test->drawFromJPG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         }
     }
     $Test->setColorPalette(0, $settings['DataR'], $settings['DataG'], $settings['DataB']);
     if ($type == "bar") {
         // Draw the bar chart
         $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
     } elseif ($type == "line") {
         $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
         $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
     } elseif ($type == "cubic") {
         $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
         $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
         $Test->clearShadow();
         if ($settings['Filled'] == 'yes') {
             $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
         }
         $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
     }
     // Draw the textbox
     if (strlen($settings['Textbox'])) {
         $Test->setFontProperties($TextboxFontName, $TextboxFontSize);
         $Test->drawTextBox(0, $h - $TextboxHeight, $w, $h, $settings['Textbox'], 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30);
     }
     // Draw the legend
     if (strlen($settings['Legend'])) {
         $LegendFontSize = $settings['LegendFontSize'];
         $LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName'];
         $Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $settings['Legend']);
         $LegendW = $Position[2] - $Position[0] + 40;
         $Test->setFontProperties($LegendFontName, $LegendFontSize);
         $Test->drawLegend($w - $LegendW, 10, $DataSet->GetDataDescription(), $settings['LBR'], $settings['LBG'], $settings['LBB'], 52, 58, 82, $settings['LR'], $settings['LG'], $settings['LB'], TRUE);
     }
     // Render the picture
     $Test->addBorder(2);
     if (strlen($imgname)) {
         //custom image name
         $imgname = $this->_img_path . "/" . $imgname;
     } else {
         $this->obj->load->helper('string');
         $imgname = $this->_img_path . "/{$type}-" . random_string('alnum', 16) . ".png";
     }
     $Test->Render($imgname);
     return array("name" => '/' . $imgname, "w" => $w + 4, "h" => $h + 4);
 }
Beispiel #15
0
 /**
  * Рисуем графики с помощью библиотеки pChart
  * @param object $model
  * @param integer $max_id
  * @param integer $x
  * @param integer $y
  * @param integer $y2
  */
 public function pChart($model, $max_id, $x, $y, $y2 = NULL)
 {
     /* Include the pData class */
     require_once Yii::getAlias('@app') . '/pChart/pChart/pData.class';
     require_once Yii::getAlias('@app') . '/pChart/pChart/pCache.class';
     require_once Yii::getAlias('@app') . '/pChart/pChart/pChart.class';
     //создаем объект данных
     $myData = new \pData();
     if (!$y2) {
         $datas = $model::find()->select([$x, $y])->andWhere("id > {$max_id} - 7")->all();
     } else {
         $datas = $model::find()->select([$x, $y, $y2])->andWhere("id > {$max_id} - 7")->all();
     }
     foreach ($datas as $key => $data) {
         $myData->AddPoint($data->{$x}, $x);
         $myData->AddPoint($data->{$y}, $y);
         if ($y2 != NULL) {
             $myData->AddPoint($data->{$y2}, $y2);
         }
     }
     //устанавливаем точки с датами
     //на ось абсцисс
     $myData->SetAbsciseLabelSerie($x);
     //помечаем данные как предназначеные для
     //отображения
     $myData->AddSerie($y);
     $myData->AddSerie($y2);
     //устанавливаем имена
     $myData->SetSerieName($y);
     $myData->SetSerieName($y2);
     //создаем график шириной  и высотой  px
     $graph = new \pChart(340, 130);
     //устанавливаем шрифт и размер шрифта
     $graph->setFontProperties(Yii::getAlias('@app') . '/pChart/Fonts/tahoma.ttf', true, 8);
     //координаты левой верхней вершины и правой нижней
     //вершины графика
     $graph->setGraphArea(35, 20, 330, 110);
     //добавляем бэкграунд
     $graph->drawBackground(255, 0, 0);
     $graph->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
     //рисуем заполненный четырехугольник
     $graph->drawFilledRoundedRectangle(7, 7, 993, 493, 5, 240, 240, 240);
     //теперь незаполненный для эффекта тени
     $graph->drawRoundedRectangle(5, 5, 995, 495, 5, 0, 200, 0);
     //прорисовываем фон графика
     $graph->drawGraphArea(200, 255, 255, TRUE);
     //устанавливаем данные для графиков
     $graph->drawScale($myData->GetData(), $myData->GetDataDescription(), SCALE_NORMAL, 10, 10, 10, true, 0, 2);
     //рисуем сетку для графика
     $graph->drawGrid(4, TRUE, 200, 230, 230, 50);
     //прорисовываем линейные графики
     $graph->drawLineGraph($myData->GetData(), $myData->GetDataDescription());
     // рисуем точки на графике
     $graph->drawPlotGraph($myData->GetData(), $myData->GetDataDescription(), 3, 2, 255, 255, 255);
     // пишем в подвале некоторый текст
     $graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
     $graph->drawTextBox(805, 470, 990, 480, "{$x}", 0, 150, 150, 150, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
     $graph->drawTextBox(10, 470, 140, 480, "{$y}", 0, 250, 250, 250, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
     //ложим легенду
     $graph->drawLegend(90, 35, $myData->GetDataDescription(), 255, 255, 255);
     //Пишем заголовок
     $graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
     $graph->drawTitle(480, 22, "График", 50, 50, 50, -1, -1, true);
     //выводим в браузер
     $graph->Render(Url::to('@app/web/uploads/' . $y . '.png'));
 }