Exemplo n.º 1
0
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 5, 25, 20);
// Setup the tab
$graph->tabtitle->Set(' Year 2003 ');
$graph->tabtitle->SetFont(FF_ARIAL, FS_BOLD, 13);
$graph->tabtitle->SetColor('darkred', '#E1E1FF');
// Enable X-grid as well
$graph->xgrid->Show();
// Use months as X-labels
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Create the plot
$p1 = new LinePlot($datay1);
$p1->SetColor("navy");
$p1->SetCSIMTargets(array('#1', '#2', '#3', '#4', '#5'));
// Use an image of favourite car as
$p1->mark->SetType(MARK_IMG, 'saab_95.jpg', 0.5);
//$p1->mark->SetType(MARK_SQUARE);
// Displayes value on top of marker image
$p1->value->SetFormat('%d mil');
$p1->value->Show();
$p1->value->SetColor('darkred');
$p1->value->SetFont(FF_ARIAL, FS_BOLD, 10);
// Increase the margin so that the value is printed avove tje
// img marker
$p1->value->SetMargin(14);
// Incent the X-scale so the first and last point doesn't
// fall on the edges
$p1->SetCenter();
$graph->Add($p1);
Exemplo n.º 2
0
$ydata = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
$ydata2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$targ = array("#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9", "#10");
$alt = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
// Create the graph.
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->img->SetMargin(40, 20, 30, 40);
$graph->title->Set("CSIM example with bar and line");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Setup axis titles
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Create the linear plot
$lineplot = new LinePlot($ydata);
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetWidth(5);
$lineplot->mark->SetColor('black');
$lineplot->mark->SetFillColor('red');
$lineplot->SetCSIMTargets($targ, $alt);
// Create line plot
$barplot = new barPlot($ydata2);
$barplot->SetCSIMTargets($targ, $alt);
// Add the plots to the graph
$graph->Add($lineplot);
$graph->Add($barplot);
$graph->StrokeCSIM();
?>


Exemplo n.º 3
0
function graficar_cantidades($eje_y, $x_label, $pareto, $titulo_eje_x, $titulo_eje_y, $title, $name)
{
    include "../jpgraph/src/jpgraph.php";
    include "../jpgraph/src/jpgraph_line.php";
    include "../jpgraph/src/jpgraph_bar.php";
    $graph = new Graph(820, 350);
    $graph->SetScale("textlin");
    $graph->SetMarginColor("#FFFFFF");
    $graph->img->SetMargin(80, 80, 60, 100);
    $graph->yaxis->SetTitleMargin(40);
    $graph->SetBackgroundImage("../imagenes/fondo.jpg", BGIMG_FILLFRAME);
    $graph->xaxis->SetLabelAngle(90);
    $graph->xaxis->SetTickLabels($x_label);
    $graph->legend->Pos(0.03, 0.3);
    $graph->title->SetColor("#000000");
    $graph->title->Set($title);
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->yaxis->title->Set($titulo_eje_y);
    $graph->xaxis->title->Set($titulo_eje_x);
    $graph->setcolor("#EEEEEE");
    $graph->setshadow("true", 3, "#aaaaaa");
    // Crear la gráfica de barras
    $bplot1 = new BarPlot($eje_y);
    $bplot1->SetWidth(0.3);
    $bplot1->SetYMin(0.02);
    $bplot1->SetFillColor("orange@0.2");
    $bplot1->SetShadow('darkgray');
    $bplot1->value->SetColor("darkred");
    $bplot1->value->Show();
    // Crear la gráfica de líneas
    $lplot = new LinePlot($pareto);
    $lplot->mark->SetType(MARK_FILLEDCIRCLE);
    $lplot->mark->SetFillColor("red");
    $lplot->mark->SetWidth(3);
    $lplot->SetColor("blue");
    $lplot->SetCSIMTargets($targ, $alt);
    $lplot->SetBarCenter();
    $graph->Add($bplot1);
    $graph->Stroke("charts/" . $name);
}
Exemplo n.º 4
0
$graph->yaxis->title->Set('Basic Rate');
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->yaxis->title->SetColor('black');
$graph->Add($lp1);
// First multi Y-axis plot
$lp2 = new LinePlot($datay2);
$lp2->SetLegend('2002');
$lp2->mark->SetType(MARK_DIAMOND);
$lp2->mark->SetWidth(15);
$lp2->mark->SetFillColor('darkred');
$lp2->SetCSIMTargets($targ2, $alts2);
$graph->ynaxis[0]->SetColor('darkred');
$graph->ynaxis[0]->title->Set('Rate A');
$graph->ynaxis[0]->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->ynaxis[0]->title->SetColor('darkred');
$graph->AddY(0, $lp2);
// Second multi Y-axis plot
$lp3 = new LinePlot($datay3);
$lp3->SetLegend('2003');
$lp3->mark->SetType(MARK_DIAMOND);
$lp3->mark->SetWidth(15);
$lp3->mark->SetFillColor('darkgreen');
$lp3->SetCSIMTargets($targ3, $alts3);
$graph->ynaxis[1]->SetColor('darkgreen');
$graph->ynaxis[1]->title->Set('Rate B');
$graph->ynaxis[1]->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph->ynaxis[1]->title->SetColor('darkgreen');
$graph->AddY(1, $lp3);
// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
 function addAudiogramme($values, $mark_color)
 {
     $pressions = CExamAudio::$pressions;
     // Empty plot case
     $datay = $values;
     CMbArray::removeValue("", $datay);
     if (!count($datay)) {
         return;
     }
     $title = $this->title->t;
     $words = explode(" ", $title);
     $cote = $words[1];
     $labels = array();
     $jscalls = array();
     // Remove empty values to connect distant points
     $datax = array();
     $datay = array();
     foreach ($values as $key => $value) {
         if ($value !== "" && $value !== null) {
             $pression = $pressions[$key];
             $jstitle = strtr($title, "\n", " ");
             $labels[] = "Modifier l'admittance {$value} ml pour {$jstitle} à la pression {$pression} mm H²0";
             $jscalls[] = "javascript:changeTympanValue('{$cote}',{$key})";
             $datay[] = $value;
             $datax[] = "{$key}";
             // Needs to be a string when null
         }
     }
     $p1 = new LinePlot($datay, $datax);
     // Create the first line
     $p1->SetColor($mark_color);
     $p1->SetCenter();
     $p1->SetWeight(1);
     $p1->SetCSIMTargets($jscalls, $labels);
     // Marks
     $p1->mark->SetType(MARK_FILLEDCIRCLE);
     $p1->mark->SetColor($mark_color);
     $p1->mark->SetFillColor("{$mark_color}@0.6");
     $p1->mark->SetWidth(4);
     $this->Add($p1);
 }
