function _stats_build_graph($data, $labels, $filename, $stat, $width, $height, $vars) { if (file_exists($filename)) { unlink($filename); } $data_orig = $data; foreach ($data as $key => $val) { if (!is_numeric($val)) { $data[$key] = 0; } } // $vars["color_tab_black"] $bg_grey = _stats_color($vars["bg_grey"], 0); $bg_light_blue = _stats_color($vars["bg_light_blue"], 25); $graph = new Graph($width, $height); $group = new PlotGroup(); $group->setSpace(2, 2); $group->grid->setType(LINE_DASHED); $group->grid->hideVertical(TRUE); $group->setPadding(30, 10, 25, 20); $graph->setBackgroundColor($bg_grey); $graph->title->set($stat); $graph->title->setFont(new Tuffy(10)); $plot = new BarPlot($data, 1, 1, 0); $plot->setBarColor($bg_light_blue); $plot->label->set($data_orig); $plot->label->move(0, -5); $group->add($plot); $group->axis->bottom->setLabelText($labels); $group->axis->bottom->hideTicks(TRUE); $graph->add($group); $graph->draw($filename); }
public function draw($format = false) { /* Make sure we have GD support. */ if (!function_exists('imagecreatefromjpeg')) { die; } if ($format === false) { $format = IMG_PNG; } $group = new PlotGroup(); $graph = new Graph($this->width, $this->height); $graph->setFormat($format); $graph->setBackgroundColor(new Color(0xf4, 0xf4, 0xf4)); $graph->shadow->setSize(3); $graph->title->set($this->title); $graph->title->setFont(new Tuffy(10)); $graph->title->setColor(new Color(0x0, 0x0, 0x8b)); $graph->border->setColor(new Color(187, 187, 187, 15)); $plot = new BarPlot($this->xValues); $plot->setBarColor(new $this->color()); $plot->barBorder->hide(true); $plot->setBarGradient(new LinearGradient(new $this->color(), new White(), 0)); $plot->setBarPadding(0.2, 0.2); $group->axis->bottom->setLabelText($this->xLabels); $group->axis->bottom->label->setFont(new Tuffy(8)); $plot2 = new LinePlot($this->xValues, LinePlot::MIDDLE); $plot2->setColor(new DarkBlue()); $plot2->setThickness(1); if (GRAPH_TREND_LINES) { $group->add($plot2); } $group->add($plot); $graph->add($group); $graph->draw(); }
function Artichow_Histogram($Name, $File, $Lines, $Labels, $Colors) { #----------------------------------------------------------------------------- $Graph = new Graph(800, 500); $Graph->setDriver('gd'); $Graph->setAntiAliasing(TRUE); $Graph->title->set($Name); $Graph->title->move(0, -5); $Graph->border->hide(); $Graph->setBackgroundGradient(new LinearGradient(new Color(240, 240, 240, 0), new White(), 0)); #----------------------------------------------------------------------------- $Group = new PlotGroup(); $Group->grid->hide(FALSE); $Group->setBackgroundColor(new Color(240, 240, 240)); $Group->setSpace(2, 2, 20, 0); $Group->setPadding(60, 10, NULL, NULL); #----------------------------------------------------------------------------- foreach ($Lines as $LineID => $Value) { #--------------------------------------------------------------------------- $Legend = $Value['Name']; unset($Value['Name']); #--------------------------------------------------------------------------- $Plot = new BarPlot($Value, 1, 1, 0); $Plot->barShadow->setPosition(Shadow::RIGHT_TOP); $Plot->barShadow->setColor(new Color(160, 160, 160, 10)); $Color = Color_RGB_Explode($Colors[$LineID]); $Plot->setBarColor(new Color($Color['R'], $Color['G'], $Color['B'], 56)); #--------------------------------------------------------------------------- $Group->add($Plot); $Group->legend->add($Plot, $Legend, Legend::BACKGROUND); } #----------------------------------------------------------------------------- $Group->axis->bottom->setLabelText($Labels); $Group->axis->bottom->hideTicks(TRUE); #----------------------------------------------------------------------------- $Group->legend->shadow->setSize(4); $Group->legend->setAlign(Legend::BOTTOM); $Group->legend->setSpace(5); $Group->legend->setTextFont(new Tuffy(8)); $Group->legend->setPosition(0.3, 0.2); $Group->setPadding(50, 10, 50, 30); $Group->legend->setBackgroundColor(new Color(255, 255, 255, 25)); #----------------------------------------------------------------------------- $Graph->add($Group); #----------------------------------------------------------------------------- $Graph->draw($File); #----------------------------------------------------------------------------- return TRUE; }
$group->axis->bottom->title->set($_REQUEST["xtitle"]); } if (!empty($_REQUEST["ytitle"])) { $group->axis->left->title->set($_REQUEST["ytitle"]); } $group->axis->bottom->title->move(6, -6); $group->axis->bottom->setTitleAlignment(LABEL_RIGHT); $group->axis->left->title->move(-2, -4); $group->axis->left->setTitleAlignment(LABEL_TOP); } $group->add($plot); $group->axis->bottom->setLabelText($keys); $group->axis->bottom->hideTicks(TRUE); if (count($data2) > 0 and $type != "baraccumulate") { $plot = new BarPlot($data2, 2, 2); $plot->setBarColor(new Color(255, 187, 0, 20)); $plot->setBarPadding(0.15, 0.15); $plot->label->set($data2); $plot->label->move(0, -5); $group->add($plot); } $graph->add($group); } else { if ($type == "pie") { require INCLUDE_PATH . "/Pie.class.php"; $graph = new Graph($width, $height); $graph->title->set($title); $graph->title->setFont(new Tuffy(11)); $colors = array(new Color(102, 205, 0), new Color(122, 197, 205), new Color(238, 197, 145), new Color(238, 180, 34), new LightOrange(), new LightPurple(), new LightBlue(), new LightRed(), new LightPink()); $plot = new Pie($data, $colors); $plot->setCenter(0.4, 0.55);
$plot->setBarPadding(0.1, 0.1); $plot->setBarSpace(0); $plot->barShadow->setSize(0); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $plot->label->move(0, -6); $plot->label->setFont(new Tuffy(7)); $plot->label->setAngle(90); $plot->label->setAlign(NULL, LABEL_TOP); $plot->label->setPadding(3, 1, 0, 6); $plot->setBarColor($colors[2]); $plot->setBarSize(0.60); $plot->setYAxis(PLOT_LEFT); $plot->setYMax("20"); $group->add($plot); if ($k == 1) $group->legend->add($plot, $legendy2, LEGEND_BACKGROUND); $k++; } $group->axis->left->setColor($blue); $group->axis->left->setNumberByTick('minor','major', 1); $group->axis->left->title->set("Note"); $group->axis->left->setLabelNumber("11");
<?php require_once '../../BarPlot.class.php'; $graph = new Graph(600, 200); $graph->setAntiAliasing(TRUE); $values = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0); $plot = new BarPlot($values); $plot->setBarColor(new Color(234, 236, 255)); $plot->setSpace(5, 5, NULL, NULL); $plot->barShadow->setSize(3); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $mois = array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Juil', 'Août', 'Sept', 'Oct', 'Nov', 'Déc'); $label = array(); foreach ($mois as $m) { $label[] = $m; } $label[] = ' '; foreach ($mois as $m) { $label[] = $m; } $plot->xAxis->setLabelText($label); /* ICI */ $max = array_max($values); $yValues = array(); for ($i = 0; $i <= $max; $i++) { $yValues[] = $i; } $plot->yAxis->setLabelText($yValues); // Image::drawError(var_export($yValues, TRUE));
require_once "../BarPlot.class.php"; $graph = new Graph(400, 400); // Set a title to the graph $graph->title->set('The title'); // Change graph background color $graph->setBackgroundColor(new Color(230, 230, 230)); $values = array(8, 2, 6, 1, 3, 5); // Declare a new BarPlot $plot = new BarPlot($values); // Reduce padding around the plot $plot->setPadding(NULL, NULL, NULL, 20); // Reduce plot size and move it to the bottom of the graph $plot->setSize(1, 0.96); $plot->setCenter(0.5, 0.52); // Set a background color to the plot $plot->grid->setBackgroundColor(new White()); // Set a dashed grid $plot->grid->setType(LINE_DASHED); $plot->label->set($values); $plot->label->move(0, -10); $plot->label->setColor(new DarkBlue()); // Set a shadow to the bars $plot->barShadow->setSize(2); // Bar size is at 60% $plot->setBarSize(0.6); // Change the color of the bars $plot->setBarColor(new Orange(15)); // Add the plot to the graph $graph->add($plot); // Draw the graph $graph->draw();
$group->axis->left->setColor($darkColor[0]); $group->axis->left->label->setColor($darkColor[0]); $group->axis->right->setColor($darkColor[1]); $group->axis->right->label->setColor($darkColor[1]); $group->setBackgroundGradient(new LinearGradient(new Color(225, 225, 225), new Color(255, 255, 255), 0)); for ($n = 0; $n < 2; $n++) { $x = array(); for ($i = 0; $i < 4; $i++) { $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0) + 1; } $plot = new BarPlot($x, $n + 1, 2); $plot->barBorder->setColor(new Color(0, 0, 0, 30)); $plot->setBarPadding(0.1, 0.1); $plot->setBarSpace(5); $plot->barShadow->setSize(3); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $plot->label->set($x); $plot->label->move(0, -6); $plot->label->setFont(new Tuffy(7)); $plot->label->setAngle(90); $plot->label->setAlign(NULL, LABEL_TOP); $plot->label->setPadding(3, 1, 0, 6); $plot->label->setCallbackFunction("labelFormat"); $plot->setBarColor($colors[$n]); $plot->setYAxis($axis[$n]); $group->add($plot); } $graph->add($group); $graph->draw();
<?php /* * This work is hereby released into the Public Domain. * To view a copy of the public domain dedication, * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../BarPlot.class.php"; $graph = new Graph(400, 400); $graph->title->set('Two bars'); $values = array(12, 8, 13, 2, 4); $group = new PlotGroup(); $group->setPadding(NULL, NULL, 35, NULL); $plot = new BarPlot($values, 1, 2); $plot->setBarColor(new LightBlue(25)); $plot->setBarSpace(5); $group->add($plot); $values = array(1, 7, 2, 10, 6); $plot = new BarPlot($values, 2, 2); $plot->setBarColor(new LightOrange(25)); $plot->setBarSpace(5); $group->add($plot); $graph->add($group); $graph->draw();
$plot->setBarPadding(0.1, 0.1); $plot->setBarSpace(0); $plot->barShadow->setSize(4); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $plot->label->move(0, -6); $plot->label->setFont(new Tuffy(7)); $plot->label->setAngle(90); $plot->label->setAlign(NULL, LABEL_TOP); $plot->label->setPadding(3, 1, 0, 6); $plot->setBarColor($colors[$k], 50); $plot->setBarSize(0.60); $plot->setYAxis(PLOT_LEFT); $plot->setYMax("20"); $group->add($plot); $group->legend->add($plot, $legendy[$k], LEGEND_BACKGROUND); $k++; } $group->axis->left->setColor($blue); $group->axis->left->setNumberByTick('minor','major', 1); $group->axis->left->title->set("Note"); $group->axis->left->setLabelNumber("11");
<?php /* * This work is hereby released into the Public Domain. * To view a copy of the public domain dedication, * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../BarPlot.class.php"; $graph = new Graph(400, 400); $graph->title->set('Two bars with depth'); $group = new PlotGroup(); $group->setPadding(NULL, NULL, 35, NULL); $group->setSpace(5, 5, NULL, NULL); $group->grid->hide(TRUE); $values = array(1, 7, 2, 10, 6, 3, 4, 7); $plot = new BarPlot($values, 1, 1, 5); $plot->setBarColor(new LightBlue(25)); $group->add($plot); $values = array(12, 8, 13, 2, 4, 8, 4, 3); $plot = new BarPlot($values, 1, 1, 0); $plot->setBarColor(new LightRed(25)); $group->add($plot); $graph->add($group); $graph->draw();
$plot->setBarSize($bw); $plot->setYAxis(PLOT_RIGHT); $plot->setYMin($qty_min); $plot->setYMax($qty_max); $grp->add($plot); if (isset($val_ret)) { $plot = new BarPlot($val_ret, 2, 2, 0); $plot->setBarColor(make_color('ret_color', 'FFEEEE')); $plot->setBarSize($bw); $plot->setYAxis(PLOT_RIGHT); $plot->setYMin($qty_min); $plot->setYMax($qty_max); $grp->add($plot); } $plot = new BarPlot($val_retprv, 1, 2, 0); $plot->setBarColor(make_color('retprv_color', 'FFFAFA')); $plot->setBarSize($bw); $plot->setYAxis(PLOT_RIGHT); $plot->setYMin($qty_min); $plot->setYMax($qty_max); $grp->add($plot); if ($val_prv) { foreach ($val_prv as $k => $v) { $xkeys[$k] = $k + 0.5; } //for ($i=0;isset($val_prv[$i]);$i++) $xkeys[$i]=$i+.5; $plot = new ScatterPlot(array_values($val_prv), array_values($xkeys)); $plot->link(TRUE, make_color('prv_color', '40FFFF')); $plot->mark->setSize(make_num('prv_mark', 10)); $plot->mark->setFill(make_color('prv_markcolor', 'F0F0F0')); $plot->setThickness(make_num('prv_thick', 5));
function dis_chart_bar_multiple($chart) { global $chart_colors; $title = $chart["title"]; $xlabels = $chart["xlabels"]; $values = $chart["plots"]["values"]; $labels = $chart["plots"]["labels"]; $legends = $chart["plots"]["legends"]; $new_bar = $chart["plots"]["new_bar"]; $graph = new Graph(600, 250); $graph->setAntiAliasing(TRUE); $graph->setBackgroundColor(new Color(240, 240, 240)); $group = new PlotGroup; $group->grid->hideVertical(); $group->setPadding(45, 22 ,30, 40); $group->setSpace(3, 3, NULL, NULL); $group->legend->setAlign(NULL, LEGEND_TOP); $group->legend->setPosition(1,0); // X axis Labels infos $xlabel = new Label($xlabels); $group->axis->bottom->setlabelText($xlabels); // Title infos if ($title != "") { $graph->title->set("$title"); } $num = 0; $nb_bars = array_sum($new_bar); $num_bar = 0; // $num_plot is the plot number // $num_bar is the bar number (1 bar can cumul more than one plot) foreach ($values as $num_plot => $plot_values) { // Chart infos : colors, size, shadow if ($new_bar[$num_plot] == 1) { $num_bar++; } $plot = new BarPlot($plot_values, $num_bar, $nb_bars); $plot->setBarColor(new Color($chart_colors[$num_plot][0], $chart_colors[$num_plot][1], $chart_colors[$num_plot][2])); $plot->setBarSize(0.6); if ($new_bar[$num_plot] == 1) { $plot->barShadow->setSize(2); $plot->barShadow->smooth(TRUE); // Labels infos $label = new Label($labels[$num_plot]); $label->setFont(new Tuffy(8)); $label->setAlign(NULL, LABEL_TOP); $plot->label = $label; } $group->add($plot); $group->legend->add($plot, utf8_decode($legends[$num_plot]), LEGEND_BACKGROUND); } $graph->add($group); $graph->draw(); }
<?php /* * This work is hereby released into the Public Domain. * To view a copy of the public domain dedication, * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../BarPlot.class.php"; $graph = new Graph(400, 400); $graph->title->set('The title'); $graph->border->setStyle(LINE_DASHED); $graph->border->setColor(new DarkGray()); $values = array(19, 42, 15, -25, 3); $plot = new BarPlot($values); $plot->setSize(1, 0.96); $plot->setCenter(0.5, 0.52); $plot->setBarColor(new VeryLightPurple(25)); $graph->add($plot); $graph->draw();
$group = new PlotGroup(); $group->setSpace(5, 5, 15, 15); $group->setPadding(40, 40, 25, 25); $group->axis->left->setLabelPrecision(2); for ($n = 0; $n < 4; $n++) { $x = array(); for ($i = 0; $i < 6; $i++) { $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(700, 1300) / 1000 - 0.5) * ($n % 2 ? -0.5 : 1) + ($n % 2 ? -0.4 : 0) + 0.3; } $plot = new BarPlot($x, floor($n / 2) + 1, 2, ($n % 2 === 0) * 6); $plot->barBorder->setColor(color()); $plot->setBarSpace(12); $plot->barShadow->setSize(4); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $plot->label->set($x); $plot->label->move(0, -12); $plot->label->setFont(new Font1()); $plot->label->setAngle(90); $plot->label->setInterval(2); $plot->label->setAlign(NULL, LABEL_TOP); $plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0)); $plot->label->border->setColor(new Color(20, 20, 20, 20)); $plot->label->setPadding(3, 1, 1, 0); $plot->label->setCallbackFunction("labelFormat"); $plot->setBarColor(color(5)); $group->add($plot); } $graph->add($group); $graph->draw();
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../BarPlot.class.php"; $graph = new Graph(400, 300); $graph->setTiming(TRUE); $graph->setAntiAliasing(TRUE); $x = array(); for ($i = 0; $i < 7; $i++) { $x[] = mt_rand(-20, 100); } $y = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'); $plot = new BarPlot($x); $plot->setSpace(6, 6, 10, 10); $plot->setBarColor(new Color(100, 100, 100, 50)); $plot->setBarPadding(mt_rand(0, 30) / 100, mt_rand(0, 30) / 100); $plot->label->hideFirst(TRUE); $plot->label->hideLast(TRUE); $plot->label->set($x); $plot->label->move(0, -23); $plot->label->setBackgroundGradient(new LinearGradient(new Color(250, 250, 250, 10), new Color(255, 200, 200, 30), 0)); $plot->label->border->setColor(new Color(20, 20, 20, 20)); $plot->label->setPadding(0, 0, 0, 1); $plot->label->setFont(new Tuffy(10)); $plot->setBackgroundGradient(new LinearGradient(new Color(210, 210, 210), new Color(255, 255, 255), 0)); $plot->grid->setBackgroundColor(new Color(235, 235, 180, 60)); $plot->yAxis->setLabelPrecision(2); $plot->yAxis->label->setFont(new Tuffy(8)); $plot->xAxis->setLabelText($y); $plot->xAxis->label->setFont(new Tuffy(8));
<?php /* * This work is hereby released into the Public Domain. * To view a copy of the public domain dedication, * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../BarPlot.class.php"; $graph = new Graph(400, 400); $graph->setAntiAliasing(TRUE); $values = array(19, 42, 15, -25, 3); $plot = new BarPlot($values); $plot->setBarColor(new Color(250, 230, 180)); $plot->setSpace(5, 5, NULL, NULL); $plot->barShadow->setSize(4); $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); $plot->barShadow->setColor(new Color(180, 180, 180, 10)); $plot->barShadow->smooth(TRUE); $graph->add($plot); $graph->draw();
/* * This work is hereby released into the Public Domain. * To view a copy of the public domain dedication, * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. * */ require_once "../../BarPlot.class.php"; require_once "../../LinePlot.class.php"; $graph = new Graph(450, 400); $graph->setAntiAliasing(TRUE); $blue = new Color(150, 150, 230, 50); $red = new Color(240, 50, 50, 25); $group = new PlotGroup(); $group->setSpace(5, 5, 5, 0); $group->setBackgroundColor(new Color(240, 240, 240)); $values = array(18, 12, 14, 21, 11, 7, 9, 16, 7, 23); $plot = new BarPlot($values); $plot->setBarColor($red); $group->add($plot); $values = array(12, 8, 6, 12, 7, 5, 4, 9, 3, 12); $plot = new LinePlot($values, LINEPLOT_MIDDLE); $plot->setFillColor($blue); $plot->mark->setType(MARK_SQUARE); $plot->mark->setSize(7); $plot->mark->setFill(new Color(255, 255, 255)); $plot->mark->border->show(); $group->add($plot); $graph->add($group); $graph->draw();