Is this the same chart you are trying to get to work in your other thread (
here<https://groups.google.com/forum/#!topic/google-visualization-api/YZoWgI6V190>)?
If so, you need to solve that problem before figuring out why it doesn't
display (if the chart still isn't working after you fix the DataTable
problem).
On Monday, November 11, 2013 7:22:23 AM UTC-5, mani wrote:
>
> I am using a form to take user inputs and the idea is to generate a chart
> based on the submitted values,but i am not sure how tp pass the form values
> to book_chart.php
> i have to display the chart beside the datatable.Though the Data table
> appears without any issues but the chart is not displayed,pls suggest/
>
> function drawChart() {
> var json = $.ajax({
> url: 'book_chart.php', // make this url point to the data file
> dataType: 'json',
> async: false
> }).responseText;
>
>
>
> --------------------------------------------------------------------------------------
> code is below
>
> -------------------------------------------------------------------------------------
>
> <html>
> <head>
> <script type="text/javascript"
> src="js/DataTables/media/js/jquery.js"></script>
> <script type="text/javascript"
> src="js/DataTables/media/js/jquery.dataTables.js"></script>
> <script type="text/javascript" src="googlejs/jsapi.js"></script>
> <script type="text/javascript" src="googlejs/jquery.min.js"></script>
> <script type="text/javascript">
> // Load the Visualization API and the piechart package.
> google.load('visualization', '1', {'packages':['corechart']});
>
> // Set a callback to run when the Google Visualization API is loaded.
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
> var json = $.ajax({
> url: 'book_chart.php', // make this url point to the data file
> dataType: 'json',
> async: false
> }).responseText;
> // Create our data table out of JSON data loaded from server.
> var data = new google.visualization.DataTable(json);
> var options = {
> title: 'bookwise details',
> titleTextStyle: {color: 'black'},
> vAxis: { title: "Amount in Rs.", titleTextStyle: {color: 'blue',fontSize:
> 12,bold:1} },
> hAxis: { title: "books",titleTextStyle: {color: 'green',fontSize:
> 12,bold:1} },
> is3D: 'true',
> width: 900,
> height: 600,
> fontSize: 12,
> };
> // Instantiate and draw our chart, passing in some options.
> //do not forget to check ur div ID
> var chart = new
> google.visualization.PieChart(document.getElementById('chart_div'));
> chart.draw(data, options);
>
> //setInterval(drawChart, 500 );
> }
> </script>
> <script>
> $(document).ready(function(){
> $('#bookTable').dataTable({
> "sPaginationType": "full_numbers"
> });
> });
> </script>
> <link href="css/styles.css" rel="stylesheet" type="text/css">
> <style type="text/css" title="currentStyle">
> @import "js/DataTables/media/css/demo_page.css";
> @import "js/DataTables/media/css/demo_table.css";
> </style>
>
> <title>Foreign Remittance</title>
> <style>
> html,
> body { height: 100%; padding:0;margin:0;background-color:#FFFFFF
> ;font-family: 'Source Sans Pro', sans-serif;}
> #parentDiv {height:100%;width:1024px;margin:auto;}
> #headerDiv {height: 100px;background:#FFFFFF;width: 1024px;}
>
> #contentDiv {width:400px;height:400px;background-color:#BFDDE3;border:1px
> solid;margin:30px auto 30px auto;}
> #linkDiv {width:400px;height:400px;text-align:center;}
> #logoDiv {height: 100px; width: 1024px;}
> th.Branch{
> width: 15%
> }
> #dataDiv {style="margin-top:2000px";}
> #barDiv {height:30px;background-color:#004D95;width:1024px;}
> #chart_div { float:left; width:1024px;}
> </style>
> </head>
>
> <body id="dt_example">
> <center>
> <div id="parentDiv" >
>
> <div id="headerDiv">
> <div id="logoDiv" style="float:left;position:relative;">
> <img align="left" height="100px" alt="State book of Travancore logo"
> src="images/sbt_main.jpg" />
> <img align="left" height="100px" alt="State book of Travancore logo"
> src="images/fr.png" style="margin-left:44px;" />
> </div>
> </div>
>
> <div id='barDiv'>
> <div id='cssmenu'>
> <ul>
> <li ><a href='index.html'><span style="color:white">Home</span></a></li>
>
> <li ><a href='index.html'><span
> style="color:white">Back</span></a></li>
> </ul>
> </div>
> </div>
>
> <div style="padding-top:10px;">
> <?php
>
>
> include ("db/Config.php");
> $slab = $_POST['slabs'];
> $from = $_POST['from'];
> $to = $_POST['to'];
>
> //echo $slab;
> //echo $from;
> //echo $to;
> $f_dd=substr($from,0,2);
> $f_mm=substr($from,3,2);
> $f_yyyy=substr($from,6,4);
> $fdate_new= $f_yyyy."-".$f_mm."-".$f_dd;
> $t_dd=substr($to,0,2);
> $t_mm=substr($to,3,2);
> $t_yyyy=substr($to,6,4);
> $tdate_new= $t_yyyy."-".$t_mm."-".$t_dd;
> switch ($slab)
> {
> case "slab1":
>
> $slb = "Displaying books with total transaction between Rs.50000 and
> Rs.500000 from $from to $to";
> break;
> case "slab2":
>
> $slb = "Displaying books with total transaction between Rs.500000 and
> Rs.2500000 from $from to $to";
> break;
> case "slab3":
>
> $slb = "Displaying books with total transaction greater than Rs.2500000
> from $from to $to";
> break;
> case "slab4":
>
> $slb = "Consolidated list of books with their total transations from
> $from to $to";
> break;
> default:
> echo "Slab not selected !!!!!";
> }
> //or die(mysql_error());
> //$info = mysql_fetch_array( $data );
> //$msg = .$slb.;
> echo "<span style='font-weight:600;font-family: Times New Roman,Arial,
> Helvetica, sans-serif;font-size:13'>$slb</span>";
>
> ?>
> </div>
>
> <div id='container' style="padding-top:20px;" >
> <table cellpadding=5 id='bookTable' class='display'>
> <thead><tr>
> <th>book</th>
> <th>Amount in Rs.</th> </tr>
> </thead>
> <tbody align="center">
> <?php
>
> include ("db/Config.php");
> ini_set('session.cache_limiter', 'private');
> session_start();
>
> $slab = $_POST['slabs'];
> $from = $_POST['from'];
> $to = $_POST['to'];
>
> $f_dd=substr($from,0,2);
> $f_mm=substr($from,3,2);
> $f_yyyy=substr($from,6,4);
> $fdate_new= $f_yyyy."-".$f_mm."-".$f_dd;
> $t_dd=substr($to,0,2);
> $t_mm=substr($to,3,2);
> $t_yyyy=substr($to,6,4);
> $tdate_new= $t_yyyy."-".$t_mm."-".$t_dd;
> $_SESSION['f_new'] = $fdate_new;
> $_SESSION['t_new'] = $tdate_new;
>
> switch ($slab)
> {
> case "slab1":
> $data = mysql_query("select b.ifbook as book,sum(a.amt) as
> amt,substring(a.ifsc,1,4) as code from mtrans a JOIN ifsc b on
> b.ifscd=a.ifsc and orgdate between '$fdate_new' and '$tdate_new' where
> b.ifbook not like '%TRAVAN%' group by book having (amt between 50000 and
> 500000)order by amt desc");
> $data1 = mysql_query("select a.obook as code,sum(a.amt) as amt from
> mtrans a where orgdate between '$fdate_new' and '$tdate_new' and a.obook <>
> '1' group by a.obook having (amt between 50000 and 500000)");
>
> break;
> case "slab2":
> $data = mysql_query("select b.ifbook as book,sum(a.amt) as
> amt,substring(a.ifsc,1,4) as code from mtrans a JOIN ifsc b on
> b.ifscd=a.ifsc and orgdate between '$fdate_new' and '$tdate_new' where
> b.ifbook not like '%TRAVAN%' group by book having (amt between 500000 and
> 2500000) order by amt desc");
> $data1 = mysql_query("select a.obook as code,sum(a.amt) as amt from
> mtrans a where orgdate between '$fdate_new' and '$tdate_new' and a.obook <>
> '1' group by a.obook having (amt between 500000 and 2500000)");
> break;
> case "slab3":
> $data = mysql_query("select b.ifbook as book,sum(a.amt) as
> amt,substring(a.ifsc,1,4) as code from mtrans a JOIN ifsc b on
> b.ifscd=a.ifsc and orgdate between '$fdate_new' and '$tdate_new' where
> b.ifbook not like '%TRAVAN%' group by book having (amt >2500000) order by
> amt desc");
> $data1 = mysql_query("select a.obook as code,sum(a.amt) as amt from
> mtrans a where orgdate between '$fdate_new' and '$tdate_new' and a.obook <>
> '1' group by a.obook having (amt >2500000)");
> break;
> case "slab4":
> $data = mysql_query("select b.ifbook as book,sum(a.amt) as
> amt,substring(a.ifsc,1,4) as code from mtrans a JOIN ifsc b on
> b.ifscd=a.ifsc and orgdate between '$fdate_new' and '$tdate_new' where
> b.ifbook not like '%TRAVAN%' group by book order by amt desc");
> $data1 = mysql_query("select a.obook as code,sum(a.amt) as amt from
> mtrans a where orgdate between '$fdate_new' and '$tdate_new' and a.obook <>
> '1' group by a.obook");
>
> break;
> default:
> echo "Slab not selected !!!!!";
> }
> $row = mysql_fetch_assoc($data);
> //$row1 = mysql_fetch_assoc($data1);
> if($row != NULL){
> while($info = mysql_fetch_array( $data ))
> {
> $id = $info['book'];
> $cd = $info['code'];
>
>
> $msg .= "<tr>";
> $msg .= "<td ><a href=\"mbranch_details.php?ifsc_code=" . $cd
> ."&fdate=".$fdate_new."&tdate=".$tdate_new."&slab=".$slab."\">" . $id .
> "</a></td>";
> $msg .= "<td align='right'>". $info['amt'] . " </td></tr>";
> }
> //$msg .= "</table>";
> //echo $msg;
> } else {
> echo "<script>alert('No transactions available during the selected
> period ,Click OK to go back to Home page!!');window.location.href =
> 'index.html';</script>";
>
> }
> //if($row1 != NULL){
> while($info = mysql_fetch_array( $data1 ))
> {
>
> $amt = $info['amt'];
> $msg .= "<tr>";
> $msg .= "<td ><a
> href=\"mbranch_details.php?ifsc_code=SBTR&fdate=".$fdate_new."&tdate=".$tdate_new."&slab=".$slab."\">STATE
>
> book OF TRAVANCORE</a></td>";
> $msg .= "<td align='right'>". $info['amt'] . " </td></tr>";
> //echo $msg;
>
> }
> // }
> echo $msg;
>
> ///code for chart
> include_once("db/db.php");
>
> $mysqli = new mysqli($db_host, $db_username, $db_password, $db_database);
>
> if (mysqli_connect_errno()) {
> printf("Connect failed: %s\n", mysqli_connect_error());
> exit();
> }
> if ($result = $mysqli->query($data)) {
> {
> $rows = array();
> $table = array();
> $table['cols'] = array(
> array('label' => 'book', 'type' => 'string'),
> array('label' => 'Amount', 'type' => 'number')
> );
>
> while ($row = $result->fetch_assoc()) {
> $temp = array();
> $temp[] = array('v' => (string) $row['book']);
> $temp[] = array('v' => (float) $row['Amount']);
> $rows[] = array('c' => $temp);
> }
> }
> }
>
> if ($result1 = $mysqli->query($data1)) {
> {
> while ($row = $result1->fetch_assoc()) {
> $temp1 = array();
> $temp1[] = array('v' => "Books");
> $temp1[] = array('v' => (float) $row['Amt']);
> $rows[] = array('c' => $temp1);
> }
> }
> }
>
> $table['rows'] = $rows;
> $jsonTable = json_encode($table);
> echo $jsonTable;
> ?>
> </tbody>
> </table>
> </div>
> </div>
> </center>
>
> <div id="chart_div" style="width:800px; margin:0 auto;"></div>
> </body>
> </html>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.