function AudiogrammeTonal($with_legend = true) { $frequences = CExamAudio::$frequences; $delta = $with_legend ? 75 : 0; // Setup the graph. $this->Graph(300 + $delta, 250, "auto"); $this->SetScale("textlin", -120, 10); $this->SetMarginColor("lightblue"); // Image setup //$this->img->SetAntiAliasing(); $this->img->SetMargin(45, 20 + $delta, 30, 15); // Legend setup if ($with_legend) { $this->legend->Pos(0.02, 0.5, "right", "center"); $this->legend->SetShadow("darkgray@0.5", 3); $this->legend->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->legend->SetFillColor('white@0.3'); } else { $this->legend->Hide(); } // Title setup $this->title->SetFont(FF_ARIAL, FS_NORMAL, 10); $this->title->SetColor("darkred"); //Setup X-axis labels $this->xgrid->Show(true); $this->xgrid->SetColor("lightgray", "lightgray:1.8"); $this->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->xaxis->SetTickLabels($frequences); $this->xaxis->SetLabelSide(1); $this->xaxis->SetLabelMargin(22); // Setup Y-axis labels $this->ygrid->Show(true, true); $this->ygrid->SetColor("lightgray", "lightgray:1.8"); $this->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->yaxis->SetLabelFormatString("%ddB"); $this->yaxis->scale->ticks->Set(20, 10); $this->yaxis->scale->ticks->SupressZeroLabel(false); $this->yaxis->scale->ticks->SupressMinorTickMarks(false); // Empty plots for scale window foreach ($frequences as $value) { $datay[] = 100; } $p1 = new LinePlot($datay); $p1->SetCenter(); $this->Add($p1); }
function draw_graph($datay, $data2y, $label_x) { include_once "src/jpgraph.php"; include_once "src/jpgraph_line.php"; // A nice graph with anti-aliasing $graph = new Graph(800, 600, "auto"); $graph->img->SetMargin(40, 180, 40, 40); $graph->img->SetAntiAliasing("white"); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set("Nodes and Comment Count By Duration"); $graph->xaxis->SetTickLabels($label_x); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line if ($datay) { $p1 = new LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("blue"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Nodes Count"); $graph->Add($p1); } // ... and the second if ($data2y) { $p2 = new LinePlot($data2y); $p2->mark->SetType(MARK_STAR); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("Comments Count"); $graph->Add($p2); } // Output line $graph->Stroke(); }
//$Threads_running[] = $rs_a[$i]['Threads_running']; //Threads_cached $p1 = new LinePlot($Threads_cached); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Cached AVG:{$Threads_cached_avg}"); $graph->Add($p1); //Threads_connected $p2 = new LinePlot($Threads_connected); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("Connected AVG:{$Threads_connected_avg}"); $graph->Add($p2); //Threads_connected //$p3 = new LinePlot($Threads_created); //$p3->SetColor("orange"); //$p3->SetCenter(); //$p3->SetLegend("Threads_created AVG:$Threads_created_avg"); //$graph->Add($p3); //Threads_connected $p4 = new LinePlot($Threads_running); $p4->SetColor("green"); $p4->SetCenter(); $p4->SetLegend("Running AVG:{$Threads_running_avg}"); $graph->Add($p4); // Output line $graph->Stroke(); ?>
// Create the graph and set a scale. // These two calls are always required $graph = new Graph($width, $height); $graph->SetScale('linlin', 0, 0, 0, 11); $graph->SetMarginColor('white'); $graph->SetFrame(false); // Setup margin and titles $graph->SetMargin(40, 10, 10, 20); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTickLabels($xdata); #$graph->yaxis->SetColor('red'); // Create the linear plot $lineplot = new LinePlot($ydata); $lineplot->SetColor('red'); $lineplot->SetCenter(); $lineplot->SetWeight(2); // Two pixel wide $lineplot->mark->SetType(MARK_FILLEDCIRCLE); $lineplot->mark->SetWidth(3); $lineplot->mark->SetColor('red'); $lineplot->mark->SetFillColor('red'); $lineplot->value->format = "%.1f"; $lineplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7); $lineplot->value->Show(); // Add the plot to the graph $graph->Add($lineplot); // Display the graph #$graph->Stroke(); $graph->Stroke('../../upload/ipo.png'); #var_dump($ydata);
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380) { $t_graph_font = graph_get_font(); error_check(is_array($p_metrics) ? count($p_metrics) : 0, lang_get('cumulative') . ' ' . lang_get('by_date')); foreach ($p_metrics as $i => $vals) { if ($i > 0) { $plot_date[] = $i; $reported_plot[] = $p_metrics[$i][0]; $resolved_plot[] = $p_metrics[$i][1]; $still_open_plot[] = $p_metrics[$i][2]; } } $graph = new Graph($p_graph_width, $p_graph_height); $graph->img->SetMargin(40, 40, 40, 170); if (ON == config_get_global('jpgraph_antialias')) { $graph->img->SetAntiAliasing(); } $graph->SetScale('linlin'); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->title->Set(lang_get('cumulative') . ' ' . lang_get('by_date')); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->legend->Pos(0.05, 0.9, 'right', 'bottom'); $graph->legend->SetShadow(false); $graph->legend->SetFillColor('white'); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->SetFont($t_graph_font); $graph->yaxis->scale->ticks->SetDirection(-1); $graph->yaxis->SetFont($t_graph_font); if (FF_FONT2 <= $t_graph_font) { $graph->xaxis->SetLabelAngle(60); } else { $graph->xaxis->SetLabelAngle(90); # can't rotate non truetype fonts } $graph->xaxis->SetLabelFormatCallback('graph_date_format'); $graph->xaxis->SetFont($t_graph_font); $p1 = new LinePlot($reported_plot, $plot_date); $p1->SetColor('blue'); $p1->SetCenter(); $p1->SetLegend(lang_get('legend_reported')); $graph->Add($p1); $p3 = new LinePlot($still_open_plot, $plot_date); $p3->SetColor('red'); $p3->SetCenter(); $p3->SetLegend(lang_get('legend_still_open')); $graph->Add($p3); $p2 = new LinePlot($resolved_plot, $plot_date); $p2->SetColor('black'); $p2->SetCenter(); $p2->SetLegend(lang_get('legend_resolved')); $graph->Add($p2); if (helper_show_queries()) { $graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)'); $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8); } $graph->Stroke(); }
$p1->mark->SetFillColor("blue"); $p1->mark->SetWidth(3); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend($legend1); $graph->Add($p1); // 海の交通手段 $legend2 = mb_convert_encoding("海", "UTF-8", "eucJP-win"); $p2 = new LinePlot($data2); $p2->mark->SetType(MARK_SQUARE); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend($legend2); $graph->Add($p2); // 空の交通手段 $legend3 = mb_convert_encoding("空", "UTF-8", "eucJP-win"); $p3 = new LinePlot($data3); $p3->mark->SetType(MARK_DIAMOND); $p3->mark->SetFillColor("orange"); $p3->mark->SetWidth(6); $p3->SetColor("orange"); $p3->SetCenter(); $p3->SetLegend($legend3); $graph->Add($p3); // グラフの描画 $graph->Stroke(); ?>
// conversion $graphCon = new Graph(700, 175, 'auto'); $graphCon->img->SetMargin(40, 40, 40, 40); $graphCon->SetMarginColor('gray9'); $graphCon->SetScale('textlin'); $graphCon->xaxis->SetTickLabels($tickLabels); $graphCon->xaxis->SetFont(FF_FONT1); $graphCon->img->SetAntiAliasing(); $graphCon->SetShadow(); $graphCon->title->Set($tickLabels[0] . '(' . $yearArray[0] . ') - ' . $tickLabels[11] . '(' . $yearArray[11] . ')'); $graphCon->SetColor('cornsilk'); $graphCon->yscale->SetGrace(10, 10); foreach ($graphArray as $k => $v) { $pl = new LinePlot($v); $pl->mark->SetWidth(6); $pl->SetCenter(); $pl->SetLegend($k); $pl->value->Show(); $pl->value->SetFormat('%d'); $pl->value->SetFont(FF_FONT0); switch ($k) { case 'personal': $marker = 'blue'; $line = 'blue'; $mark = MARK_UTRIANGLE; $pl->mark->SetType($mark); $pl->mark->SetFillColor($marker); $pl->SetColor($line); $graphPer->Add($pl); break; case 'professional':
$graph->SetShadow(); $graph->title->Set("Background image"); // Use built in font $graph->title->SetFont(FF_FONT1, FS_BOLD); // Slightly adjust the legend from it's default position in the // top right corner. $graph->legend->Pos(0.05, 0.5, "right", "center"); // Create the first line $p1 = new LinePlot($datay); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("red"); $p1->mark->SetWidth(4); $p1->SetColor("blue"); $p1->SetCenter(); $p1->SetLegend("Triumph Tiger -98"); $graph->Add($p1); // ... and the second $p2 = new LinePlot($data2y); $p2->mark->SetType(MARK_STAR); $p2->mark->SetFillColor("red"); $p2->mark->SetWidth(4); $p2->SetColor("red"); $p2->SetCenter(); $p2->SetLegend("New tiger -99"); $graph->Add($p2); // Output line $graph->Stroke(); ?>
$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); $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); }
$graph->img->SetMargin(50, 50, 50, 50); $graph->SetShadow(); $graph->title->Set("Rencana Penarikan Anggaran Tahun " . $th); $graph->subtitle->Set('Kegiatan : ' . trim(nm_giat($kdgiat))); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 20); $graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, 12); $graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->xaxis->SetTickLabels($leg); $graph->legend->Pos(0.1, 0.09); $graph->legend->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->xaxis->title->Set("Bulan"); $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->legend->Pos(0.8, 0.13, "right", "center"); $bplot1 = new LinePlot($sbx_grafik_1); $bplot1->mark->SetType(MARK_FILLEDCIRCLE); $bplot1->mark->SetFillColor("red"); $bplot1->mark->SetWidth(8); $bplot1->SetColor("blue"); $bplot1->SetWeight(3); $bplot1->value->Show(); $bplot1->value->SetFont(FF_ARIAL, FS_BOLD, 15); $bplot1->value->SetAngle(30); $bplot1->SetCenter(0.4, 0.5); $bplot1->SetLegend("Rencana Penarikan (%)"); $graph->Add($bplot1); $graph->Stroke(); ?>
/* END OF POSTS GRAPH */ /* START OF TOPICS GRAPH */ $topics = $dates = array(); $result = $db->query('SELECT topics FROM ' . $db->prefix . 'stats ORDER BY date ASC') or error('Unable to fetch topic history', __FILE__, __LINE__, $db->error()); while ($temp = $db->fetch_row($result)) { $topics[] = $temp[0]; } $result = $db->query('SELECT date FROM ' . $db->prefix . 'stats ORDER BY date ASC') or error('Unable to fetch date history', __FILE__, __LINE__, $db->error()); while ($temp = $db->fetch_row($result)) { $date[] = date('j M', $temp[0]); } // A nice graph with anti-aliasing $graph = new Graph(600, 200, 'auto'); $graph->img->SetMargin(60, 20, 20, 60); $graph->img->SetAntiAliasing('black'); $graph->SetScale('textlin'); $graph->title->Set('Topic Count'); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetTickLabels($date); $graph->xaxis->SetLabelAngle(90); $topic_plot = new LinePlot($topics); $topic_plot->mark->SetType(MARK_STAR); $topic_plot->mark->SetFillColor('black'); $topic_plot->mark->SetWidth(4); $topic_plot->SetColor('red'); $topic_plot->SetCenter(); $graph->Add($topic_plot); $graph->Stroke(PUN_ROOT . 'img/stats/topics.png'); /* END OF TOPICS GRAPH */ $db->close(); exit('Finished' . "\n");
$bar1->SetColor('blue'); $bar1->SetFillColor('blue'); $bar1->SetLegend('Mail'); $bar2 = new LinePlot($data_total_virii); $bar2->SetColor('red'); $bar2->SetFillColor('red'); $bar2->SetLegend('Virii'); $bar3 = new LinePlot($data_total_spam); $bar3->SetColor('pink'); $bar3->SetFillColor('pink'); $bar3->SetLegend('Spam'); $line1 = new LinePlot($data_total_size); //$line1->SetColor('green'); $line1->SetFillColor('green'); $line1->SetLegend('Volume (' . $size_info['shortdesc'] . ')'); $line1->SetCenter(); //$abar1 = new AccBarPlot(array($bar2,$bar3)); //$gbplot = new GroupBarPlot(array($bar1,$abar1)); $graph->Add($bar1); $graph->Add($bar2); $graph->Add($bar3); //$graph->Add($gbplot); $graph->Stroke($filename); } echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">\n"; echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . MS_LOGO . "\" ALT=\"MailScanner Logo\"></TD>"; echo " <TR>\n"; // Check Permissions to see if the file has been written and that apache to read it. if (is_readable($filename)) { echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>"; } else {
$bplot2->SetCenter(0.4, 0.5); $bplot2->SetLegend("Belanja Pegawai(%)"); $graph->Add($bplot2); $bplot3 = new LinePlot($sbx_grafik_3); $bplot3->mark->SetType(MARK_FILLEDCIRCLE); $bplot3->mark->SetFillColor("brown"); $bplot3->mark->SetWidth(8); $bplot3->SetColor("orange"); $bplot3->SetWeight(3); $bplot3->value->Show(); $bplot3->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot3->value->SetAngle(30); $bplot3->SetCenter(0.4, 0.5); $bplot3->SetLegend("Belanja Barang(%)"); $graph->Add($bplot3); $bplot4 = new LinePlot($sbx_grafik_4); $bplot4->mark->SetType(MARK_FILLEDCIRCLE); $bplot4->mark->SetFillColor("#993399"); $bplot4->mark->SetWidth(8); $bplot4->SetColor("#FFFF33"); $bplot4->SetWeight(3); $bplot4->value->Show(); $bplot4->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot4->value->SetAngle(30); $bplot4->SetCenter(0.4, 0.5); $bplot4->SetLegend("Belanja Modal(%)"); $graph->Add($bplot4); $graph->Stroke(); ?>
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380) { $t_graph_font = graph_get_font(); error_check(is_array($p_metrics) ? count($p_metrics) : 0, plugin_lang_get('cumulative') . ' ' . lang_get('by_date')); if (plugin_config_get('eczlibrary') == ON) { $graph = new ezcGraphLineChart(); $graph->background->color = '#FFFFFF'; $graph->xAxis = new ezcGraphChartElementNumericAxis(); $graph->data[0] = new ezcGraphArrayDataSet($p_metrics[0]); $graph->data[0]->label = plugin_lang_get('legend_reported'); $graph->data[0]->color = '#FF0000'; $graph->data[1] = new ezcGraphArrayDataSet($p_metrics[1]); $graph->data[1]->label = plugin_lang_get('legend_resolved'); $graph->data[1]->color = '#0000FF'; $graph->data[2] = new ezcGraphArrayDataSet($p_metrics[2]); $graph->data[2]->label = plugin_lang_get('legend_still_open'); $graph->data[2]->color = '#000000'; $graph->additionalAxis[2] = $nAxis = new ezcGraphChartElementNumericAxis(); $nAxis->chartPosition = 1; $nAxis->background = '#005500'; $nAxis->border = '#005500'; $nAxis->position = ezcGraph::BOTTOM; $graph->data[2]->yAxis = $nAxis; $graph->xAxis->labelCallback = 'graph_date_format'; $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer(); $graph->xAxis->axisLabelRenderer->angle = -45; $graph->legend->position = ezcGraph::BOTTOM; $graph->legend->background = '#FFFFFF80'; $graph->driver = new ezcGraphGdDriver(); //$graph->driver->options->supersampling = 1; $graph->driver->options->jpegQuality = 100; $graph->driver->options->imageFormat = IMG_JPEG; $graph->title = plugin_lang_get('cumulative') . ' ' . lang_get('by_date'); $graph->options->font = $t_graph_font; $graph->renderToOutput($p_graph_width, $p_graph_height); } else { foreach ($p_metrics[0] as $i => $vals) { if ($i > 0) { $plot_date[] = $i; $reported_plot[] = $p_metrics[0][$i]; $resolved_plot[] = $p_metrics[1][$i]; $still_open_plot[] = $p_metrics[2][$i]; } } $graph = new Graph($p_graph_width, $p_graph_height); $graph->img->SetMargin(40, 40, 40, 170); if (ON == plugin_config_get('jpgraph_antialias')) { $graph->img->SetAntiAliasing(); } $graph->SetScale('linlin'); $graph->yaxis->SetColor("red"); $graph->SetY2Scale("lin"); $graph->SetMarginColor('white'); $graph->SetFrame(false); $graph->title->Set(plugin_lang_get('cumulative') . ' ' . lang_get('by_date')); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->legend->Pos(0.05, 0.9, 'right', 'bottom'); $graph->legend->SetShadow(false); $graph->legend->SetFillColor('white'); $graph->legend->SetLayout(LEGEND_HOR); $graph->legend->SetFont($t_graph_font); $graph->yaxis->scale->ticks->SetDirection(-1); $graph->yaxis->SetFont($t_graph_font); $graph->y2axis->SetFont($t_graph_font); if (FF_FONT2 <= $t_graph_font) { $graph->xaxis->SetLabelAngle(60); } else { $graph->xaxis->SetLabelAngle(90); # can't rotate non truetype fonts } $graph->xaxis->SetLabelFormatCallback('graph_date_format'); $graph->xaxis->SetFont($t_graph_font); $p1 = new LinePlot($reported_plot, $plot_date); $p1->SetColor('blue'); $p1->SetCenter(); $p1->SetLegend(plugin_lang_get('legend_reported')); $graph->AddY2($p1); $p3 = new LinePlot($still_open_plot, $plot_date); $p3->SetColor('red'); $p3->SetCenter(); $p3->SetLegend(plugin_lang_get('legend_still_open')); $graph->Add($p3); $p2 = new LinePlot($resolved_plot, $plot_date); $p2->SetColor('black'); $p2->SetCenter(); $p2->SetLegend(plugin_lang_get('legend_resolved')); $graph->AddY2($p2); if (helper_show_query_count()) { $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)'); $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8); } $graph->Stroke(); } }
$graph->legend->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->xaxis->title->Set("Bulan"); $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, 15); $graph->legend->Pos(0.8, 0.13, "right", "center"); $bplot1 = new LinePlot($sbx_grafik_1); $bplot1->mark->SetType(MARK_FILLEDCIRCLE); $bplot1->mark->SetFillColor("red"); $bplot1->mark->SetWidth(8); $bplot1->SetColor("blue"); $bplot1->SetWeight(3); $bplot1->value->Show(); $bplot1->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot1->value->SetAngle(10); //$bplot1->SetCenter(0.4,0.5); $bplot1->SetCenter(1, 2); $bplot1->SetLegend("Rencana Penarikan (Miliyar Rupiah)"); $graph->Add($bplot1); $bplot2 = new LinePlot($sbx_grafik_2); $bplot2->mark->SetType(MARK_FILLEDCIRCLE); $bplot2->mark->SetFillColor("yellow"); $bplot2->mark->SetWidth(8); $bplot2->SetColor("red"); $bplot2->SetWeight(3); $bplot2->value->Show(); $bplot2->value->SetFont(FF_ARIAL, FS_BOLD, 10); $bplot2->value->SetAngle(10); //$bplot2->SetCenter(0.4,0.5); $bplot1->SetCenter(1, 2); $bplot2->SetLegend("Realisasi (Miliyar Rupiah)"); $graph->Add($bplot2);
function graficar_series($eje_y, $x_label, $titulo_eje_x, $titulo_eje_y, $title, $name) { include "../jpgraph/src/jpgraph.php"; include "../jpgraph/src/jpgraph_line.php"; $graph = new Graph(820, 350); $graph->SetScale("textlin"); $graph->SetMarginColor("#FFFFFF"); $graph->img->SetMargin(80, 80, 60, 80); $graph->yaxis->SetTitleMargin(40); $graph->SetBackgroundImage("../imagenes/fondo.jpg", BGIMG_FILLFRAME); $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->xaxis->SetTickSide(SIDE_DOWN); $graph->yaxis->SetTickSide(SIDE_LEFT); $graph->yaxis->title->Set($titulo_eje_y); $graph->xaxis->title->Set($titulo_eje_x); $graph->setcolor("#EEEEEE"); $graph->setshadow("true", 3, "#aaaaaa"); $lplot = new LinePlot($eje_y); $lplot->mark->SetType(MARK_FILLEDCIRCLE); $lplot->mark->SetFillColor("red"); $lplot->value->Show(); $lplot->mark->SetWidth(3); $lplot->SetColor("blue"); $lplot->SetCenter(); $graph->Add($lplot); $graph->Stroke("charts/" . $name); }
function CResultatsLaboGraph($patient, $examen, $resultats) { $resultats = array_reverse($resultats, true); if ($examen->type != "num") { JpGraphError::raise("Le type d'examen doit être numérique pour être affiché"); } // Prepare values // Value plot $ydata = array(); $xlabels = array(); $min = $examen->min; $max = $examen->max; foreach ($resultats as $resultat) { $min = min($min, $resultat->resultat); $max = max($max, $resultat->resultat); $ydata[] = $resultat->resultat; $xlabels[] = $resultat->date ? CMbDT::transform(null, $resultat->date, "%d/%m/%y") : "attendu"; } // Setup the graph. $this->Graph(360, 250, "auto"); $delta = 2; $this->SetScale("textlin", max(0, $min - $delta), $max + $delta); $this->SetMarginColor("lightblue"); // Image setup $this->img->SetAntiAliasing(true); $this->img->SetMargin(40, 10, 30, 40); if ($examen->max) { $uband = new PlotBand(HORIZONTAL, BAND_RDIAG, $examen->max, "max", "#ffbbbb"); $uband->ShowFrame(true); $uband->SetDensity(92); $this->AddBand($uband); } if ($examen->min) { $lband = new PlotBand(HORIZONTAL, BAND_RDIAG, "min", $examen->min, "#ffbbbb"); $lband->ShowFrame(true); $lband->SetDensity(92); $this->AddBand($lband); } // Legend setup $this->legend->Pos(0.02, 0.5, "right", "center"); $this->legend->SetShadow("darkgray@0.5", 3); $this->legend->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->legend->SetFillColor("white@0.3"); // Title setup $this->title->SetFont(FF_ARIAL, FS_NORMAL, 10); $this->title->SetColor("darkred"); $this->title->Set("Résultats pour " . $examen->_view); $this->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->subtitle->SetColor("darkgray"); $this->subtitle->Set($patient->_view); // Setup X-axis labels $this->xgrid->Show(true); $this->xgrid->SetColor("lightgray", "lightgray:1.7"); $this->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->xaxis->SetLabelAlign("right", "top", "right"); $this->xaxis->SetLabelMargin(2); $this->xaxis->SetLabelAngle(45); $this->xaxis->SetTickLabels($xlabels); // Setup Y-axis labels $this->ygrid->Show(true, true); $this->ygrid->SetColor("lightgray", "lightgray:1.7"); $this->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->yaxis->scale->ticks->SupressMinorTickMarks(false); $this->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->yaxis->title->SetColor("darkred"); $this->yaxis->title->Set("valeurs en {$examen->unite}"); $this->yaxis->SetLabelMargin(4); $this->yaxis->SetTitleMargin(28); $plot = new LinePlot($ydata); $plot->SetCenter(); $plot->mark->SetType(MARK_FILLEDCIRCLE); $plot->mark->SetFillColor("gray"); $this->Add($plot); }
/** * 线图 */ function createmonthline($title, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array()) { vendor("Jpgraph.jpgraph"); vendor("Jpgraph.jpgraph_line"); $labels = $legend; //编码转化 foreach ($labels as $k => $v) { $labels[$k] = iconv('utf-8', 'gb2312', $v); } $data = $data; $graph = new Graph($width, $height, "auto"); $graph->img->SetMargin(40, 40, 40, 40); $graph->img->SetAntiAliasing(); $graph->SetScale("textlin"); $graph->SetShadow(); $graph->title->Set(iconv('utf-8', 'gb2312', "{$title}")); $graph->title->SetFont(FF_SIMSUN, FS_NORMAL, 14); $graph->SetFrame(false, '#ffffff', 0); //去掉周围的边框 $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 9); $graph->xaxis->SetTickLabels($labels); $graph->xaxis->SetLabelAngle(0); $p1 = new LinePlot($data); $p1->mark->SetType(MARK_FILLEDCIRCLE); $p1->mark->SetFillColor("#0080C0"); $p1->mark->SetWidth(4); $p1->SetColor("#000000"); $p1->SetCenter(); $graph->Add($p1); $graph->Stroke(); }
function print_graph($g, $pgwidth) { $splines = false; $bandw = false; $percent = false; $show_percent = false; $stacked = false; $h = false; $show_values = false; $hide_grid = false; $hide_y_axis = false; if (isset($g['attr']['TYPE']) && $g['attr']['TYPE']) { $type = strtolower($g['attr']['TYPE']); } if (!in_array($type, array('bar', 'horiz_bar', 'line', 'radar', 'pie', 'pie3d', 'xy', 'scatter'))) { $type = 'bar'; } // Default=bar if (isset($g['attr']['STACKED']) && $g['attr']['STACKED']) { $stacked = true; } // stacked for bar or horiz_bar if (isset($g['attr']['SPLINES']) && $g['attr']['SPLINES'] && $type == 'xy') { $splines = true; } // splines for XY line graphs if (isset($g['attr']['BANDW']) && $g['attr']['BANDW']) { $bandw = true; } // black and white if (isset($g['attr']['LEGEND-OVERLAP']) && $g['attr']['LEGEND-OVERLAP']) { $overlap = true; } // avoid overlap of Legends over graph (line, bar, horiz_bar only) if (isset($g['attr']['PERCENT']) && $g['attr']['PERCENT'] && $type != 'xy' && $type != 'scatter') { $percent = true; } // Show data series as percent of total in series if (isset($g['attr']['SHOW-VALUES']) && $g['attr']['SHOW-VALUES']) { $show_values = true; } // Show the individual data values if (isset($g['attr']['HIDE-GRID']) && $g['attr']['HIDE-GRID']) { $hide_grid = true; } // Hide the y-axis gridlines if (isset($g['attr']['HIDE-Y-AXIS']) && $g['attr']['HIDE-Y-AXIS']) { $hide_y_axis = true; } // Hide the y-axis // Antialias: If true - better quality curves, but graph line will only be 1px even in PDF 300dpi // default=true for most except line and radar if (isset($g['attr']['ANTIALIAS']) && ($g['attr']['ANTIALIAS'] == '' || $g['attr']['ANTIALIAS'] == 0)) { $antialias = false; } else { if (isset($g['attr']['ANTIALIAS']) && $g['attr']['ANTIALIAS'] > 0) { $antialias = true; } else { if ($type == 'line' || $type == 'radar') { $antialias = false; } else { $antialias = true; } } } if ($g['attr']['DPI']) { $dpi = intval($g['attr']['DPI']); } if (!$dpi || $dpi < 50 || $dpi > 2400) { $dpi = 150; } // Default dpi 150 $k = 0.2645 / 25.4 * $dpi; // mPDF 4.5.009 global $JpgUseSVGFormat; if (isset($JpgUseSVGFormat) && $JpgUseSVGFormat) { $img_type = 'svg'; $k = 1; // Overrides as Vector scale does not need DPI } else { $img_type = 'png'; } if (isset($g['attr']['TITLE']) && $g['attr']['TITLE']) { $title = $g['attr']['TITLE']; } if (isset($g['attr']['LABEL-X']) && $g['attr']['LABEL-X']) { $xlabel = $g['attr']['LABEL-X']; } // NOT IMPLEMENTED?????? if (isset($g['attr']['LABEL-Y']) && $g['attr']['LABEL-Y']) { $ylabel = $g['attr']['LABEL-Y']; } if (isset($g['attr']['AXIS-X']) && $g['attr']['AXIS-X']) { $xaxis = strtolower($g['attr']['AXIS-X']); } if (!in_array($xaxis, array('text', 'lin', 'linear', 'log'))) { $xaxis = 'text'; } // Default=text if ($xaxis == 'linear') { $xaxis = 'lin'; } if (isset($g['attr']['AXIS-Y']) && $g['attr']['AXIS-Y']) { $yaxis = strtolower($g['attr']['AXIS-Y']); } if (!in_array($yaxis, array('lin', 'linear', 'log', 'percent'))) { $yaxis = 'lin'; } // Default=lin if ($yaxis == 'percent') { $show_percent = true; $yaxis = 'lin'; } // Show percent sign on scales if ($yaxis == 'linear') { $yaxis = 'lin'; } if ($splines) { $xaxis = 'lin'; } $axes = $xaxis . $yaxis; // e.g.textlin, textlog, loglog, loglin, linlog (XY) // mPDF 4.0 if (isset($g['attr']['cWIDTH']) && $g['attr']['cWIDTH']) { $w = $g['attr']['cWIDTH'] / 0.2645; } // pixels if (isset($g['attr']['cHEIGHT']) && $g['attr']['cHEIGHT']) { $h = $g['attr']['cHEIGHT'] / 0.2645; } if (isset($g['attr']['SERIES']) && strtolower($g['attr']['SERIES']) == 'rows') { $dataseries = 'rows'; } else { $dataseries = 'cols'; } // Defaults - define data $rowbegin = 2; $colbegin = 2; if ($type == 'scatter' || $type == 'xy') { if ($dataseries == 'rows') { $rowbegin = 1; } else { $colbegin = 1; } } $rowend = 0; $colend = 0; if (isset($g['attr']['DATA-ROW-BEGIN']) && ($g['attr']['DATA-ROW-BEGIN'] === '0' || $g['attr']['DATA-ROW-BEGIN'] > 0)) { $rowbegin = $g['attr']['DATA-ROW-BEGIN']; } if (isset($g['attr']['DATA-COL-BEGIN']) && ($g['attr']['DATA-COL-BEGIN'] === '0' || $g['attr']['DATA-COL-BEGIN'] > 0)) { $colbegin = $g['attr']['DATA-COL-BEGIN']; } if (isset($g['attr']['DATA-ROW-END']) && ($g['attr']['DATA-ROW-END'] === '0' || $g['attr']['DATA-ROW-END'] != 0)) { $rowend = $g['attr']['DATA-ROW-END']; } if (isset($g['attr']['DATA-COL-END']) && ($g['attr']['DATA-COL-END'] === '0' || $g['attr']['DATA-COL-END'] != 0)) { $colend = $g['attr']['DATA-COL-END']; } $nr = count($g['data']); $nc = 0; foreach ($g['data'] as $r) { $cc = 0; foreach ($r as $c) { $cc++; } $nc = max($nc, $cc); } if ($colend == 0) { $colend = $nc; } else { if ($colend < 0) { $colend = $nc + $colend; } } if ($rowend == 0) { $rowend = $nr; } else { if ($rowend < 0) { $rowend = $nr + $rowend; } } if ($colend < $colbegin) { $colend = $colbegin; } if ($rowend < $rowbegin) { $rowend = $rowbegin; } // if ($type == 'xy' || $type=='scatter') { $colstart=0; } // Get Data + Totals $data = array(); $totals = array(); for ($r = $rowbegin - 1; $r < $rowend; $r++) { for ($c = $colbegin - 1; $c < $colend; $c++) { if (isset($g['data'][$r][$c])) { $g['data'][$r][$c] = floatval($g['data'][$r][$c]); } else { $g['data'][$r][$c] = 0; } if ($dataseries == 'rows') { $data[$r + 1 - $rowbegin][$c + 1 - $colbegin] = $g['data'][$r][$c]; $totals[$r + 1 - $rowbegin] += $g['data'][$r][$c]; } else { $data[$c + 1 - $colbegin][$r + 1 - $rowbegin] = $g['data'][$r][$c]; if (isset($totals[$c + 1 - $colbegin])) { $totals[$c + 1 - $colbegin] += $g['data'][$r][$c]; } else { $totals[$c + 1 - $colbegin] = $g['data'][$r][$c]; } } } } // PERCENT if ($percent && $type != 'pie' && $type != 'pie3d') { for ($r = 0; $r < count($data); $r++) { for ($c = 0; $c < count($data[$r]); $c++) { $data[$r][$c] = $data[$r][$c] / $totals[$r] * 100; } } } // Get Legends and labels $legends = array(); $labels = array(); $longestlegend = 0; $longestlabel = 0; if ($dataseries == 'cols') { if ($colbegin > 1) { for ($r = $rowbegin - 1; $r < $rowend; $r++) { $legends[$r + 1 - $rowbegin] = $g['data'][$r][0]; $longestlegend = max($longestlegend, strlen($g['data'][$r][0])); } } if ($rowbegin > 1) { for ($c = $colbegin - 1; $c < $colend; $c++) { $labels[$c + 1 - $colbegin] = $g['data'][0][$c]; $longestlabel = max($longestlabel, strlen($g['data'][0][$c])); } } } else { if ($dataseries == 'rows') { if ($colbegin > 1) { for ($r = $rowbegin - 1; $r < $rowend; $r++) { $labels[$r + 1 - $rowbegin] = $g['data'][$r][0]; $longestlabel = max($longestlabel, strlen($g['data'][$r][0])); } } if ($rowbegin > 1) { for ($c = $colbegin - 1; $c < $colend; $c++) { $legends[$c + 1 - $colbegin] = $g['data'][0][$c]; $longestlegend = max($longestlegend, strlen($g['data'][0][$c])); } } } } // Default sizes $defsize = array(); $defsize['pie'] = array('w' => 600, 'h' => 300); $defsize['pie3d'] = array('w' => 600, 'h' => 300); $defsize['radar'] = array('w' => 600, 'h' => 300); $defsize['line'] = array('w' => 600, 'h' => 400); $defsize['xy'] = array('w' => 600, 'h' => 400); $defsize['scatter'] = array('w' => 600, 'h' => 400); $defsize['bar'] = array('w' => 600, 'h' => 400); $defsize['horiz_bar'] = array('w' => 600, 'h' => 500); // Use default ratios if ($w && !$h) { $h = $w * $defsize[$type]['h'] / $defsize[$type]['w']; } if ($h && !$w) { $w = $h * $defsize[$type]['w'] / $defsize[$type]['h']; } if (!$h && !$w) { $w = $defsize[$type]['w']; $h = $defsize[$type]['h']; } if (count($data) > 0 && $type) { $figure_file = "graph_cache/" . rand(11111, 999999999) . "." . $img_type; if ($bandw) { $colours = array('snow1', 'black', 'snow4', 'snow3', 'snow2', 'cadetblue4', 'cadetblue3', 'cadetblue1', 'bisque4', 'bisque2', 'beige'); } else { $colours = array('cyan', 'darkorchid4', 'cadetblue3', 'khaki1', 'darkolivegreen2', 'cadetblue4', 'coral', 'cyan4', 'rosybrown3', 'wheat1'); } $fills = array('navy', 'orange', 'red', 'yellow', 'purple', 'navy', 'orange', 'red', 'yellow', 'purple'); $patterns = array(PATTERN_DIAG1, PATTERN_CROSS1, PATTERN_STRIPE1, PATTERN_DIAG3, PATTERN_CROSS2, PATTERN_DIAG2, PATTERN_DIAG4, PATTERN_CROSS3, PATTERN_CROSS4, PATTERN_STRIPE1); $markers = array(MARK_DIAMOND, MARK_SQUARE, MARK_CIRCLE, MARK_UTRIANGLE, MARK_DTRIANGLE, MARK_FILLEDCIRCLE, MARK_CROSS, MARK_STAR, MARK_X); // LEGENDS if ($type == 'pie' || $type == 'pie3d') { $graph = new PieGraph($w * $k, $h * $k); } else { if ($type == 'radar') { $graph = new RadarGraph($w * $k, $h * $k); } else { $graph = new Graph($w * $k, $h * $k); } } // mPDF 4.5.009 // $graph->img->SetImgFormat($img_type) ; // if (strtoupper($img_type)=='JPEG') { $graph->img->SetQuality(90); } if ($antialias) { $graph->img->SetAntiAliasing(); } $graph->SetShadow(true, 2 * $k); $graph->SetMarginColor("white"); // TITLE $graph->title->Set($title); $graph->title->SetMargin(10 * $k); $graph->title->SetFont(FF_USERFONT, FS_BOLD, 11 * $k); $graph->title->SetColor("black"); $graph->legend->SetLineSpacing(3 * $k); $graph->legend->SetMarkAbsSize(6 * $k); $graph->legend->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); // Set GRAPH IMAGE MARGINS if ($type == 'pie' || $type == 'pie3d') { $psize = 0.3; $pposxabs = $w / 2; $pposy = 0.55; if ($longestlegend) { // if legend showing $pposxabs -= ($longestlegend * 5 + 20) / 2; } $pposx = $pposxabs / $w; $graph->legend->Pos(0.02, 0.5, 'right', 'center'); } else { if ($type == 'radar') { $psize = 0.5; $pposxabs = $w / 2; $pposy = 0.55; if ($longestlabel) { // if legend showing $pposxabs -= ($longestlabel * 5 + 20) / 2; } $pposx = $pposxabs / $w; $graph->legend->Pos(0.02, 0.5, 'right', 'center'); } else { if ($type == 'xy' || $type == 'scatter') { $pml = 50; $pmr = 20; $pmt = 60; $pmb = 50; $xaxislblmargin = $pmb - 30; $yaxislblmargin = $pml - 15; $graph->legend->Pos(0.02, 0.1, 'right', 'top'); } else { if ($type == 'line' || $type == 'bar') { $pml = 50; $pmr = 20; $pmt = 60; $pmb = 50; $xlangle = 0; $ll = $longestlegend * 5; // 45 degrees 8pt fontsize if ($ll > 5 || $ll > 3 && count($data) > 10) { $pmb = max($pmb, $ll + 30); $xlangle = 50; } $xaxislblmargin = $pmb - 30; $yaxislblmargin = $pml - 15; if ($longestlabel && !$overlap) { // if legend showing $pmr = $longestlabel * 5 + 40; } $graph->legend->Pos(0.02, 0.1, 'right', 'top'); } else { if ($type == 'horiz_bar') { $pml = 50; $pmr = 20; $pmt = 50; $pmb = 45; $ll = $longestlegend * 6.5; // 8pt fontsize $pml = max($pml, $ll + 20); $xaxislblmargin = $pml - 20; $yaxislblmargin = $pmb - 15; if ($longestlabel && !$overlap) { // if legend showing $pmr = $longestlabel * 5 + 40; } $graph->legend->Pos(0.02, 0.1, 'right', 'top'); } } } } } // DRAW THE GRAPHS if ($type == 'pie') { $p1 = new PiePlot($data[0]); $p1->SetSliceColors($colours); if ($show_values) { $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($percent) { $p1->SetLabelType(PIE_VALUE_PERADJ); } else { $p1->SetLabelType(PIE_VALUE_ABS); } if ($percent || $show_percent) { $p1->value->SetFormat("%d%%"); } else { $p1->value->SetFormat("%s"); } // Enable and set policy for guide-lines. Make labels line up vertically $p1->SetGuideLines(true); $p1->SetGuideLinesAdjust(1.5); } else { $p1->value->Show(false); } $p1->SetLegends($legends); $p1->SetSize($psize); $p1->SetCenter($pposx, $pposy); if ($labels[0]) { $graph->subtitle->Set($labels[0]); $graph->subtitle->SetMargin(10 * $k); $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k); $graph->subtitle->SetColor("black"); } $graph->Add($p1); } else { if ($type == 'pie3d') { $p1 = new PiePlot3d($data[0]); $p1->SetSliceColors($colours); if ($show_values) { $p1->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($percent) { $p1->SetLabelType(PIE_VALUE_PERADJ); } else { $p1->SetLabelType(PIE_VALUE_ABS); } if ($percent || $show_percent) { $p1->value->SetFormat("%d%%"); } else { $p1->value->SetFormat("%s"); } } else { $p1->value->Show(false); } $p1->SetLegends($legends); $p1->SetEdge(); $p1->SetSize($psize); $p1->SetCenter($pposx, $pposy); if ($labels[0]) { $graph->subtitle->Set($labels[0]); $graph->subtitle->SetMargin(10 * $k); $graph->subtitle->SetFont(FF_USERFONT, FS_BOLD, 11 * $k); $graph->subtitle->SetColor("black"); } $graph->Add($p1); } else { if ($type == 'radar') { $graph->SetSize($psize); $graph->SetPos($pposx, $pposy); $graph->SetTitles($legends); // labels each axis $graph->axis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->axis->title->SetMargin(5 * $k); $graph->axis->SetWeight(1 * $k); $graph->axis->HideLabels(); $graph->axis->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k); $graph->HideTickMarks(); $group = array(); foreach ($data as $series => $dat) { $rdata = array(); foreach ($data[$series] as $row) { $rdata[] = $row; } if (count($rdata) < 3) { die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points."); } // Create the radar plot $bplot = new RadarPlot($rdata); $bplot->mark->SetType($markers[$series]); $bplot->mark->SetFillColor($colours[$series]); $bplot->mark->SetWidth(3 * $k); $bplot->SetColor($colours[$series]); if ($series == 0) { $bplot->SetFillColor('lightred'); } else { $bplot->SetFill(false); } $bplot->SetLineWeight(1 * $k); $bplot->SetLegend($labels[$series]); if ($bandw) { $bplot->SetShadow("gray5"); } $graph->Add($bplot); } } else { if ($type == 'line') { // Setup the graph. $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k); // LRTB $graph->SetScale($axes); $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($ylabel) { $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->yaxis->SetTitle($ylabel, 'middle'); $graph->yaxis->SetTitleMargin($yaxislblmargin * $k); } $graph->yaxis->SetLabelMargin(4 * $k); if ($percent || $show_percent) { $graph->yaxis->SetLabelFormat('%d%%'); } // Percent // Show 0 label on Y-axis (default is not to show) $graph->yscale->ticks->SupressZeroLabel(true); if ($hide_y_axis) { $graph->yaxis->Hide(); } if ($hide_grid) { $graph->ygrid->Show(false); } // Setup X-axis labels $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTickLabels($legends); $graph->xaxis->SetLabelAngle($xlangle); $graph->xaxis->SetLabelMargin(4 * $k); // X-axis title if ($xlabel) { $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTitle($xlabel, 'middle'); $graph->xaxis->SetTitleMargin($xaxislblmargin * $k); } foreach ($data as $series => $rdata) { $bplot = new LinePlot($rdata); $bplot->mark->SetType($markers[$series]); $bplot->mark->SetFillColor($colours[$series]); $bplot->mark->SetWidth(4 * $k); if ($show_values) { $bplot->value->Show(); // Not if scatter $bplot->value->SetMargin(6 * $k); $bplot->value->SetColor("darkred"); $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($percent || $show_percent) { $bplot->value->SetFormat('%d%%'); } else { $bplot->value->SetFormat("%s"); } } // Set color for each line $bplot->SetColor($colours[$series]); $bplot->SetWeight(2 * $k); $bplot->SetLegend($labels[$series]); if ($bandw) { $bplot->SetShadow("gray5"); } // Indent the X-scale so the first and last point doesn't fall on the edges $bplot->SetCenter(); $graph->Add($bplot); } } else { if ($type == 'xy' || $type == 'scatter') { // Setup the graph. $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k); // LRTB $graph->SetScale($axes); // Setup font for axis $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); // Y-axis title if ($labels[1]) { $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->yaxis->SetTitleMargin($yaxislblmargin * $k); $graph->yaxis->SetTitle($labels[1], 'middle'); } $graph->yaxis->SetLabelMargin(4 * $k); if ($percent || $show_percent) { $graph->yaxis->SetLabelFormat('%d%%'); } // Percent // Show 0 label on Y-axis (default is not to show) $graph->yscale->ticks->SupressZeroLabel(true); // Just let the maximum be autoscaled $graph->yaxis->scale->SetAutoMin(0); if ($hide_y_axis) { $graph->yaxis->Hide(); } if ($hide_grid) { $graph->ygrid->Show(false); } // Setup X-axis labels $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); // mPDF 2.5 Corrects labelling of x-axis // $graph->xaxis->SetTickLabels($legends); $graph->xaxis->SetLabelAngle(50); $graph->xaxis->SetLabelMargin(4 * $k); // X-axis title if ($labels[0]) { $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTitleMargin($xaxislblmargin * $k); $graph->xaxis->SetTitle($labels[0], 'middle'); } // Create the bar plot // SPLINES if ($splines && $type == 'xy') { $spline = new Spline($data[0], $data[1]); list($newx, $newy) = $spline->Get(100); } else { $newx = $data[0]; $newy = $data[1]; } if ($type == 'xy') { // LINE PLOT $bplot = new LinePlot($newy, $newx); // Set color for each line $bplot->SetColor($fills[0]); $bplot->SetWeight(4 * $k); if ($bandw) { $bplot->SetShadow("gray5"); } $graph->Add($bplot); } // SCATTER PLOT $cplot = new ScatterPlot($data[1], $data[0]); $cplot->mark->SetType($markers[0]); $cplot->mark->SetFillColor($fills[0]); $cplot->mark->SetWidth(8 * $k); if ($show_values) { // mPDF 2.5 if ($type == 'xy') { $cplot->value->Show(); } // Not if scatter $cplot->value->SetMargin(8 * $k); $cplot->value->SetColor("darkred"); $cplot->value->SetFont(FF_USERFONT, FS_NORMAL, 6 * $k); if ($percent || $show_percent) { $cplot->value->SetFormat('%d%%'); } else { $cplot->value->SetFormat("%s"); } } // Set color for each line $cplot->SetColor($fills[0]); $cplot->SetWeight(4 * $k); if ($bandw) { $cplot->SetShadow("gray5"); } $graph->Add($cplot); } else { if ($type == 'bar') { // Setup the graph. $graph->img->SetMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k); // LRTB $graph->SetScale($axes); // Setup y-axis $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($hide_y_axis) { $graph->yaxis->Hide(); } if ($hide_grid) { $graph->ygrid->Show(false); } $graph->yaxis->SetLabelMargin(4 * $k); if ($ylabel) { $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->yaxis->SetTitle($ylabel, 'middle'); $graph->yaxis->SetTitleMargin($yaxislblmargin * $k); } // Show 0 label on Y-axis (default is not to show) $graph->yscale->ticks->SupressZeroLabel(false); // Setup X-axis labels $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTickLabels($legends); $graph->xaxis->SetLabelAngle($xlangle); $graph->xaxis->SetLabelMargin(4 * $k); // X-axis title if ($xlabel) { $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTitle($xlabel, 'middle'); $graph->xaxis->SetTitleMargin($xaxislblmargin * $k); } $group = array(); foreach ($data as $series => $dat) { $rdata = array(); foreach ($data[$series] as $row) { $rdata[] = $row; } // Create the bar plot $bplot = new BarPlot($rdata); $bplot->SetWidth(0.6); // for SINGLE?? // Setup color for gradient fill style if ($bandw) { $bplot->SetPattern($patterns[$series]); } else { $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION); } // Set color for the frame of each bar $bplot->SetColor("darkgray"); $bplot->SetLegend($labels[$series]); if ($bandw) { $bplot->SetShadow("gray5"); } if ($show_values) { $bplot->value->Show(); $bplot->value->SetMargin(6 * $k); $bplot->value->SetColor("darkred"); $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($percent || $show_percent) { $bplot->value->SetFormat('%d%%'); } else { $bplot->value->SetFormat("%s"); } } $group[] = $bplot; } if (count($data) == 1) { $graph->Add($group[0]); } else { // Create the grouped bar plot if ($stacked) { $gbplot = new AccBarPlot($group); } else { $gbplot = new GroupBarPlot($group); } $graph->Add($gbplot); } } else { if ($type == 'horiz_bar') { $graph->SetScale($axes); $graph->Set90AndMargin($pml * $k, $pmr * $k, $pmt * $k, $pmb * $k); // LRTB // Setup y-axis $graph->yaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->yaxis->SetLabelMargin(4 * $k); $graph->yaxis->SetPos('max'); // Intersect at top of x-axis i.e. y axis is at bottom // First make the labels look right $graph->yaxis->SetLabelAlign('center', 'top'); if ($percent || $show_percent) { $graph->yaxis->SetLabelFormat('%d%%'); } $graph->yaxis->SetLabelSide(SIDE_RIGHT); $graph->yaxis->scale->SetGrace(10); // sets 10% headroom if ($hide_y_axis) { $graph->yaxis->Hide(); } if ($hide_grid) { $graph->ygrid->Show(false); } // The fix the tick marks $graph->yaxis->SetTickSide(SIDE_LEFT); if ($ylabel) { $graph->yaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->yaxis->SetTitle($ylabel, 'middle'); $graph->yaxis->SetTitleMargin($yaxislblmargin * $k); // Finally setup the title $graph->yaxis->SetTitleSide(SIDE_RIGHT); // To align the title to the right use : $graph->yaxis->title->Align('right'); $graph->yaxis->title->SetAngle(0); } // Show 0 label on Y-axis (default is not to show) $graph->yscale->ticks->SupressZeroLabel(false); // Setup X-axis labels $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->title->SetAngle(90); $graph->xaxis->SetTickLabels($legends); $graph->xaxis->SetLabelMargin(4 * $k); // X-axis title if ($xlabel) { $graph->xaxis->title->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); $graph->xaxis->SetTitleMargin($xaxislblmargin * $k); $graph->xaxis->SetTitle($xlabel, 'middle'); } $group = array(); foreach ($data as $series => $dat) { $rdata = array(); foreach ($data[$series] as $row) { $rdata[] = $row; } // Create the bar pot $bplot = new BarPlot($rdata); $bplot->SetWidth(0.6); // for SINGLE?? // Setup color for gradient fill style if ($bandw) { $bplot->SetPattern($patterns[$series]); } else { $bplot->SetFillGradient($fills[$series], "#EEEEEE", GRAD_LEFT_REFLECTION); } // Set color for the frame of each bar $bplot->SetColor("darkgray"); $bplot->SetLegend($labels[$series]); if ($bandw) { $bplot->SetShadow("gray5"); } if ($show_values) { $bplot->value->Show(); $bplot->value->SetMargin(6 * $k); $bplot->value->SetColor("darkred"); $bplot->value->SetFont(FF_USERFONT, FS_NORMAL, 8 * $k); if ($percent || $show_percent) { $bplot->value->SetFormat('%d%%'); } else { $bplot->value->SetFormat("%s"); } } $group[] = $bplot; } if (count($data) == 1) { $graph->Add($group[0]); } else { // Create the grouped bar plot if ($stacked) { $gbplot = new AccBarPlot($group); } else { $gbplot = new GroupBarPlot($group); } $graph->Add($gbplot); } } } } } } } } if ($graph) { $graph->Stroke(_MPDF_PATH . $figure_file); $srcpath = str_replace("\\", "/", dirname(__FILE__)) . "/"; $srcpath .= $figure_file; return array('file' => $srcpath, 'w' => $w, 'h' => $h); } } return false; }
/** * Draw the XY type plot * * @param array $data plot data array reference * @param array $xmlArr xml array reference * @return object refernce XY plot object reference */ public function renderXYPlot(&$data, &$xmlArr) { $id = $xmlArr['ATTRIBUTES']['ID']; $field = $xmlArr['ATTRIBUTES']['FIELD']; $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE']; $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE']; $weight = $xmlArr['ATTRIBUTES']['WEIGHT']; $color = $xmlArr['ATTRIBUTES']['COLOR']; $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR']; $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE']; $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD']; $visible = $xmlArr['ATTRIBUTES']['VISIBLE']; if ($chartType == 'Line' or $chartType == 'Bar') { if ($chartType == 'Line') { include_once JPGRAPH_DIR . '/jpgraph_line.php'; $plot = new LinePlot($data); $this->_drawMark($plot->mark, $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']); $plot->SetBarCenter(); $plot->SetCenter(); } else { if ($chartType == 'Bar') { include_once JPGRAPH_DIR . '/jpgraph_bar.php'; $plot = new BarPlot($data); $plot->SetAlign('center'); } } if ($color) { $plot->SetColor($color); } if ($fillColor) { $plot->SetFillColor($fillColor); } if ($weight) { $plot->SetWeight($weight); } if ($showVal == 1) { $plot->value->Show(); } if ($legend) { $plot->SetLegend($legend); } $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']); } if ($chartType == 'GroupBar' or $chartType == 'AccBar') { $children = $xmlArr['ATTRIBUTES']['CHILDREN']; $childList = explode(",", $children); foreach ($childList as $child) { $childPlotList[] = $this->m_PlotList[$child]; } if ($chartType == 'GroupBar') { $plot = new GroupBarPlot($childPlotList); } else { if ($chartType == 'AccBar') { $plot = new AccBarPlot($childPlotList); } } } $this->m_PlotList[$id] = $plot; if ($visible == 1) { return $plot; } return null; }
function getLastYearPlot($re, $an, $art = false) { $employee = $_SESSION["login"]; $keys = array_keys($re); $sum = array(); $avg = array(); $monate = array(); $gut = array(); if ($re) { foreach ($re as $month) { if ($month["summe"] < 0) { $gut[] = $month["summe"] * -1; $sum[] = 0; $avg[] = 0; } else { $sum[] = $month["summe"]; $gut[] = 0; if ($month["count"] > 0) { $avg[] = $month["summe"] / $month["count"]; } else { $avg[] = 0; } } } } if ($an) { foreach ($an as $month) { $sumA[] = $month["summe"]; } } if ($keys) { foreach ($keys as $m) { $monate[] = substr($m, 4, 2); } } $monate = array_splice($monate, 0, -1); $sum = array_splice($sum, 0, -1); $gut = array_splice($gut, 0, -1); if (!empty($sumA)) { $sumA = array_splice($sumA, 0, -1); } else { $sumA[] = 0; } $avg = array_splice($avg, 0, -1); $graph = new Graph(520, 320); if ($art) { $art = "textlin"; } else { $art = "textlog"; } $graph->SetScale($art); $graph->img->SetMargin(65, 10, 10, 90); $sumplot = new BarPlot($sum); // Graph Umsatz $sumplot->SetColor("darkgreen"); $sumplot->SetWidth(1.0); $sumplot->SetAlign("center"); //$sumplot->SetCenter(true); //$sumplot->mark->SetType(MARK_CIRCLE); $sumplot->SetLegend("Gesamtumsatz"); $graph->Add($sumplot); $avgplot = new BarPlot($avg); // Graph durchn. Umsatz $avgplot->SetColor("darkred"); $avgplot->SetFillColor("red"); $avgplot->SetWidth(0.5); $avgplot->SetAlign("center"); //$avgplot->SetStyle("dashed"); //$avgplot->SetCenter(true); $avgplot->SetLegend("duchschnitt"); $graph->Add($avgplot); if (empty($gut)) { $gut[] = 0; } $gutplot = new BarPlot($gut); // Graph Umsatz $gutplot->SetColor("darkgreen"); $gutplot->SetFillColor("green"); $gutplot->SetWidth(0.2); $gutplot->SetAlign("center"); //$sumplot->SetCenter(true); //$sumplot->mark->SetType(MARK_CIRCLE); $gutplot->SetLegend("Gutschrift"); $graph->Add($gutplot); $angbplot = new LinePlot($sumA); // Graph Angebote $angbplot->SetColor("darkblue"); //$angbplot->SetStyle("dashed"); $angbplot->SetCenter(true); $angbplot->mark->SetType(MARK_FILLEDCIRCLE); $angbplot->mark->SetWidth(4); $angbplot->mark->SetFillColor("yellow"); //$angbplot->mark->SetType(MARK_CIRCLE); $angbplot->SetLegend("Angbote"); $graph->Add($angbplot); $graph->yaxis->title->SetFont(FONTART, FONTSTYLE); $graph->xaxis->title->SetFont(FONTART, FONTSTYLE); $graph->yaxis->SetFont(FONTART, FONTSTYLE); $graph->xaxis->SetFont(FONTART, FONTSTYLE); $graph->xaxis->title->Set("Monate"); $graph->yaxis->title->Set("Euro"); $graph->yaxis->SetTitleMargin(50); $graph->xaxis->SetTickLabels($monate); $graph->legend->Pos(0.03, 0.9, "left", "center"); $IMG = 'tmp/' . $employee . '.png'; @exec('rm ' . $IMG); $graph->Stroke($IMG); return $IMG; }