codeigniter でグラフを作成し、pdf に変換しようとしています。PDF変換にはmpdfを使用しています。
グラフ生成のために、いくつかの方法を試しました。含む-phpgraphlib、phpmygraph5.0、およびgcharts..
gchart は私が推測する javascript でグラフを生成しています..だから私は phpgraphlib と phpmygraph5 で試しました。しかし、私が今直面している問題は、グラフがブラウザで生成されていることです。それを画像に変換し、データ配列として私のpdfビューに送信する方法に行き詰まりました..
これが私のpdf生成コードです:
$this->CI->load->library('pdf');
$pdf = $this->CI->pdf->load();
$style = 'assets/pdf/pdf.css';
$stylesheet = file_get_contents( $style);
//$pdf-> $img = file_get_contents($this->graph());
$graph_result['points'] = $points;
$graph_result['profile'] = $profile;
$graph_result['image'] = file_get_contents($this->mygraph());
$content = $this->CI->load->view('pdf/graph_pdf_view', $graph_result, TRUE);
$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($content,2);
$pdf->Output('Graph.pdf', 'I');
グラフ関数を生成しています:
public function graph()
{
//graph library loads.......
include (APPPATH.'libraries/phpgraphlib/phpgraphlib.php');
$graph = new PHPGraphLib(650,200);
$data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
"5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
"10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
"14" => .0028, "15" => .0025);
//print_r($data);
$graph->addData($data);
$graph->setTitle('PPM Per Container');
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('green');
$graph->setGoalLine(.0025);
$graph->setGoalLineColor('yellow');
$graph->createGraph();
return $graph;
}
PDF生成関数からグラフ関数を呼び出すと、ブラウザでグラフを直接生成します..PDFのビューをロードする場所の次のコードに移動しません..この生成されたグラフを画像として保存し、その画像のみを渡すにはどうすればよいですかPDF表示へ??