我正在使用PHP的fusioncharts,但我得到一个无数据显示错误。我是通过从数组生成的xml将数据添加到图表中的。数据存在,因为当我转储数组时,我可以看到它很好。我认为这是错误的xml。也许有人可以看看并帮助我,xml var转储很奇怪。
创建数组
$x = 0;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
$issuetype[$x][1] = $row['issue_type_id'];
$issuetype[$x][2] = $row['issue_type_name'];
$issuetype[$x][3] = $row['Total'];
$x++;
}
数组的转储
array(13) { [0]=> array(3) { [1]=> int(17) [2]=> string(14) "Advice Request" [3]=> int(14) } [1]=> array(3) { [1]=> int(30) [2]=> string(27) "Application Failure/Problem" [3]=> int(37) } [2]=> array(3) { [1]=> int(28) [2]=> string(6) "Backup" [3]=> int(3) } [3]=> array(3) { [1]=> int(21) [2]=> string(21) "Device Configuration " [3]=> int(14) } [4]=> array(3) { [1]=> int(25) [2]=> string(6) "E-Mail" [3]=> int(6) } [5]=> array(3) { [1]=> int(20) [2]=> string(16) "Hardware Failure" [3]=> int(4) } [6]=> array(3) { [1]=> int(18) [2]=> string(8) "Internet" [3]=> int(6) } [7]=> array(3) { [1]=> int(26) [2]=> string(11) "Procurement" [3]=> int(1) } [8]=> array(3) { [1]=> int(24) [2]=> string(8) "Security" [3]=> int(3) } [9]=> array(3) { [1]=> int(22) [2]=> string(18) "Structured Cabling" [3]=> int(2) } [10]=> array(3) { [1]=> int(31) [2]=> string(9) "Telephony" [3]=> int(23) } [11]=> array(3) { [1]=> int(32) [2]=> string(21) "Ticketed Project Work" [3]=> int(11) } [12]=> array(3) { [1]=> int(23) [2]=> string(25) "User/Group Administration" [3]=> int(49) } }
创建XML字符串
//Initialize <chart> element
$strXML = "<chart caption='Tickets by Issue Types' formatNumberScale='0'>";
foreach ($issuetype as $issue){
$strXML .= "<set label='" . $issue[2] . "' value='" . $issue[3] . "' />";
}
//Close <chart> element
$strXML .= "</chart>";
//Create the chart - Column 2D Chart with data contained in strXML
echo renderChart("FusionCharts/Charts/FCF_Column2D.swf", "issueTypes", $strXML, "", 600, 300, false, true);
strXML的Var转储
string(669) ""
Simplexml_load_string的Var转储
$xml = simplexml_load_string($strXML);
var_dump($xml);
object(SimpleXMLElement)#2 (2) { ["@attributes"]=> array(5) { ["caption"]=> string(22) "Tickets by Issue Types" ["formatNumberScale"]=> string(1) "0" ["showValues"]=> string(1) "1" ["xAxisName"]=> string(10) "Issue Type" ["yAxisName"]=> string(14) "No. of Tickets" } ["set"]=> array(13) { [0]=> object(SimpleXMLElement)#3 (1) { ["@attributes"]=> array(2) { ["label"]=> string(14) "Advice Request" ["value"]=> string(2) "14" } } [1]=> object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(2) { ["label"]=> string(27) "Application Failure/Problem" ["value"]=> string(2) "37" } } [2]=> object(SimpleXMLElement)#5 (1) { ["@attributes"]=> array(2) { ["label"]=> string(6) "Backup" ["value"]=> string(1) "3" } } [3]=> object(SimpleXMLElement)#6 (1) { ["@attributes"]=> array(2) { ["label"]=> string(21) "Device Configuration " ["value"]=> string(2) "14" } } [4]=> object(SimpleXMLElement)#7 (1) { ["@attributes"]=> array(2) { ["label"]=> string(6) "E-Mail" ["value"]=> string(1) "6" } } [5]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(2) { ["label"]=> string(16) "Hardware Failure" ["value"]=> string(1) "4" } } [6]=> object(SimpleXMLElement)#9 (1) { ["@attributes"]=> array(2) { ["label"]=> string(8) "Internet" ["value"]=> string(1) "6" } } [7]=> object(SimpleXMLElement)#10 (1) { ["@attributes"]=> array(2) { ["label"]=> string(11) "Procurement" ["value"]=> string(1) "1" } } [8]=> object(SimpleXMLElement)#11 (1) { ["@attributes"]=> array(2) { ["label"]=> string(8) "Security" ["value"]=> string(1) "3" } } [9]=> object(SimpleXMLElement)#12 (1) { ["@attributes"]=> array(2) { ["label"]=> string(18) "Structured Cabling" ["value"]=> string(1) "2" } } [10]=> object(SimpleXMLElement)#13 (1) { ["@attributes"]=> array(2) { ["label"]=> string(9) "Telephony" ["value"]=> string(2) "23" } } [11]=> object(SimpleXMLElement)#14 (1) { ["@attributes"]=> array(2) { ["label"]=> string(21) "Ticketed Project Work" ["value"]=> string(2) "11" } } [12]=> object(SimpleXMLElement)#15 (1) { ["@attributes"]=> array(2) { ["label"]=> string(25) "User/Group Administration" ["value"]=> string(2) "49" } } } }
答案 0 :(得分:0)
看着the docs它看起来像你的论点是错误的顺序。
尝试:
echo renderChart("FusionCharts/Charts/FCF_Column2D.swf", "", $strXML, "issueTypes", 600, 300, false, true);
答案 1 :(得分:0)
回复此问题可能有点迟,或者您可能已经解决了这个问题。
我能想到的最接近的解决方案是:
您需要使用而不是名称而不是标签。因此,您的代码将是:
//Initialize <graph> element
$strXML = "<graph caption='Tickets by Issue Types' formatNumberScale='0'>";
foreach ($issuetype as $issue){
$strXML .= "<set name='" . $issue[2] . "' value='" . $issue[3] . "' />";
}
//Close <chart> element
$strXML .= "</graph>";