2010-09-16 8 views
0

J'utilise fusioncharts avec PHP mais je reçois une erreur "No data to display". J'ajoute des données au graphique via xml généré à partir d'un tableau. les données existent comme quand je décharge le tableau je peux le voir tout bien. Je pense que c'est le xml qui est faux. Peut-être que quelqu'un peut jeter un coup d'oeil et m'aider, le xml var dump est en train d'être bizarre.PHP: création d'une chaîne XML pour les tableaux de fusion

Création du tableau

$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++; 
    } 

décharge Var du tableau

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) } } 

Création de la chaîne 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); 

décharge Var strXML

string(669) "" 

Var décharge de 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" } } } } 
+0

est le XML valide si vous l'éditez? – robjmills

+0

Je ne suis pas sûr de la meilleure façon de produire du XML, mais j'ai utilisé var dump et j'obtiens string (619) "" - je ne sais pas quoi en faire. semble la chaîne contient quelque chose, mais il n'affiche rien – iamjonesy

Répondre

0

regardant the docs il me semble que vos arguments sont dans le mauvais ordre.

essayer:

echo renderChart("FusionCharts/Charts/FCF_Column2D.swf", "", $strXML, "issueTypes", 600, 300, false, true); 
+0

merci essayé mais pas de chance :( – iamjonesy

0

Il est peut-être un peu en retard à répondre ceci ou vous pourriez avoir à résoudre le problème.

La solution la plus proche possible que je peux penser est:

Vous devez utiliser en lieu et nom au lieu de l'étiquette. Ainsi votre code serait:

//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>";