5 Replies - 353 Views - Last Post: 18 July 2013 - 04:24 PM Rate Topic: -----

#1 kim_barcelona555  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 54
  • Joined: 01-July 13

Can't display Google Charts using $post

Posted 17 July 2013 - 09:53 PM

Hello guys, I've created a function to generate line graph for our system.

nClass.php
class A{
    function generateGraph(parameters){
    //Google codes + Mysql Data
     }
}



n.php
$net = new A;

	echo $net->generateGraph(parameters); 



n.tpl

<html>
<head>
    {literal}
 <link type="text/css" rel="stylesheet" href="include/css/cupertino/jquery-ui-1.8.18.custom.css">
	<script type="text/javascript"  src="include/js/jquery.js"></script>
	<script type="text/javascript"  src="include/jquery/jquery-ui-1.8.18.custom.min.js"></script>
	<script type="text/javascript" src="https://www.google.com/jsapi"></script>
	<script type="text/javascript" >

	function getGraph(){
	 $.post('n.php', {parameters: parameters}, function(result) {
				 $("#graphXY").html(result);
			
			});
	}

	</script>
    {/literal}
	</head>
	<body>


<table border='0' align='center'>
	<tr>
		<td width="10%" align='right'>Port: </td>
		<td colspan="3"><select id="port" onchange="getGraph()">
		<option value='default'>Choose</option>	
		</select></td>
	</tr>
	<tr>
		   <td colspan="4" id="graphXY">
		   </td>   
	</tr>

</table>

</body>

</html>




I'm trying to display the graph to n.tpl but seems that as I load it, the whole page is getting blank. if I run the n.php, it displays the graph smoothly.

I think the $post or the .html in it is causing the problem? Any idea what's causing it?
If i try to change .html with .text, I'm getting the function's code.

And also take note, the google code is in the nClass.php under the generateGraph().

Is This A Good Question/Topic? 0
  • +

Replies To: Can't display Google Charts using $post

#2 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,851
  • Joined: 30-April 10

Re: Can't display Google Charts using $post

Posted 17 July 2013 - 10:02 PM

Do you get any javascript errors in the console?
Was This Post Helpful? 0
  • +
  • -

#3 kim_barcelona555  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 54
  • Joined: 01-July 13

Re: Can't display Google Charts using $post

Posted 17 July 2013 - 10:07 PM

View Postlaytonsdad, on 17 July 2013 - 10:02 PM, said:

Do you get any javascript errors in the console?


Nope

One more thing, I use this dummy data for generating graph in n.tpl
 {literal}
		   
    <script type="text/javascript">

      google.load("visualization", "1", {packages:["corechart"]});
      google.setonloadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Priorities', 'Voice Pod', 'CM Pod', 'Data Pod', 'Others'],
          ['Priority 1',  44,      35,  44, 56],
          ['Priority 2',  25,     46,  78,  89],
          ['Priority 3',  87,      56,  78,  23],
          ['Priority 4',  45,      42,  56,  87],
          ['Priority 5',  34,      9,  99,  54],
          ['Priority 6',  12,      34,  54, 34],
          ['Priority 9',  56,      67,  27,  73]

        ]);

        var options = {
          title: 'Pod Priorities',
          hAxis: {title: 'Priorities', titleTextStyle: {color: 'red'}}
        };

        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
		

      }


    </script>
	{/literal}
    <!--Div that will hold the pie chart-->
    <div id="chart_div" style="width: 300px; height: 500px;"></div>


But I'm getting this error

Cannot call method '$d' of undefined×

I don't know where $d came from.
Was This Post Helpful? 0
  • +
  • -

#4 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,851
  • Joined: 30-April 10

Re: Can't display Google Charts using $post

Posted 18 July 2013 - 09:52 AM

Can you post the entire text from the error? What page does the error originate from?

This error may come from the google api.

This post has been edited by laytonsdad: 18 July 2013 - 09:53 AM

Was This Post Helpful? 0
  • +
  • -

#5 kim_barcelona555  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 54
  • Joined: 01-July 13

Re: Can't display Google Charts using $post

Posted 18 July 2013 - 03:44 PM

View Postlaytonsdad, on 18 July 2013 - 09:52 AM, said:

Can you post the entire text from the error? What page does the error originate from?

This error may come from the google api.


Well, that's the only error that I can see. And it's appearing on my client side. The n.tpl
Was This Post Helpful? 0
  • +
  • -

#6 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,851
  • Joined: 30-April 10

Re: Can't display Google Charts using $post

Posted 18 July 2013 - 04:24 PM

Is there an Error in your javascript error console?

What template engine are you using?

This post has been edited by laytonsdad: 18 July 2013 - 05:07 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1