souren Report post Posted November 13, 2011 Hi all, I'm new in this forum. I' using fusion chart v3.2 evaluation demo in php. My code is working fine in Chrome and IE. But, it is not working perfectly in mozila. When the first time page is loading in mozila, the chart is showing for some sometimes. After that it si being disappeared and showing a message "error in loading data". My code is below: function report1(){ $current_time = date("H:i:s",time()); $content .='<div id="chartContainer">FusionCharts will load here</div>'; $content .='<script type="text/javascript">'; $content .=' var myChart = new FusionCharts( "Charts/Column3D.swf?noCache=" + new Date().getMilliseconds(),"myChartId", "600", "300","0","1");'; $content .=' myChart.setXMLUrl( "get-data.php?current_time='.$current_time.'" );'; $content .=' myChart.render( "chartContainer" );'; $content .=' </script>'; return $content; } get-data.php:- <?php include ('../settings/local_settings.php'); include ($_SERVER['DOCUMENT_ROOT'].'/modules/common.php'); include ($_SERVER['DOCUMENT_ROOT']. '/modules/utils/cls_utils.php'); $cls_utils=new utils(); include ($_SERVER['DOCUMENT_ROOT'].'/modules/users/cls_users.php'); $cls_users=new Users(); //Sanitizing the input //$Type = $_GET['type']; $current_time = intval($_GET['current_time']); //$current_time = date("H:i:s",time()); $current_date =date("Y-m-d",time()); //$Month = intval($_GET['month']); //$Day = intval($_GET['day']); //Months Names $sql="Select * from tbl_box order by box_id"; $result=mysql_query($sql); $box .='null'; $count=0; while($row=mysql_fetch_array($result)){ $box .=','; $box .=$row['box_name']; $count++; } $BoxNames=array(); $BoxNames = explode(",",$box); //Prepare variables according to type-of-chart $Query = "SELECT box_id AS Value, COUNT( * ) AS Total FROM tbl_app WHERE TIME( app_start ) > '$current_time' and TIME( app_stop ) < '$current_time' AND DATE( app_start ) = '$current_date' GROUP BY Value"; $ResultArray = array_fill(1, $count, 0); // fill the Result array with 0 values for each month $ChartHeading = 'Number of appointments for: '.$current_date.':'.$current_time; $XaxisName = 'Boxes'; //Query the database $QueryResult = mysql_query($Query); //Fetch results in the Result Array while($Row = mysql_fetch_assoc($QueryResult)) $ResultArray[$Row['Value']]=$Row['Total']; //Generate Chart XML: Head Part $Output = '<chart caption="'.$ChartHeading.'" xAxisName="'.$XaxisName.'" yAxisName="No. Of Appointments" showNames="1" bgColor="E6E6E6,F0F0F0" bgAlpha="100,50" bgRatio="50,100" bgAngle="270" showBorder="1" borderColor="AAAAAA" baseFontSize="12">'; //Generate Chart XML: Main Body foreach($ResultArray as $MonthNumber => $value) // MonthNumber is month number (1-12) $Output .= '<set value="'.$value.'" name="'.$BoxNames[$MonthNumber].'" />'; //Generate Chart XML: Last Part $Output .= '</chart>'; //Set the output header to XML header('Content-type: text/xml'); //Send output echo $Output; ?> Please help me out. Thanks, Souren Share this post Link to post Share on other sites
Guest Angshu Report post Posted November 14, 2011 Hi, Welcome to FusionCharts Forum! If you get a "Error in Loading Data" message in your chart, it means that FusionCharts could not find XML data at the specified URL. In that case, please check the following: 1. Please check if you've actually provided Data URL or Data String. If you do not provide either, FusionCharts looks for a default Data.xml file in the same path. Now, if that is also not found, it shows the "Error in Loading Data" error. 2. If you're using Data URL method, paste this URL in your browser to check if it's returning a valid XML. Make sure, there are no scripting or time-out errors and a valid XML is being returned. Also pleasec make sure that the XML isn't intermingled with HTML content. The data provider page should return a clean XML only - not even HTML <head> or <body> tags. 3. Please make sure you're passing relative URLs for Data URL, and not absolute URLs. To restrict cross site security attacks, FusionCharts doesn't allow colons in dataURL (starting v3.0.5). So you cannot specify dataURL as http://.../path/file.ext any more. 4. When using Data URL method, please make sure that the SWF File and data provider page are on the same sub-domain. Due to Flash's sandbox security model, it cannot access data from external domains, unless otherwise configured. Hope this helps. Share this post Link to post Share on other sites