Exemplo n.º 6
0
 function addAudiogramme($points, $title, $mark_color, $mark_type)
 {
     CMbArray::removeValue(array("", ""), $points);
     // Empty plot case
     if (!count($points)) {
         $datay = array(50);
         $p1 = new LinePlot($datay, $datay);
         $this->Add($p1);
         return;
     }
     $words = explode(" ", $title);
     $cote = $words[1];
     $labels = array();
     $jscalls = array();
     $dBs = array();
     $pcs = array();
     foreach ($points as $key => $point) {
         $dB = @$point[0];
         $pc = @$point[1];
         $dBs[] = $dB;
         $pcs[] = $pc;
         $labels[] = "Modifier le valeur {$pc}%% à {$dB}dB pour l'oreille {$cote}";
         $jscalls[] = "javascript:changeVocalValue('{$cote}',{$key})";
     }
     $p1 = new LinePlot($pcs, $dBs);
     // Create the first line
     $p1->SetColor($mark_color);
     $p1->SetLegend($title);
     $p1->SetCSIMTargets($jscalls, $labels);
     $p1->SetWeight(1);
     // Marks
     $p1->mark->SetType($mark_type);
     $p1->mark->SetColor($mark_color);
     $p1->mark->SetFillColor("{$mark_color}@0.6");
     $p1->mark->SetWidth(5);
     // Create the splined line
     if (count($points) > 1) {
         /*
         $spline = new Spline($dBs, $pcs);
         list($sdBs, $spcs) = $spline->Get(40);
         $p2 = new LinePlot($spcs, $sdBs);
         $p2->SetColor("$mark_color:1.8");
         
         $this->Add($p2);
         */
         $spline = new BezierTD($dBs, $pcs, 5);
         list($bdBs, $bpcs) = $spline->Get(40);
         $p3 = new LinePlot($bpcs, $bdBs);
         $p3->SetColor("{$mark_color}:1.8");
         $this->Add($p3);
     }
     $this->Add($p1);
 }
