Zend 框架 pChart 集成

发布于 2024-11-26 20:27:15 字数 103 浏览 1 评论 0原文

有人可以向我解释如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撑一把青伞 2024-12-03 20:27:15

在 .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.

亽野灬性zι浪 2024-12-03 20:27:15

我必须说,这与 Mario's 的答案没有什么不同,但对我来说,这是在路径中使用 pChart 的更好的解决方案。如下所示:

//public/index.php

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../library/pChart/class'),
...
get_include_path(),
)));

渲染图表并返回您需要在视图中使用的图像名称和路径,然后一切就完成了。
如有疑问,请询问。

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:

//public/index.php

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
realpath(APPLICATION_PATH . '/../library/pChart/class'),
...
get_include_path(),
)));

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.

梦途 2024-12-03 20:27:15

可能有更好的方法来做到这一点,但由于没有人回答,这里有一种相当简单的方法。

首先将 pChart 放入库目录 (myapp/library/pChart)。

接下来创建一个用于渲染图像的操作(是的,您的图表将需要它自己的操作,因为您需要禁用布局和视图,并设置标题。)

注意:以下代码将进入您的操作,我只包含了部分内容与 Zend Framework 集成相关。

禁用布局和视图:

$this->_helper->getHelper("layout")->disableLayout();
$this->_helper->viewRenderer->setNoRender();

包含 pChart:

include(APPLICATION_PATH."/../library/pChart/class/pData.class.php");
include(APPLICATION_PATH."/../library/pChart/class/pDraw.class.php");
include(APPLICATION_PATH."/../library/pChart/class/pImage.class.php");

现在开始构建图表(为清楚起见,排除了 pChart 代码):

{... pChart code ...}

指定字体时使用完整路径:

$myPicture->setFontProperties(array(
    "R"=>0,"G"=>0,"B"=>0,
    "FontName"=>APPLICATION_PATH."/../library/pChart/fonts/pf_arma_five.ttf",
    "FontSize"=>12
));

完成图表代码(为清楚起见,排除了 pChart 代码):

{... pChart code ...}

最后将内容类型设置为 image/ png 并渲染图像:

header('Content-type: image/png');
$myPicture->stroke();

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:

$this->_helper->getHelper("layout")->disableLayout();
$this->_helper->viewRenderer->setNoRender();

Include pChart:

include(APPLICATION_PATH."/../library/pChart/class/pData.class.php");
include(APPLICATION_PATH."/../library/pChart/class/pDraw.class.php");
include(APPLICATION_PATH."/../library/pChart/class/pImage.class.php");

Now start building your chart (pChart code excluded for clarity):

{... pChart code ...}

When specifying fonts use the full path:

$myPicture->setFontProperties(array(
    "R"=>0,"G"=>0,"B"=>0,
    "FontName"=>APPLICATION_PATH."/../library/pChart/fonts/pf_arma_five.ttf",
    "FontSize"=>12
));

Finish your chart code (pChart code excluded for clarity):

{... pChart code ...}

Finally set the content-type to image/png and render the image:

header('Content-type: image/png');
$myPicture->stroke();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文