# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Library General Public License as published by # the Free Software Foundation; version 2 only # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU Library General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # require_once('phplot-5.0.5/phplot.php'); // accept data to plot through phplot function draw_stackedbar($chart_title, $legend, $ytitle, $data) { // Define general plot properties $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); // Create the chart, write it to a newly created tmpfile. $output = tempnam('tmp/', 'plot'); $plot = new PHPlot(900, 400); $plot->SetIsInline(True); //$plot->SetPrintImage(False); $plot->SetImageBorderType('plain'); $plot->SetDataColors($data_colors); $plot->SetPlotType('stackedbars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); $plot->SetTitle($chart_title); $plot->SetYTitle($ytitle); $plot->SetLegend($legend); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetLegendPixels(760, 40); $plot->SetMarginsPixels(100, 150, 50, 50); $plot->SetNumberFormat(',', '.'); $plot->SetPrecisionY(0); $plot->SetYLabelType('data'); $plot->SetOutputFile($output); $plot->DrawGraph(); chmod($output, 0644); $target = dirname($output).'/'.basename($output).'.png'; if (rename($output, $target)) { return 'tmp/'.basename($target); } else { return False; } }