Exemplo n.º 7
0
    $data = array();
    $dataTargets = array();
    $dataNames = array();
    $previousAmount = null;
    foreach ($totals as $key => $currentAmount) {
        $data[] = is_null($previousAmount) || $currentAmount->compare($previousAmount) != 0 || $key == $displayEndDate->getTime() ? $currentAmount->get() : '-';
        $date = new Date($key);
        if ($showTickMarks) {
            $dataTargets[] = "javascript:reachThroughTrend('" . $date->getFormatted() . "', '" . implode(',', $accountIds) . "');";
            $dataNames[] = $date->getFormatted() . ': ' . $currentAmount->getFormatted();
        }
        $previousAmount = new Amount($currentAmount);
    }
    $line = new LinePlot($data, $xdata);
    if ($showTickMarks) {
        $line->SetCSIMTargets(array_values($dataTargets), array_values($dataNames));
        $line->mark->SetType(MARK_UTRIANGLE);
        $line->mark->SetColor($chartColors[$colorIndex % count($chartColors)]);
        $line->mark->SetFillColor($chartColors[$colorIndex % count($chartColors)]);
    }
    $line->SetColor($chartColors[$colorIndex % count($chartColors)]);
    $line->SetStepStyle();
    $line->SetLegend(getBadgerTranslation2('statistics', 'trendTotal'));
    $line->SetWeight(2);
    $colorIndex++;
    $graph->add($line);
}
$graph->xaxis->SetFont(FF_VERA);
$interval = $numDates / MAX_LABELS;
if ($interval < 1) {
    $interval = 1;
 public function summary($id)
 {
     JpGraph\JpGraph::load();
     JpGraph\JpGraph::module('line');
     $targ1 = array();
     $targ2 = array();
     $targ3 = array();
     $alts1 = array();
     $alts2 = array();
     $alts3 = array();
     // Setup some dummy targets for the CSIM
     $n = 5;
     for ($i = 0; $i < $n; ++$i) {
         $targ1[$i] = "#{$i}";
         $targ2[$i] = "#{$i}";
         $targ3[$i] = "#{$i}";
         $alts1[$i] = "val=%d";
         $alts2[$i] = "val=%d";
         $alts3[$i] = "val=%d";
     }
     $datay1 = array(20, 15, 23, 15, 80, 20, 45, 10, 5, 45, 60);
     $datay2 = array(12, 9, 12, 8, 41, 15, 30, 8, 48, 36, 14, 25, 30, 35);
     $datay3 = array(5, 17, 32, 24, 4, 2, 36, 2, 9, 24, 21, 23);
     $dateStart = '2015-03-01';
     $dateEnd = '2016-04-30';
     $numberTotalDays = $this->numberDaysBetweenTwoDates($dateStart, $dateEnd);
     $numberTotalMonths = $this->numberMonthBetweenTwoDates($dateStart, $dateEnd);
     $yearStart = $this->obtainInfoDate($dateStart, "Y");
     $monthStart = $this->obtainInfoDate($dateStart, 'n');
     $dayStart = $this->obtainInfoDate($dateStart, 'd');
     $yearEnd = $this->obtainInfoDate($dateEnd, "Y");
     $monthEnd = $this->obtainInfoDate($dateEnd, "n");
     $dayEnd = $this->obtainInfoDate($dateEnd, "d");
     $arrayDays = array();
     $result = array();
     $result[] = 0;
     $monthCount = $monthStart;
     $yearCount = $yearStart;
     $daysElapsed = 0;
     $percentaje = 0;
     $days = 0;
     $counter = 0;
     for ($i = 1; $i <= $numberTotalMonths; $i++) {
         if ($i == 1) {
             $days = $this->numberDaysFirstMonth($yearCount, $monthCount, $dayStart);
             $arrayDays[] = $monthCount . '+' . $days;
             $daysElapsed = $daysElapsed + $days;
             $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed);
             $result[] = $percentaje;
         } elseif ($i == $numberTotalMonths) {
             $days = $dayEnd;
             $arrayDays[] = $monthCount . '+' . $days;
             $daysElapsed = $daysElapsed + $days;
             $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed);
             $result[] = $percentaje;
         } else {
             $days = $this->numberDaysPerMonth($yearCount, $monthCount);
             $arrayDays[] = $monthCount . '+' . $days;
             $daysElapsed = $daysElapsed + $days;
             $percentaje = $this->calculatePercentage($numberTotalDays, $daysElapsed);
             $result[] = $percentaje;
         }
         if ($monthCount == 12) {
             $monthCount = 0;
             $yearCount++;
         }
         $monthCount++;
     }
     $stringTmp = '';
     foreach ($arrayDays as $var) {
         $stringTmp = $stringTmp . (string) $var . ' - ';
     }
     //$datay3 = $result;
     // Setup the graph
     $graph = new Graph(900, 350);
     //$graph->SetScale("textlin");
     $graph->SetScale("intlin");
     //$graph->SetYScale(0,'int');
     //$graph->SetYScale(1,'int');
     $theme_class = new UniversalTheme();
     //$numberDays = $this->numberDaysBetweenTwoDates('2013-01-01','2014-01-01');
     //$numberMonth = $this->numberMonthBetweenTwoDates('2013-01-01','2013-12-20');
     //$month = $this->obtainInfoFromDate('2013-12-20');
     //$yearStart = $this->obtainInfoDate('2013-12-20', "Y");
     //$monthStart = $this->obtainInfoDate('2013-12-20', 'm');
     //$dayStart = $this->obtainInfoDate('2013-12-20','d');
     $graph->SetTheme($theme_class);
     $graph->img->SetAntiAliasing(false);
     //$numberTotalMonths = $this->numberMonthBetweenTwoDates($dateStart, $dateEnd);
     //$monthStart = $this->obtainInfoDate($dateStart, 'n');
     //$monthEnd = $this->obtainInfoDate($dateEnd, 'n');
     $monthNames = array('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic');
     // $result = array();
     $counter = $monthStart - 1;
     $resultNames = array();
     $resultNames[] = '';
     for ($i = 0; $i < $numberTotalMonths; $i++) {
         $resultNames[] = $monthNames[$counter];
         $counter++;
         if ($counter == 12) {
             $counter = 0;
         }
     }
     $graph->title->Set('Pedidos ' . $numberTotalMonths . ' , ' . $numberTotalDays . ' , ' . $daysElapsed . ' : ' . $stringTmp . ' ; ' . $monthStart);
     //        $graph->title->Set('Evolución de pedidos ' . $numberTotalMonths . ' ' . $numberTotalDays . ' ' . $yearStart . ' ' . $monthStart . ' ' . $daysElapsed . ' ' . $percentaje . ' ' . $stringTmp);
     //$graph->title->Set('Evolución de pedidos ' . $numberTotalMonths);$arrayDays
     //$graph->title->Set('Evolución de pedidos');
     $graph->SetBox(false);
     $graph->img->SetAntiAliasing();
     $graph->yaxis->HideZeroLabel();
     $graph->yaxis->HideLine(false);
     $graph->yaxis->HideTicks(false, false);
     $graph->xgrid->Show();
     $graph->xgrid->SetLineStyle("solid");
     //$months = $this->buildArrayMonthName('2015-01-01','2016-01-01');
     //$graph->xaxis->SetTickLabels(array('Ene','Feb','Mar','Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Nov', 'Oct', 'Dic', 'Aux'));
     $graph->xaxis->SetTickLabels($resultNames);
     $graph->xgrid->SetColor('#E3E3E3');
     // Create the first line
     $p1 = new LinePlot($datay1);
     $graph->Add($p1);
     $p1->SetColor("#6495ED");
     $p1->SetLegend('Tienda 1');
     // Create the second line
     $p2 = new LinePlot($datay2);
     $graph->Add($p2);
     $p2->SetColor("#B22222");
     $p2->SetLegend('Tienda 2');
     // Create the third line
     $p3 = new LinePlot($result);
     $p3->SetColor("#FF1493");
     $p3->SetLegend('Tienda 3');
     $p3->SetCSIMTargets($targ1, $alts1);
     //-----------
     //$p3->value->SetFormat('%d');
     $p3->value->Show();
     $p3->value->SetColor('#55bbdd');
     $graph->Add($p3);
     // Standard Y-axis plot
     $lp1 = new LinePlot($datay1);
     $lp1->SetLegend('2001');
     $lp1->mark->SetType(MARK_DIAMOND);
     $lp1->mark->SetWidth(15);
     $lp1->mark->SetFillColor('orange');
     $lp1->SetCSIMTargets($targ1, $alts1);
     $graph->yaxis->title->Set('Basic Rate');
     //$graph->yaxis->title->SetFont(FF_ARIAL,FS_BOLD,10);
     //$graph->yaxis->title->SetFont(FS_NORMAL);
     $graph->yaxis->title->SetColor('black');
     $graph->Add($lp1);
     $graph->legend->SetFrameWeight(1);
     // Output line
     $graph->Stroke();
 }