Example #1
0
/* Add a border to the picture */
//$myPicture->drawRectangle(800,350,0,0,array("R"=>0,"G"=>0,"B"=>0));
/* Write the chart title */
// $myPicture->setFontProperties(array("FontName"=>"./fonts/simsun.ttc","FontSize"=>8,"R"=>255,"G"=>255,"B"=>255));
//$myPicture->drawText(10,16,"Average recorded temperature",array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
$myPicture->drawText(200, 60, $chart_title);
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(40, 60, 800, 400);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "Mode" => SCALE_MODE_START0, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 45, "LabelSkip" => $row_number / 60);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawLineChart();
//$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
/* Write the chart legend */
//$myPicture->drawLegend(590,9,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL,"FontR"=>255,"FontG"=>255,"FontB"=>255));
//$myPicture->drawLegend(100,40,array("Style"=>LEGEND_FAMILY_BOX,"Mode"=>LEGEND_VERTICAL));
$myPicture->drawLegend(800, 150, 0, 255, 255, 255);
/* Render the picture (choose the best way) */
$myPicture->Render("pictures/{$chart_png}.png");
echo "<img src=\"pictures/{$chart_png}.png\" />";
?>
</body></html>
Example #2
0
 public function createCharts($lenght, $width = 1000, $height = 400, $statisticsUncategorized, $params, $options)
 {
     //print_r($params);
     //print_r($options);
     $year = date('Y');
     $month = date('m');
     $y = date('Y', strtotime('-' . ($lenght - 1) . ' month'));
     $m = date('m', strtotime('-' . ($lenght - 1) . ' month'));
     $user = Zend_Registry::get('User');
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $creditnotesDb = new Sales_Model_DbTable_Creditnote();
     $turnover = array();
     $turnoverCategories = array();
     while ($y <= $year) {
         while ($m) {
             if ($y < $year || $m <= $month) {
                 //Get invoices
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (invoicedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $invoices = $invoicesDb->fetchAll($invoicesDb->select()->from(array('i' => 'invoice'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 //Get credit notes
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (creditnotedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $creditnotes = $creditnotesDb->fetchAll($creditnotesDb->select()->from(array('i' => 'creditnote'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 $turnover[$y . $ym] = 0;
                 $turnoverCategories[0][$y . $ym] = 0;
                 //Calculate invoices
                 foreach ($invoices as $invoice) {
                     $turnover[$y . $ym] += $invoice->subtotal;
                     if (isset($turnoverCategories[$invoice->catid][$y . $ym])) {
                         $turnoverCategories[$invoice->catid][$y . $ym] += $invoice->subtotal;
                     } else {
                         $turnoverCategories[$invoice->catid][$y . $ym] = $invoice->subtotal;
                     }
                 }
                 //Calculate credit notes
                 foreach ($creditnotes as $creditnote) {
                     $turnover[$y . $ym] -= $creditnote->subtotal;
                     if (isset($turnoverCategories[$creditnote->catid][$y . $ym])) {
                         $turnoverCategories[$creditnote->catid][$y . $ym] += $creditnote->subtotal;
                     } else {
                         $turnoverCategories[$creditnote->catid][$y . $ym] = $creditnote->subtotal;
                     }
                 }
                 //Calculate categories
                 foreach ($options['categories'] as $id => $category) {
                     if (isset($turnoverCategories[$id][$y . $ym])) {
                         $turnoverCategories[$id][$y . $ym] = round($turnoverCategories[$id][$y . $ym]);
                     } else {
                         $turnoverCategories[$id][$y . $ym] = 0;
                     }
                 }
                 $turnover[$y . $ym] = round($turnover[$y . $ym]);
                 $turnoverCategories[0][$y . $ym] = round($turnoverCategories[0][$y . $ym]);
                 $dataDb = 'total:' . $turnover[$y . $ym] . ';';
                 foreach ($turnoverCategories as $key => $value) {
                     if (isset($value[$y . $ym])) {
                         $dataDb .= $key . ':' . $value[$y . $ym] . ';';
                     }
                 }
                 //$archiveDb->addArchive($y.$ym, $dataDb, $user['clientid']);
                 $months[$y . $ym] = $y . '/' . $ym;
             }
             ++$m;
             if ($m > 12) {
                 $m = 0;
             }
         }
         ++$y;
         $m = 1;
     }
     //Merge subcategories to main categories
     foreach ($turnoverCategories as $id => $values) {
         if (isset($options['categories'][$id]['childs']) && $id != $params['catid']) {
             foreach ($options['categories'][$id]['childs'] as $childId) {
                 foreach ($values as $month => $value) {
                     $turnoverCategories[$id][$month] += $turnoverCategories[$childId][$month];
                 }
                 unset($turnoverCategories[$childId]);
             }
         }
     }
     //Remove empty arrays
     foreach ($turnoverCategories as $key => $values) {
         if (!array_sum($values)) {
             unset($turnoverCategories[$key]);
         }
     }
     require_once BASE_PATH . '/library/pChart/class/pData.class.php';
     require_once BASE_PATH . '/library/pChart/class/pDraw.class.php';
     require_once BASE_PATH . '/library/pChart/class/pImage.class.php';
     //Turnover
     /* Create your dataset object */
     $turnoverData = new pData();
     /* Add data in your dataset */
     $turnoverData->addPoints($turnover, 'Values');
     $turnoverData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverData->addPoints($months, 'Labels');
     $turnoverData->setSerieDescription('Labels', 'Months');
     $turnoverData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnover = new pImage($width, $height, $turnoverData);
     /* Turn off AA processing */
     $turnover->Antialias = FALSE;
     /* Choose a nice font */
     $turnover->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnover->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnover->drawScale(array('DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array('Gradient' => TRUE, 'GradientMode' => GRADIENT_EFFECT_CAN, 'DisplayPos' => LABEL_POS_INSIDE, 'DisplayValues' => TRUE, 'DisplayR' => 0, 'DisplayG' => 0, 'DisplayB' => 0, 'DisplayShadow' => TRUE, 'Surrounding' => 10);
     $turnover->drawBarChart($settings);
     /* Build the PNG file and send it to the web browser */
     if (!file_exists(BASE_PATH . '/cache/chart/')) {
         mkdir(BASE_PATH . '/cache/chart/');
         chmod(BASE_PATH . '/cache/chart/', 0777);
     }
     $turnover->Render(BASE_PATH . '/cache/chart/turnover-' . $width . '-' . $height . '.png');
     //Turnover by categories
     /* Create your dataset object */
     $turnoverCategoriesData = new pData();
     /* Add data in your dataset */
     $turnoverCategoriesTotal = array();
     foreach ($turnoverCategories as $key => $value) {
         $turnoverCategoriesTotal[$key] = array_sum($value);
     }
     arsort($turnoverCategoriesTotal);
     foreach ($turnoverCategoriesTotal as $key => $value) {
         if ($key && isset($options['categories'][$key])) {
             $turnoverCategoriesData->addPoints($turnoverCategories[$key], $options['categories'][$key]['title']);
         }
     }
     if (isset($turnoverCategories[0])) {
         $turnoverCategoriesData->addPoints($turnoverCategories[0], $statisticsUncategorized);
     }
     $turnoverCategoriesData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverCategoriesData->addPoints($months, 'Labels');
     $turnoverCategoriesData->setSerieDescription('Labels', 'Months');
     $turnoverCategoriesData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnoverCategories = new pImage($width, $height, $turnoverCategoriesData);
     /* Turn off AA processing */
     $turnoverCategories->Antialias = FALSE;
     /* Choose a nice font */
     $turnoverCategories->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnoverCategories->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnoverCategories->drawScale(array('XMargin' => 2, 'DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_ADDALL_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array();
     $turnoverCategories->drawStackedAreaChart($settings);
     /* Write the chart legend */
     $turnoverCategories->drawLegend(100, 20, array('Style' => LEGEND_NOBORDER, 'Mode' => LEGEND_VERTICAL));
     /* Build the PNG file and send it to the web browser */
     $turnoverCategories->Render(BASE_PATH . '/cache/chart/turnover-category-' . $width . '-' . $height . '.png');
 }
Example #3
0
        /* Write the data bounds */
        $boundSetting = array("DrawBox" => FALSE, "MaxLabelTxt" => 'Max:', "MinLabelTxt" => 'Min:', "MinDisplayR" => 0, "MinDisplayG" => 0, "MinDisplayB" => 0, "DisplayOffset" => 5);
        if ($bound == 'min') {
            $myPicture->writeBounds(BOUND_MIN, $boundSetting);
        }
        if ($bound == 'max') {
            $myPicture->writeBounds(BOUND_MAX, $boundSetting);
        }
        if ($bound == 'both') {
            $myPicture->writeBounds(BOUND_BOTH, $boundSetting);
        }
    }
}
/* Render the picture (choose the best way) */
if ($resultType == 'charttable') {
    $myPicture->Render("pictures/chart_png_{$id}.png");
    echo '<html>';
    echo '<head>';
    echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
    echo '<link rel="stylesheet" type="text/css" href="./datatb.css" />';
    echo '<title>pchart_config</title>';
    echo '</head>';
    echo '<body>';
    echo "<img src='pictures/chart_png_{$id}.png' />";
    if (isset($err)) {
        echo $err;
    } else {
        echo $table_html;
    }
    echo '</body>';
    echo '</html>';
Example #4
0
            $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 330, DIRECTION_VERTICAL, $Settings);
            $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
            /* Add a border to the picture */
            $myPicture->drawRectangle(0, 0, 65 * $nbr_room + 64, 329, array("R" => 0, "G" => 0, "B" => 0));
            /* Write the chart title */
            $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255));
            $myPicture->drawText(10, 13, "Capacite electrique disponible (kW)", array("R" => 255, "G" => 255, "B" => 255));
            /* Define the default font */
            $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10));
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
            /* Set the graph area */
            $myPicture->setGraphArea(50, 40, 65 * $nbr_room + 35, 290);
            $myPicture->drawGradientArea(50, 40, 65 * $nbr_room + 35, 290, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
            /* Draw the chart scale */
            $scaleSettings = array("AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10);
            $myPicture->drawScale($scaleSettings);
            /* Draw the chart */
            $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Surrounding" => 30));
            if ($consult_date != "Donnée actuelle") {
                $myPicture->Render("images/capae_graph_render_{$consult_date}.png");
            } else {
                $myPicture->Render("images/capae_graph_render.png");
            }
        } else {
            $error = 1;
        }
    }
} catch (Exception $e) {
    // Catch des erreurs et écriture dans le fichier de log
    require 'error_log.php';
}
Example #5
0
    $myPicture->setGraphArea(75, 90, 525, 540);
    /* Create the Scatter chart object */
    $myScatter = new pScatter($myPicture, $myData);
    /* Draw the scale */
    $myScatter->drawScatterScale();
    /* Turn on shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    /* Draw a scatter plot chart */
    $myScatter->drawScatterPlotChart();
    /* Draw the legend */
    $myScatter->drawScatterLegend(420, 580, array("Mode" => LEGEND_HORIZONTAL, "Style" => LEGEND_NOBORDER));
    /* Draw the line of best fit */
    $myScatter->drawScatterBestFit();
    /* Render the picture (choose the best way) */
    // $myPicture->autoOutput("pictures/example.drawScatterBestFit.png");
    $myPicture->Render("attempts_pro2.png");
}
echo "<body>";
if (isset($_POST['option'])) {
    echo "<div class='bigcontainer2'>";
    echo "<div class='bigmain2'>";
} else {
    echo "<div class='bigcontainer'>";
    echo "<div class='bigmain'>";
}
echo "<table align=center style='width:50%'>";
echo "<tr>";
if (isset($_POST['option'])) {
    echo $extype;
    echo "<br><br>";
    // echo "Quartile based on: ".$quartile;
$myArray = explode(',', $string);
$i = 0;
while ($string = fgets($handler)) {
    $myArray = explode(',', $string);
    $components[$i] = $myArray[0];
    ++$i;
}
$MyData = new pData();
$MyData->importFromCSV("foundit.csv", array("GotHeader" => TRUE, "SkipColumns" => array(0)));
$MyData->setAxisName(0, "Bug Count");
$MyData->setAxisName(1, "Components");
$MyData->addPoints($components, "Components");
$MyData->setAbscissa("Components");
//$MyData->setSerieOnAxis("Component",1);
//$MyData->setAxisXY(1,AXIS_X);
/* Create the pChart object */
$myPicture = new pImage(3000, 700, $MyData);
$myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 3000, 680);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Interleave" => 0.5, "Surrounding" => -15, "InnerSurrounding" => 15));
/* Write the chart legend */
$myPicture->drawLegend(800, 10, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->Render("foundit.png");
Example #7
0
function block_mystats_quiz_chart($avg, $high, $strAvg, $strHigh, $strTitle, $strScale, $userid)
{
    $myQuizData = new pData();
    $myQuizData->addPoints(array($avg), "Serie1");
    $myQuizData->setSerieDescription("Serie1", $strAvg);
    $myQuizData->setSerieOnAxis("Serie1", 0);
    $myQuizData->addPoints(array($high), "Serie2");
    $myQuizData->setSerieDescription("Serie2", $strHigh);
    $myQuizData->setSerieOnAxis("Serie2", 0);
    $myQuizData->addPoints(array(" "), "Absissa");
    $myQuizData->setAbscissa("Absissa");
    $myQuizData->setAxisPosition(0, AXIS_POSITION_LEFT);
    $myQuizData->setAxisName(0, $strScale);
    $myQuizData->setAxisUnit(0, "");
    $myQuizPicture = new pImage(350, 230, $myQuizData);
    $quizSettings = array("R" => 255, "G" => 255, "B" => 255);
    $myQuizPicture->drawFilledRectangle(0, 0, 350, 230, $quizSettings);
    $myQuizPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
    $myQuizPicture->setFontProperties(array("FontName" => "../blocks/mystats/pChart2.1.3/fonts/GeosansLight.ttf", "FontSize" => 14));
    $TextSettings = array("Align" => TEXT_ALIGN_TOPLEFT, "R" => 0, "G" => 0, "B" => 0);
    $myQuizPicture->drawText(25, 25, $strTitle, $TextSettings);
    $myQuizPicture->setShadow(FALSE);
    $myQuizPicture->setGraphArea(25, 70, 325, 210);
    $myQuizPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "../blocks/mystats/pChart2.1.3/fonts/pf_arma_five.ttf", "FontSize" => 8));
    $AxisBoundaries = array(0 => array("Min" => 0, "Max" => 110), 1 => array("Min" => 00, "Max" => 1));
    $quizSettings = array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
    $myQuizPicture->drawScale($quizSettings);
    $myQuizPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
    $quizConfig = array("DisplayValues" => 1, "Rounded" => 1, "AroundZero" => 1);
    $myQuizPicture->drawBarChart($quizConfig);
    $quizConfig = array("R" => 0, "G" => 0, "B" => 0, "Alpha" => 50, "AxisID" => 0, "Ticks" => 4, "Caption" => "Threshold");
    $myQuizPicture->drawThreshold(0, $quizConfig);
    $quizConfig = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "../blocks/mystats/pChart2.1.3/fonts/pf_arma_five.ttf", "FontSize" => 8, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_ROUND, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_CIRCLE);
    $myQuizPicture->drawLegend(240, 16, $quizConfig);
    $imgName = sha1($userid . $strTitle) . '.png';
    $myQuizPicture->Render('../blocks/mystats/img/' . $imgName);
    return '<img src="../blocks/mystats/img/' . $imgName . '" alt="' . $strAvg . ': ' . $avg . ', ' . $strHigh . ': ' . $high . '">';
}
Example #8
0
function createGraphe($vData, $hData, $titre, $vLabel, $hLabel)
{
    $MyData = new pData();
    /*Je présente ma série de données à utiliser pour le graphique et je détermine le titre de l'axe vertical avec setAxisName*/
    $MyData->addPoints($vData, "vertical");
    $MyData->setSerieWeight("vertical", 2);
    $MyData->setAxisName(0, $vLabel);
    /*J'indique les données horizontales du graphique. Il doit y avoir le même nombre que pour ma série de données précédentes (logique)*/
    $MyData->addPoints($hData, "horizontal");
    $MyData->setSerieDescription("horizontal", $hLabel);
    $MyData->setAbscissa("horizontal");
    $MyData->setPalette("vertical", array("R" => 255, "G" => 0, "B" => 0));
    /* Je crée l'image qui contiendra mon graphique précédemment crée */
    $myPicture = new pImage(900, 400, $MyData);
    /* Je crée une bordure à mon image */
    $myPicture->drawRectangle(0, 0, 899, 399, array("R" => 0, "G" => 0, "B" => 0));
    /* J'indique le titre de mon graphique, son positionnement sur l'image et sa police */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/Forgotte.ttf", "FontSize" => 11));
    $myPicture->drawText(200, 25, $titre, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
    /* Je choisi la font de mon graphique */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
    /* Je détermine la taille du graphique et son emplacement dans l'image */
    $myPicture->setGraphArea(60, 40, 800, 380);
    /* Paramètres pour dessiner le graphique à partir des deux abscisses */
    $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => TRUE, "LabelSkip" => 4);
    $myPicture->drawScale($scaleSettings);
    /* Je dessine mon graphique en fonction des paramètres précédents */
    $myPicture->drawAreaChart();
    $myPicture->drawLineChart();
    /* J'indique le chemin où je souhaite que mon image soit créée */
    $myPicture->Render("img/" . $titre . ".png");
}
Example #9
0
// $myPicture->drawGradientArea(0,0,1000,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));
/* Add a border to the picture */
//$myPicture->drawRectangle(1500,450,0,0,array("R"=>0,"G"=>0,"B"=>0));
/* Write the chart title */
// $myPicture->setFontProperties(array("FontName"=>"../fonts/simsun.ttc","FontSize"=>8,"R"=>255,"G"=>255,"B"=>255));
//$myPicture->drawText(10,16,"Average recorded temperature",array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/simsun.ttc", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 1000, 400);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 45, "LabelSkip" => $row_number / 60);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawLineChart();
//$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
/* Write the chart legend */
// $myPicture->drawLegend(590,9,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL,"FontR"=>255,"FontG"=>255,"FontB"=>255));
// $myPicture->drawLegend(100,40,array("Style"=>LEGEND_FAMILY_BOX,"Mode"=>LEGEND_VERTICAL));
$myPicture->drawLegend(1000, 60, 0, 255, 255, 255);
/* Render the picture (choose the best way) */
// $myPicture->autoOutput("pictures/example.drawLineChart.plots.png");
$myPicture->Render("pictures/example.{$chart_png}.png");
echo "<img src=\"pictures/example.{$chart_png}.png\" />";
?>
</body></html>
//$myPicture->drawText(10,16,"Average recorded temperature",array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/simsun.ttc", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
$myPicture->drawText(40, 60, $chart_title);
$myPicture->setFontProperties(array("FontName" => "../fonts/simsun.ttc", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(40, 60, 800, 400);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 45, "LabelSkip" => $row_number / 60);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawLineChart();
//$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
/* Write the chart legend */
// $myPicture->drawLegend(590,9,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL,"FontR"=>255,"FontG"=>255,"FontB"=>255));
// $myPicture->drawLegend(100,40,array("Style"=>LEGEND_FAMILY_BOX,"Mode"=>LEGEND_VERTICAL));
$myPicture->drawLegend(800, 150, 0, 255, 255, 255);
/* Render the picture (choose the best way) */
// $myPicture->autoOutput("pictures/example.drawLineChart.plots.png");
$filename = "pictures/" . $chart_name . ".png";
$myPicture->Render($filename);
echo "<img src={$filename} />";
//$myPicture->Render("pictures/example.drawLineChart2.plots.rand().png");
//echo "<img src=\"pictures/example.drawLineChart2.plots.png\" />";
?>
</body></html>
        $filas[$indexArr] = $columnas;
        $indexArr++;
    }
}
for ($i = 0; $i < $indexArr; $i++) {
    $DataSet->addPoints(array($filas[$i][1], $filas[$i][2], $filas[$i][3], $filas[$i][4], $filas[$i][5]), $filas[$i][0]);
    $DataSet->setAxisName(0, "Valores");
}
$DataSet->addPoints(array("estrategia", "personas", "recursos", "procesos", "resultados"), "Fechas");
$DataSet->setSerieDescription("Fechas", "Fecha");
$DataSet->setAbscissa("Fechas");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $DataSet);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "wp-content/plugins/adeada/test/pChart2/fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale  */
$myPicture->setGraphArea(50, 30, 680, 200);
$myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255, "DisplayShadow" => TRUE, "Surrounding" => 10);
$myPicture->drawBarChart($settings);
/* Write the chart legend */
$myPicture->drawLegend(580, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
$myPicture->Render("holas.png");
?>
 
<img src='holas.png'>
Example #12
0
function drk_start()
{
    global $db, $darkcoin;
    $drk_price = file_get_contents("http://midas-bank.com/price.php?name=DRK");
    $hash_block = $darkcoin->getbestblockhash();
    $info_block = $darkcoin->getblock($hash_block);
    $tx = $info_block["tx"][0];
    $diff = round($info_block["difficulty"]);
    $last_block = $block_id = $info_block["height"];
    $block_time = $info_block["time"];
    $encode_tx = $darkcoin->getrawtransaction($tx);
    $tx_info = $darkcoin->decoderawtransaction($encode_tx);
    $address = $tx_info["vout"][0]["scriptPubKey"]["addresses"][0];
    // Определеяем P2Pool
    $p2p = json_decode(file_get_contents("http://eu.p2pool.pl:7903/recent_blocks"), TRUE);
    foreach ($p2p as $data) {
        if ($block_id == $data["number"]) {
            $address = 'P2Pool';
            break;
        }
    }
    // Записываем данные в базу
    $query_select = $db->prepare("SELECT * FROM `address` WHERE `address` =:address");
    $query_select->bindParam(':address', $address, PDO::PARAM_STR);
    $query_select->execute();
    if ($query_select->rowCount() != 1) {
        $query_insert = $db->prepare("INSERT INTO `address` (`address`) VALUES (:address)");
        $query_insert->bindParam(':address', $address, PDO::PARAM_STR);
        $query_insert->execute();
    }
    // Записываем статистику по блокам
    $query_select = $db->prepare("SELECT * FROM `data` WHERE `bid` =:bid");
    $query_select->bindParam(':bid', $block_id, PDO::PARAM_STR);
    $query_select->execute();
    if ($query_select->rowCount() == 1) {
        echo "Find new block... \n";
        return;
    } else {
        echo "Block: {$block_id} | Find: {$address} | Time: {$block_time} | Diff: {$diff} | Price: {$drk_price}\$  \n";
        $query_insert = $db->prepare("INSERT INTO `data` (`bid`, `diff`, `address`, `time`) VALUES (:bid, :diff, :address, :time)");
        $query_insert->bindParam(':bid', $block_id, PDO::PARAM_STR);
        $query_insert->bindParam(':diff', $diff, PDO::PARAM_STR);
        $query_insert->bindParam(':address', $address, PDO::PARAM_STR);
        $query_insert->bindParam(':time', $block_time, PDO::PARAM_STR);
        $query_insert->execute();
        $lastId = $db->lastInsertId();
    }
    $k = 0;
    $query_select = $db->prepare("SELECT * FROM `data` WHERE `time` > UNIX_TIMESTAMP()-86400");
    $query_select->execute();
    $all_data = $query_select->rowCount();
    $query_select = $db->prepare("SELECT SUM(diff) FROM `data` WHERE `time` > UNIX_TIMESTAMP()-86400");
    $query_select->execute();
    $row = $query_select->fetch();
    $diff_sum = $row['SUM(diff)'];
    $avg_diff = $diff_sum / $all_data;
    $query_select = $db->prepare("SELECT * FROM `address`");
    $query_select->execute();
    if ($query_select->rowCount() == 0) {
        return;
    }
    while ($row = $query_select->fetch()) {
        $query_data = $db->prepare("SELECT * FROM `data` WHERE `address` = :address AND `time` > UNIX_TIMESTAMP()-86400");
        $query_data->bindParam(':address', $row['address'], PDO::PARAM_STR);
        $query_data->execute();
        if ($row['address'] == 'P2Pool') {
            $row['label'] = 'P2Pool';
        }
        if ($query_data->rowCount() / $all_data * 100 < 3 || empty($row['label'])) {
            $k = $k + $query_data->rowCount();
            continue;
        }
        $arr_count[] = $query_data->rowCount();
        $arr_label[] = $row['label'];
    }
    if ($k > 0) {
        $arr_label[] = 'Other';
        $arr_count[] = $k;
    }
    array_multisort($arr_count, SORT_DESC, $arr_label);
    /* Create and populate the pData object */
    $MyData = new pData();
    $MyData->addPoints($arr_count, "ScoreA");
    $MyData->setSerieDescription("ScoreA", "Application A");
    /* Define the absissa serie */
    $MyData->addPoints($arr_label, "Labels");
    $MyData->setAbscissa("Labels");
    /* Create the pChart object */
    $myPicture = new pImage(720, 400, $MyData, TRUE);
    $myPicture->Antialias = TRUE;
    /* Draw a solid background */
    $Settings = array("R" => 255, "G" => 255, "B" => 255);
    $myPicture->drawFilledRectangle(0, 0, 920, 400, $Settings);
    /* Write the picture title */
    $myPicture->setFontProperties(array("FontName" => "/var/www/midas/root/fonts/verdana.ttf", "FontSize" => 14));
    $myPicture->drawText(0, 20, "At block: {$last_block}", array("R" => 0, "G" => 0, "B" => 0));
    $myPicture->drawText(210, 24, "Difficulty: {$diff}", array("R" => 0, "G" => 0, "B" => 0));
    $myPicture->drawText(390, 24, "Avg difficulty: " . round($avg_diff), array("R" => 0, "G" => 0, "B" => 0));
    $myPicture->drawText(600, 23, "Price: {$drk_price}\$", array("R" => 0, "G" => 0, "B" => 0));
    /* Create the pPie object */
    $PieChart = new pPie($myPicture, $MyData);
    /* Enable shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    /* Draw a splitted pie chart */
    $myPicture->setFontProperties(array("FontName" => "/var/www/midas/root/fonts/tahoma.ttf", "FontSize" => 10));
    $PieChart->draw3DPie(340, 220, array("WriteValues" => TRUE, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "Radius" => 225, "DataGapAngle" => 4, "DataGapRadius" => 6, "DrawLabels" => TRUE, "Border" => TRUE));
    /* Render the picture (choose the best way) */
    $myPicture->Render("/var/www/midas/root/stat/drk.png");
    unset($data);
    $data = ['num' => $last_block, 'diff' => round($avg_diff)];
    $query = $db->prepare("SELECT * FROM `params` WHERE `key` = 'block'");
    $query->execute();
    if ($query->rowCount() != 1) {
        $query = $db->prepare("INSERT INTO `params` (`key`, `value`) VALUES ('block', :value)");
        $query->bindParam(':value', json_encode($data), PDO::PARAM_STR);
        $query->execute();
    } else {
        $query = $db->prepare("UPDATE `params` SET `value` =:value WHERE `key` = 'block'");
        $query->bindParam(':value', json_encode($data), PDO::PARAM_STR);
        $query->execute();
    }
    if (!empty($lastId)) {
        $j = 0;
        $tx_coun = count($info_block["tx"]);
        foreach ($info_block["tx"] as $value) {
            $encode_tx = $darkcoin->getrawtransaction("{$value}");
            $tx_info = $darkcoin->decoderawtransaction($encode_tx);
            foreach ($tx_info["vout"] as $val) {
                $j += $val["value"];
            }
            $query = $db->prepare("UPDATE `data` SET `txs` = :count, `tx_sum` = :sum WHERE `id` = :id");
            $query->bindParam(':count', $tx_coun, PDO::PARAM_STR);
            $query->bindParam(':sum', $j, PDO::PARAM_STR);
            $query->bindParam(':id', $lastId, PDO::PARAM_STR);
            $query->execute();
        }
    }
}
            $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
            /* Add a border to the picture */
            $myPicture->drawRectangle(0, 0, 65 * $nbr_room + 64, 329, array("R" => 0, "G" => 0, "B" => 0));
            /* Write the chart title */
            $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255));
            $myPicture->drawText(10, 13, "Nombre de baies possible et de baies restant a installer", array("R" => 255, "G" => 255, "B" => 255));
            /* Define the default font */
            $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10));
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
            /* Set the graph area */
            $myPicture->setGraphArea(50, 40, 65 * $nbr_room + 35, 290);
            $myPicture->drawGradientArea(50, 40, 65 * $nbr_room + 35, 290, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
            /* Draw the chart scale */
            $scaleSettings = array("AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10);
            $myPicture->drawScale($scaleSettings);
            $myPicture->drawLegend((65 * $nbr_room + 65) / 4, 315, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
            /* Draw the chart */
            $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Surrounding" => 30));
            if ($consult_date != "Donnée actuelle") {
                $myPicture->Render("images/nbrbpbr_graph_render_{$consult_date}.png");
            } else {
                $myPicture->Render("images/nbrbpbr_graph_render.png");
            }
        } else {
            $error = 1;
        }
    }
} catch (Exception $e) {
    // Catch des erreurs et écriture dans le fichier de log
    require 'error_log.php';
}
Example #14
0
 /**
  * Save rendering to disk
  *
  * @param string $filename without path
  * @return string path of file
  */
 public function sendToDisk($filename)
 {
     $filePath = self::getOutputPath($filename);
     $this->pImage->Render($filePath);
     return $filePath;
 }