在FPDF中使用Google Charts API生成的图形 [英] Using Google Charts API Generated Graphic in FPDF
问题描述
我想包括的图表示例: https://jsfiddle.net/srm8gzqg/3/
chart.draw(data,options);
编辑:
我几乎绝望了,因为我还没有找到一种可以在小提琴中创建图形的php替代方案。要求如下:
我真的发现 no 用php编写的好的库,可以输出具有给定要求的图像文件(jpg,png等)。任何提示高度赞赏
这是 jsfiddle 作为图像呈现的谷歌图表示例。您可以轻松地将可打印版本放入您的PDF中。
Google图表具有getImageURI方法,可为您提供您创建的图表的png。
//在调用getImageURI()方法之前,等待图表完成绘制。
google.visualization.events.addListener(chart,'ready',function(){
chart_div.innerHTML ='< img src ='+ chart.getImageURI()+'>' ;
});
Well, the question is really in the title. Since the Graphics are created with Javascript, and the PDF is generated on the server side, I was wondering if there was any way (may be a hackish, not-so-beautiful way if necessary) to include these graphics into a pdf generated using FPDF.
Example of a chart I'd like to include: https://jsfiddle.net/srm8gzqg/3/
chart.draw(data, options);
Edit: Im almost despairing, since I haven't found one php alternative in which I can create a graph like in the fiddle. Requirements are the following:
- Lines from top to bottom
- Input data can have float values
- Axis on the left and bottom with correct label orientation etc.
I really found no good library written in php that can output an image file (jpg, png, etc) with the given requirements. Any hint is highly appreciated
Here is a jsfiddle example of a google chart rendered as an image. You can easily put the "printable version" in your pdf.
Google charts have the getImageURI method that provides you with a png of the chart you created.
// Wait for the chart to finish drawing before calling the getImageURI() method.
google.visualization.events.addListener(chart, 'ready', function () {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
});
这篇关于在FPDF中使用Google Charts API生成的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!