c is null on using google charts

217 views
Skip to first unread message

Bluestacks Account

unread,
Sep 23, 2015, 8:40:11 AM9/23/15
to Google Visualization API
Hi,

i would like to ask what is the problem on my script. I use a Web API to get the data and pass it thru using arrayToDataTable function to fill the data using php. When i try to view the page it always shows "c is null" but if you refresh it, it will show the graph.

Please help me with this problem.

Thanks..

Daniel LaLiberte

unread,
Sep 23, 2015, 9:10:47 AM9/23/15
to Google Visualization API
That kind of obscure error message indicates a bug on our side which we are interested in fixing, but you'll have to give us more clues so we can reproduce it.  

Can you put together a small example page using jsfiddle?  Or post enough code here.  We can't use your php code, so you should use the browser debugging tools to view the html and javascript source that is sent to the browser.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/91447a19-0a5d-413a-bc8b-2b35059057b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Bluestacks Account

unread,
Sep 23, 2015, 9:19:32 AM9/23/15
to Google Visualization API
Hi Daniel,

this is part of the code which utilizes the Google Chart.

<?php
   
foreach($symbols as $syms)
   
{
        $ar_temp
=array();
        $history
=array();
        $start      
=12;
        $length    
=28;
       
?>
            <div data-role="page" id="
<?=$syms."_chart";?>">
               
<div data-role="header" data-position="fixed">
               
<a href="#pageone" class="ui-btn ui-corner-none ui-icon-back ui-btn-icon-left">Back</a>
               
<h1><?=$syms." Chart";?></h1>
               
</div>
               
<?php
                    $history_query
= 'HISTORYNEW-symbol='.strtoupper($syms).'|period=30|from='.(time() - (1 * 24 * 60 * 60)).'|to='.(time());
                    $history_result
= MQ_Query($history_query);
                   
if ($history_result != '!!!CAN\'T CONNECT!!!' )
                   
{
                        $s
=substr($history_result,0,$start);
                        $ar_temp
=unpack("ibars/idigits/itimesign",$s);
                        $digits
=$ar_temp["digits"];
                       
?>
                       
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
                       
<script type="text/javascript">
                            google
.load("visualization","1",{packages:["corechart"]});
                            google
.setOnLoadCallback(<?=$syms."Chart";?>)
                           
function <?=$syms."Chart()";?>
                           
{
                               
<?php
                                $counter
=0;
                               
?>
                               
var data = google.visualization.arrayToDataTable([
                               
<?php
                                $tmpstring
="";
                               
while($s=substr($history_result,$start,$length))
                               
{
                                    $start
+=$length;
                                   
//$s = substr($history_result,$start,$length);
                                    $history
=unpack("itime/iopen/ihigh/ilow/iclose/dvol",$s);
                                    $history
["high"]+=$history["open"];
                                    $history
["high"]/=pow(10,$digits);
                                    $history
["low"]+=$history["open"];
                                    $history
["low"]/=pow(10,$digits);
                                    $history
["close"]+=$history["open"];
                                    $history
["close"]/=pow(10,$digits);
                                    $history
["open"]/=pow(10,$digits);
                                   
                                    $tmpstring
.="['".date("d M Y",$history["time"])."',".$history["low"].",".$history["open"].",".$history["close"].",".$history["high"]."],";
                               
                               
}
                                unset
($arr_temp);
                                unset
($history);
                                $data
=mb_substr($tmpstring,0,-1);
                               
?>
                               
<?=$data;?>],true);
                               
var options={ legend:'none'};
                               
var chart=new google.visualization.CandlestickChart(document.getElementById('<?=$syms."_div";?>'));
                                chart
.draw(data,options);
                           
}
                       
</script>
                       
<?php
                   
}
                   
               
?>
                <div data-role="main" class="ui-content" id="
<?=$syms."_div";?>" height="200px">
               
</div>
           
</div>
               
<?php
   
}
    unset
($syms);
?>

Kindly check.

Thank you very much...

Daniel LaLiberte

unread,
Sep 23, 2015, 9:25:36 AM9/23/15
to Google Visualization API
As I said, we can't use your php code.   Could you go to your browser when you visit your page and open the debugger and view the html for the page?  Maybe if you look at the generated code, you'll see what the problem is.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.

Bluestacks Account

unread,
Sep 24, 2015, 12:47:58 AM9/24/15
to Google Visualization API
Hi Daniel,

It seems the other error was gone but the error "Cannot read property 'length' of null"occur.

Bluestacks Account

unread,
Sep 24, 2015, 12:49:41 AM9/24/15
to Google Visualization API
and when i run it on debugger, there is no error there and the data are on the page the only problem is that the chart is not showing.
Reply all
Reply to author
Forward
0 new messages