hi,
I'm using fusioncharts with PHP but I'm getting a No data to display error. I'm adding data to the chart via xml generated from an array. the data exists as when I dump the array I can see it all fine. I think it's the xml that is wrong. Maybe someone can have a look and help me out, the xml var dump is being wierd.
Creating the array
$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++;
}
Var dump of the array
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) } }
Creating the XML string
//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);
Var dump of strXML
string(669) ""
Var dump of simplexml_load_string
$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" } } } }