Index: trunk/flowmon-web/charts/top-ports-src.inc.php =================================================================== --- trunk/flowmon-web/charts/top-ports-src.inc.php (revision 4) +++ trunk/flowmon-web/charts/top-ports-src.inc.php (revision 1) @@ -21,5 +21,5 @@ # -require_once('stacked-bars.inc.php'); +require_once('phplot-5.0.5/phplot.php'); // Get the data from the table, format it and write it out to a file @@ -33,4 +33,6 @@ $chart_title = $style.' '.$flowsrc.' - '.strftime($date_fmt_str, $starttime).' to '.strftime($date_fmt_str, $endtime); $ytitle = 'Bytes'; + $output = tempnam('tmp/', 'plot'); + $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'purple', 'red', 'violet', 'azure1', 'yellow', 'DarkGreen'); @@ -133,6 +135,36 @@ } - return draw_stackedbar($chart_title, $legend, $ytitle, $data); + // Create the chart + $plot = new PHPlot(800, 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->SetNumberFormat(',', '.'); + $plot->SetPrecisionY(0); + + $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; + } }