Jesús Report post Posted September 2, 2011 Hi everybody, I'm new using fusion charts and since a few days i'm trying to plot data from a mysql query. I've read the documentacion and i implemented the data string method on my source code, as follow: <?php include "../includes/FusionCharts.php"; include "../includes/DBConn.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>GRAFINCANDO</title> <script LANGUAGE="Javascript" SRC="../charts/FusionCharts.js"></SCRIPT> </head> <body> <center> <?php $qAnio = $_POST['qAnio']; $qMes = $_POST['qMes']; $qDia = $_POST['qDia']; $qAnio2= $_POST['qAnio2']; $qMes2 = $_POST['qMes2']; $qDia2 = $_POST['qDia2']; $qProd = $_POST['qProd']; $qAmbt = $_POST['qAmbt']; $qTxn = $_POST['qTxn']; $qFecha = "$qAnio$qMes$qDia"; $qFecha2= "$qAnio2$qMes2$qDia2"; if ($qTxn == "id_fin") { $TXN = "FINANCIERAS"; } else { if ($qTxn == "id_adm") { $TXN = "ADMINISTRATIVAS"; } else { $TXN = "TOTALES"; } } $strXML = "<chart caption='Producto' subcaption='(TXNS)' xAxisName='Fecha' showValues='1' labelStep='2' >"; $link = connectToDB(); $strQuery ="SELECT id_fecha AS Fecha, $qTxn AS Txns FROM `datos` WHERE id_prod = '$qProd' AND id_ambt = '$qAmbt' AND '$qTxn' = '$qTxn' AND id_fecha BETWEEN $qFecha AND $qFecha2"; $result = mysql_query($strQuery) or die(mysql_error()); $ors = mysql_fetch_array($result); if ($result) { while($ors = mysql_fetch_array($result)) { $strXML .= "<set label='" . $ors['Fecha'] . "' value='" . $ors['Txns'] . "' />"; } } mysql_close($link); $strXML .= "</chart>"; echo renderChart("../charts/Column2D.swf", "", $strXML, "PROSA", 800, 500, false, true); ?> </center> </body> </html> The result of this srcipt was not the desired, it is just doing an echo with the word CHART. Chart In fact it presents just one error that i cant understand: render: function(elementId){ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = this.getSWFHTML();FusionCharts.js:142Uncaught TypeError: Cannot set property 'innerHTML' of undefined return true; }} So, i'll be happy of receive your comments or opinions in order to make it works. Share this post Link to post Share on other sites
Jesús Report post Posted September 2, 2011 Hi everybody, I'm new using fusion charts and since a few days i'm trying to plot data from a mysql query. I've read the documentacion and i implemented the data string method on my source code, as follow: <?php include "../includes/FusionCharts.php"; include "../includes/DBConn.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>GRAFINCANDO</title> <script LANGUAGE="Javascript" SRC="../charts/FusionCharts.js"></SCRIPT> </head> <body> <center> <?php $qAnio = $_POST['qAnio']; $qMes = $_POST['qMes']; $qDia = $_POST['qDia']; $qAnio2= $_POST['qAnio2']; $qMes2 = $_POST['qMes2']; $qDia2 = $_POST['qDia2']; $qProd = $_POST['qProd']; $qAmbt = $_POST['qAmbt']; $qTxn = $_POST['qTxn']; $qFecha = "$qAnio$qMes$qDia"; $qFecha2= "$qAnio2$qMes2$qDia2"; if ($qTxn == "id_fin") { $TXN = "FINANCIERAS"; } else { if ($qTxn == "id_adm") { $TXN = "ADMINISTRATIVAS"; } else { $TXN = "TOTALES"; } } $strXML = "<chart caption='Producto' subcaption='(TXNS)' xAxisName='Fecha' showValues='1' labelStep='2' >"; $link = connectToDB(); $strQuery ="SELECT id_fecha AS Fecha, $qTxn AS Txns FROM `datos` WHERE id_prod = '$qProd' AND id_ambt = '$qAmbt' AND '$qTxn' = '$qTxn' AND id_fecha BETWEEN $qFecha AND $qFecha2"; $result = mysql_query($strQuery) or die(mysql_error()); $ors = mysql_fetch_array($result); if ($result) { while($ors = mysql_fetch_array($result)) { $strXML .= "<set label='" . $ors['Fecha'] . "' value='" . $ors['Txns'] . "' />"; } } mysql_close($link); $strXML .= "</chart>"; echo renderChart("../charts/Column2D.swf", "", $strXML, "PROSA", 800, 500, false, true); ?> </center> </body> </html> The result of this srcipt was not the desired, it is just doing an echo with the word CHART. Chart In fact it presents just one error that i cant understand: render: function(elementId){ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = this.getSWFHTML();FusionCharts.js:142Uncaught TypeError: Cannot set property 'innerHTML' of undefined return true; }} So, i'll be happy of receive your comments or opinions in order to make it works. Only to supplement, this is the XML generated content: <!-- START Code Block for Chart PROSA --><div id="PROSADiv"> Chart </div><script type="text/javascript" ><!-- // Instantiate the Chart var chart_PROSA = new FusionCharts( { "swfUrl" : "../charts/Column2D.swf", "width" : "800", "height" : "500", "renderAt" : "PROSADiv", "dataFormat" : "xml", "id" : "PROSA", "debugMode" : "1", "wMode" : "opaque", "dataSource" : "<chart caption='Producto' subcaption='(TXNS)' xAxisName='Fecha' showValues='1' labelStep='2' ><set label='20110702' value='1181805' /><set label='20110703' value='755148' /></chart>" } ).render();// --></script><!-- END Script Block for Chart PROSA --> Share this post Link to post Share on other sites
Guest Angshu Report post Posted September 5, 2011 Hi, Thanks for your post. Please check the following: 1.Have you pasted the FusionCharts.js, jquery.min.js and highcharts.js files in charts folder? 2.Have you included and provided the path of FusionCharts.js properly in your html page? 3 .Are there any JavaScript syntax or runtime errors that might have halted the execution of FusionCharts functions? 4 .Have you given different names for the chart's JavaScript variable and chart's ID? Awaiting for your response. Share this post Link to post Share on other sites
Jesús Report post Posted September 9, 2011 (edited) Hi, I've read your comments and i followed your questions, so here it is that i found: 1.Have you pasted the FusionCharts.js, jquery.min.js and highcharts.js files in charts folder? Yes, the three files are in charts folder. 2.Have you included and provided the path of FusionCharts.js properly in your html page? The folder tree is as follow: - www | |- JAP | |-+ img |-- includes |-- FusionCharts.php |-- DBConn.php |-+ pages |-- charts |-- FusionCharts.js |-- jquery.min.js |-- highcharts.js |-- Column2D.swf | |-- style.css |-- index.php And the path is in the html page, <script LANGUAGE="Javascript" SRC="charts/FusionCharts.js"></SCRIPT> Is this correct ??? 3 .Are there any JavaScript syntax or runtime errors that might have halted the execution of FusionCharts functions? No, I did not find any error on Javascript syntax. 4 .Have you given different names for the chart's JavaScript variable and chart's ID? It looks like that the JavaScript variable and chart's ID have the same name, I've posted the source code so if you can find some diference i'll be grateful that you notice me. So, this is that i've checked, i really hoe that you can help me. Edited September 9, 2011 by JESUS AVILA Share this post Link to post Share on other sites
Jesús Report post Posted September 9, 2011 THANKS ANGSHU !!! Finally, i got the desire result with my source code, so we can close this topic !! THANKS A LOT !!! Share this post Link to post Share on other sites
Guest Angshu Report post Posted September 12, 2011 Hi, Glad to know that you have managed to resolve your problem. Happy FusionCharting! Share this post Link to post Share on other sites