<?php # $Id$ # Testing phplot - Default TT font (1a): No default path or font set, usettf require_once 'phplot.php'; // Extend PHPlot class to allow access to protected variable(s): class PHPlot_pv extends PHPlot { public function GET_default_ttfont() { return $this->default_ttfont; } } $data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2)); $p = new PHPlot_pv(800, 800); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitle('TTF default not set, SetUseTTF(true)'); $p->SetXTitle('X Axis Title'); $p->SetYTitle('Y Axis Title'); $p->SetUseTTF(True); $p->DrawGraph(); fwrite(STDERR, "OK defaultfont1a: default_ttfont=" . $p->GET_default_ttfont() . "\n");
function pmarg_test($call_SetMarginsPixels, $args_SetMarginsPixels, $call_SetPlotAreaPixels, $args_SetPlotAreaPixels, $return_margins) { global $data, $margins_override, $plotarea_override; $p = new PHPlot_pv(PLOT_WIDTH, PLOT_HEIGHT); $p->SetTitle("Unused Title Goes Here"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotType('lines'); $p->SetXTickLabelPos('none'); $p->SetXTickIncrement(1.0); $p->SetYTickIncrement(10.0); $p->SetYTickPos('both'); $p->SetYTickLabelPos('both'); $p->SetDrawXGrid(False); $p->SetDrawYGrid(False); $p->SetXTitle("Two Line\nX Axis Title"); $p->SetYTitle("Three Line\nY Axis\nTitle"); # Variant cases: if ($call_SetMarginsPixels) { call_user_func_array(array($p, 'SetMarginsPixels'), array_mask($margins_override, $args_SetMarginsPixels, 4)); } if ($call_SetPlotAreaPixels) { call_user_func_array(array($p, 'SetPlotAreaPixels'), array_mask($plotarea_override, $args_SetPlotAreaPixels, 4)); } # Produce but don't output the image. Comment out to test the test. $p->SetPrintImage(False); # Produce the graph: $p->DrawGraph(); # Return the resulting margins or coordinates, as requested. $plot_area = $p->GET_plot_area(); if ($return_margins) { return array($plot_area[0], PLOT_WIDTH - $plot_area[2], $plot_area[1], PLOT_HEIGHT - $plot_area[3]); } return $plot_area; }
$plot->SetXTickPos('none'); $plot->SetXDataLabelPos('none'); $plot->SetPlotAreaWorld(NULL, 0, NULL, 10); $plot->SetPrintImage(False); # StartStream does no output, only headers (which we cannot catch using the # CLI), so just check the variables it sets: $plot->StartStream(); $boundary = $plot->GET_stream_boundary(); # Check: Stream frame header includes content-type with expected MIME type $sfh = $plot->GET_stream_frame_header(); if (!preg_match("Content-Type: {$mime_type}", $sfh)) { fwrite(STDERR, "Error: Did not match Content type in header:\n{$sfh}\n"); $errors++; } $plot->SetDataValues($data1); $plot->DrawGraph(); ob_start(); $plot->PrintImageFrame(); $frame1 = ob_get_clean(); $plot->SetDataValues($data2); $plot->DrawGraph(); ob_start(); $plot->PrintImageFrame(); $frame2 = ob_get_clean(); if (!check_frame($frame1, $boundary) || !check_frame($frame2, $boundary)) { # This is kind of useless for debugging, but the frame isn't text so # we can't just print it... fwrite(STDERR, "Error: Frame(s) did not match expected pattern\n"); $errors++; } ob_start();