【问题标题】:Using Fusion Chart in PHP and rendering in Smarty Templating Engine在 PHP 中使用 Fusion Chart 并在 Smarty 模板引擎中进行渲染
【发布时间】:2009-05-01 20:02:31
【问题描述】:

我的问题无法在 .tpl 文件中呈现图表。以下代码是取自 Fusion chart document check for reference的示例

<?php
   include("../Includes/FusionCharts.php");

   //Create an XML data document in a string variable
   $strXML  = "";
   $strXML .= "<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units'
   decimalPrecision='0' formatNumberScale='0'>";
   $strXML .= "<set name='Jan' value='462' color='AFD8F8' />";
   $strXML .= "<set name='Feb' value='857' color='F6BD0F' />";
   $strXML .= "<set name='Mar' value='671' color='8BBA00' />";
   $strXML .= "<set name='Apr' value='494' color='FF8E46' />";
   $strXML .= "<set name='May' value='761' color='008E8E' />";
   $strXML .= "<set name='Jun' value='960' color='D64646' />";
   $strXML .= "<set name='Jul' value='629' color='8E468E' />";
   $strXML .= "<set name='Aug' value='622' color='588526' />";
   $strXML .= "<set name='Sep' value='376' color='B3AA00' />";
   $strXML .= "<set name='Oct' value='494' color='008ED6' />";
   $strXML .= "<set name='Nov' value='761' color='9D080D' />";
   $strXML .= "<set name='Dec' value='960' color='A186BE' />";
   $strXML .= "</graph>";

   //Create the chart - Column 3D Chart with data from strXML variable using dataXML method
   echo renderChartHTML("../../FusionCharts/FCF_Column3D.swf", "", $strXML, "myNext", 600, 300);
?>


如果我在正常的 .php 中渲染,它可以工作,但是如何将 renderChartHTML 值传递给 Smarty tpl,以便它像这样显示在 &lt;div&gt;{$chartdata}&lt;/div&gt; 中。如果有任何示例在 smarty tpl 中显示 Fusion 图表,那就太好了。

到目前为止,我能够获得图形,例如将 $strXML 分配给 smarty 变量并将值直接传递给嵌入参数。有人提出更好的方法吗?

在 PHP 中:

$smarty->assign('strXML', $strXML);

在 .tpl 中:

<embed src="FCF_MSLine.swf" flashVars="&dataXML={$strXML}&chartWidth=900&chartHeight=600" quality="high" width="900" height="600" name="testgraph" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

【问题讨论】:

    标签: php web-applications charts smarty


    【解决方案1】:
    $output = renderChartHTML("../../FusionCharts/FCF_Column3D.swf", "", $strXML, "myNext", 600, 300);
    $smarty->assign('chartdata', $output);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-04
      • 1970-01-01
      • 2011-08-24
      • 2016-08-23
      • 2011-12-18
      • 2013-07-09
      相关资源
      最近更新 更多