Zend 框架 pChart 集成
有人可以向我解释如何使用 PCharts 配置 zendframework 项目吗?我需要以图形形式显示数据库中的数据。如果可能的话,请给我发送一个示例代码,说明如何将各个部分组合在一起。谢谢
Can somebody explain to me how to configure a zendframework project with PCharts?I need to show data from my database in graph form. If possible please send me an example code of how to put the pieces together. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 .phtml 文件图像的 src 属性中调用 picartcreateAction,
就像
< img src="YOUR_SITE_PATH/Controller/picartcreateAction" >在您的主页 phtml 文件中,
现在在 picartcreateAction() 中执行与“Mario”所述相同的操作。
Call your pichartcreateAction in src attribute of an image of your .phtml file,
like
< img src="YOUR_SITE_PATH/Controller/pichartcreateAction" > In you main page phtml file
Now in pichartcreateAction() do the same as 'Mario' said.
我必须说,这与 Mario's 的答案没有什么不同,但对我来说,这是在路径中使用 pChart 的更好的解决方案。如下所示:
渲染图表并返回您需要在视图中使用的图像名称和路径,然后一切就完成了。
如有疑问,请询问。
I must say that this is not a different answer than that of Mario's but for me it was better solution with pChart in Path. As follows:
Render the Chart and return image name and path whom you'll need to use in the view, and you're all set.
Please ask, if in doubt.
可能有更好的方法来做到这一点,但由于没有人回答,这里有一种相当简单的方法。
首先将 pChart 放入库目录 (myapp/library/pChart)。
接下来创建一个用于渲染图像的操作(是的,您的图表将需要它自己的操作,因为您需要禁用布局和视图,并设置标题。)
注意:以下代码将进入您的操作,我只包含了部分内容与 Zend Framework 集成相关。
禁用布局和视图:
包含 pChart:
现在开始构建图表(为清楚起见,排除了 pChart 代码):
指定字体时使用完整路径:
完成图表代码(为清楚起见,排除了 pChart 代码):
最后将内容类型设置为 image/ png 并渲染图像:
There may be a better way to do this, but since no one has answered here's a fairly simple way to do it.
Start by placing pChart in your library directory (myapp/library/pChart).
Next create an action for rendering the image (yes, your chart will require it's own action as you need to disable layouts and views, and set the header.)
Note: The following code will go into your action and I have only included the parts relevant to Zend Framework integration.
Disable layouts and views:
Include pChart:
Now start building your chart (pChart code excluded for clarity):
When specifying fonts use the full path:
Finish your chart code (pChart code excluded for clarity):
Finally set the content-type to image/png and render the image: