$data2 = array(array('', 2, 4, 6), array('', 3, 6, 9), array('', 4, 8, 6)); # Check the overall structure of a frame. Return True if OK, else False. # Frame needs: boundary, content type and content length, then the image. # This does nothing with the image (there is another test for that). function check_frame($frame, $boundary) { global $mime_type; return preg_match("--{$boundary}\\s", $frame) && preg_match("Content-Type: {$mime_type}\\si", $frame) && preg_match("Content-Length: (\\d*)\\si", $frame); } # Initial plot object setup: $plot = new PHPlot_pv(640, 480); $plot->SetDataType('text-data'); $plot->SetPlotType('lines'); $plot->SetFileFormat('jpg'); $plot->SetXTickLabelPos('none'); $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();
{ public function GET_rgb_array() { return $this->rgb_array; } } $p = new PHPlot_pv(800, 700); # Use internal color map rgb_array to get a list of colors: $colors = array_keys($p->GET_rgb_array()); sort($colors); $nc = count($colors); # Make a data array with 1 point, $nc data sets: $dp = array(''); for ($i = 0; $i < $nc; $i++) { $dp[] = $nc - $i; } $data = array($dp); $p->SetPlotType('bars'); $p->SetDataType('text-data'); $p->SetDataValues($data); # Use all colors: $p->SetDataColors($colors); $p->SetShading(0); # Make a legend with all the color names: $p->SetLegend($colors); $p->SetPlotAreaWorld(0.1, 0, NULL, NULL); $p->SetTitle('PHPlot Default Color Map'); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->SetYTickIncrement(1); $p->DrawGraph();