PHP에서 Fusion 차트 사용 및 Smarty Templeting Engine의 렌더링
-
03-07-2019 - |
문제
내 문제는 .tpl 파일에서 차트를 렌더링 할 수 없습니다. 다음 코드는 Fusion 차트 문서 확인에서 가져온 예입니다. 참조
<?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로 전달하여 <div>{$chartdata}</div>
이와 같이. Smarty TPL에 Fusion 차트를 표시하는 예제가 있으면 좋을 것입니다.
현재 $ stxml을 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" />
해결책
$output = renderChartHTML("../../FusionCharts/FCF_Column3D.swf", "", $strXML, "myNext", 600, 300);
$smarty->assign('chartdata', $output);
제휴하지 않습니다 StackOverflow