okay...it took me all day, but I got it formatted with this:
<?php
include("includes/connect.php");
//include("linechart30.php");
$query = $_GET['query'];
$query = strtoupper($query);
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$chrt30dtsp= $chrt30dtsp= "SELECT `year`,`month`,`day`,
`open_short_percent` , `total_short_percent`
FROM `tsp30d`
WHERE `symbol` = '$query' ORDER BY `date` ASC";
$result = mysql_query($chrt30dtsp);
$table = array();
$table['cols'] = array(
array('label' => 'date', 'type' => 'date'),
array('label' => 'Open Short Pct', 'type' =>
'number'),
array('label' => 'Total Short Pct', 'type' =>
'number')
);
$rows = array();
while($r = mysql_fetch_assoc($result)) {
$temp = array();
$r['date']= array($r['year'], $r['month'], $r['day']);
$r['date'] = implode(",", $r[('date')]);
$temp[] = array('v' =>"Date(".$r['date'].")");
$temp[] = array('v' => (float) $r['open_short_percent']);
$temp[] = array('v' => (float) $r['total_short_percent']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonData = json_encode($table);
echo $jsonData;
?>
Output now is:
{"cols":[{"label":"date","type":"date"},{"label":"Open Short
Pct","type":"number"},{"label":"Total Short
Pct","type":"number"}],"rows":[{"c":[{"v":"Date(2014,10,20)"},{"v":50.28},{"v":43.92}]},{"c":[{"v":"Date(2014,10,21)"},{"v":48.84},{"v":52.51}]},{"c":[{"v":"Date(2014,10,22)"},{"v":62.18},{"v":52.88}]},{"c":[{"v":"Date(2014,10,23)"},{"v":74.94},{"v":138.07}]},{"c":[{"v":"Date(2014,10,27)"},{"v":78.98},{"v":16.18}]},{"c":[{"v":"Date(2014,10,28)"},{"v":54.11},{"v":39.22}]},{"c":[{"v":"Date(2014,10,29)"},{"v":58.77},{"v":57.33}]},{"c":[{"v":"Date(2014,10,30)"},{"v":43.02},{"v":41.5}]},{"c":[{"v":"Date(2014,10,31)"},{"v":61.03},{"v":54.9}]},{"c":[{"v":"Date(2014,11,3)"},{"v":52.6},{"v":69.08}]},{"c":[{"v":"Date(2014,11,5)"},{"v":66.67},{"v":58.63}]},{"c":[{"v":"Date(2014,11,6)"},{"v":48.44},{"v":47.81}]},{"c":[{"v":"Date(2014,11,7)"},{"v":48.57},{"v":43.04}]},{"c":[{"v":"Date(2014,11,10)"},{"v":53.45},{"v":42.73}]},{"c":[{"v":"Date(2014,11,11)"},{"v":62.89},{"v":64.35}]},{"c":[{"v":"Date(2014,11,12)"},{"v":67.48},{"v":69.58}]},{"c":[{"v":"Date(2014,11,13)"},{"v":58.34},{"v":62.46}]},{"c":[{"v":"Date(2014,11,14)"},{"v":54.91},{"v":54.93}]},{"c":[{"v":"Date(2014,11,17)"},{"v":48.75},{"v":36.2}]}]}
So now with the above html code unchanged, where to I go from here to get
the chart to render??
On Wed, Nov 19, 2014 at 9:40 AM, 'Sergey Grabkovsky' via Google
Visualization API <[email protected]> wrote:
> Don't worry about it. I work on the chart library, so I know it inside and
> out. Now, I don't really know PHP, but it seems like you should just be
> able to do something like:
> while($r = mysql_fetch_assoc($result)) {
> $temp = array();
> $temp[] = array('v' => "Date(" . str_replace("-", ",",
> $r['date']) . ")");
> $temp[] = array('v' => (float) $r['open_short_percent']);
> $temp[] = array('v' => (float) $r['total_short_percent']);
> $rows[] = array('c' => $temp);
> }
>
> On Wed Nov 19 2014 at 12:48:01 AM Dom Laviola <[email protected]>
> wrote:
>
>> Now I feel worse.. Definitely sick. That's the story I'm sticking to
>> anyway....I see the fiddle...it's lovely....especially seeing my data
>> there...I am still stuck on the original problem of how to convert what I
>> have to what you acheived..in what I gather took all of 60 seconds to
>> accomplish....I have found a host of posts of similar people having the
>> same problem yet have not found a single solution to it. That said, the
>> database that I'm pulling the data from, allows me to change the query from
>> `date` (which I can extract() from.... to `year`, `month`,` day` as 3
>> new (INT) columns from `date` . Near as I can tell thus far my only
>> option is to toss everything I have and create a .csv file, that I can then
>> apply $row = str_replace("-", "", $row); to...and then convert that
>> to json....I cant see that taking 60 seconds so what am I missing here?
>>
>>
>> On Tuesday, November 18, 2014 4:21:50 PM UTC-5, Dom Laviola wrote:
>>>
>>> I've been up so long on this I cant read the text anymore. Please help:
>>>
>>> *Here's the html:*
>>>
>>> <!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">
>>> <html>
>>> <head>
>>>
>>> <title>RealShortData.Com</title>
>>> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
>>>
>>> <!--Load the Ajax API-->
>>>
>>> <script type="text/javascript" src="https://www.google.com/jsapi
>>> "></script>
>>> <script type="text/javascript" src="http://ajax.googleapis.co
>>> m/ajax/libs/jquery/1/jquery.min.js"></script>
>>>
>>> <script type="text/javascript">
>>>
>>> google.load('visualization', '1', {'packages':['corechart','geoc
>>> hart','table']});
>>>
>>> // Set a callback to run when the Google Visualization library is
>>> loaded.
>>>
>>> google.setOnLoadCallback(drawChart);
>>> function drawChart() {
>>> var jsonData = $.ajax({
>>> url: "functions/json30.php",
>>> dataType: "json",
>>> async: false
>>> }).responseText;
>>>
>>>
>>> var data = new google.visualization.DataTable
>>> (JSON.parse(jsonData);
>>>
>>> var options = {
>>> title: 'Short Volume Percentage Breakdown'
>>> };
>>>
>>> var chart = new google.visualization.LineChart(document.
>>> getElementById('chart_div'));
>>> chart.draw(data, options);
>>> }
>>>
>>> </script>
>>>
>>> <style type="text/css">
>>>
>>> body {
>>> background-color: #f0f0f2;
>>> margin: 0;
>>> padding: 0;
>>> font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-
>>> serif;
>>> }
>>>
>>>
>>> a:link, a:visited {
>>> color: #38488f;
>>> text-decoration: none;
>>> }
>>>
>>> </style>
>>> </head>
>>> <header>
>>>
>>> <divid="headerdiv">
>>>
>>> <h1>RealShortData.com</h1>
>>> <p>Coming Soon!</p>
>>> <img src="includes/bar1.png" style="float:center">
>>>
>>> </div>
>>> <br>
>>> </br>
>>> <divid="searchdiv">
>>> <h3>Short Volume & Dark Pool Volume Search</h3>
>>> <form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
>>> Enter Ticker Symbol: <input type="text" name="query" />
>>> <input type="submit" value="Search" /></form>
>>> <img src="includes/bar1.png" style="float:center">
>>> </div>
>>> </header>
>>> <?php
>>> include("functions/json30.php");
>>> ?>
>>> <body>
>>> <div id="chart_div" style="width: 900px; height: 500px;"></div>
>>> </body>
>>> </html>
>>>
>>>
>>> *And the php*
>>>
>>> <?php
>>>
>>> include("includes/connect.php");
>>> //include("linechart30.php");
>>> $query = $_GET['query'];
>>> $query = strtoupper($query);
>>> $query = htmlspecialchars($query);
>>> $query = mysql_real_escape_string($query);
>>>
>>> $chrt30dtsp= "SELECT `date`, `open_short_percent` ,
>>> `total_short_percent`
>>> FROM `tsp30d`
>>> WHERE `symbol` = '$query' ORDER BY `date` ASC";
>>> $result = mysql_query($chrt30dtsp);
>>> $table = array();
>>> $table['cols'] = array(
>>> array('label' => 'date', 'type' => 'date'),
>>> array('label' => 'Open Short Pct', 'type' =>
>>> 'number'),
>>> array('label' => 'Total Short Pct', 'type' =>
>>> 'number')
>>> );
>>> $rows = array();
>>> while($r = mysql_fetch_assoc($result)) {
>>> $temp = array();
>>> $temp[] = array('v' => $r['date']);
>>> $temp[] = array('v' => (float) $r['open_short_percent']);
>>> $temp[] = array('v' => (float) $r['total_short_percent']);
>>> $rows[] = array('c' => $temp);
>>> }
>>> $table['rows'] = $rows;
>>>
>>> $jsonData = json_encode($table);
>>>
>>> echo $jsonData;
>>> ?>
>>>
>>>
>>> *and the result set:*
>>>
>>> RealShortData.com
>>>
>>> Coming Soon!
>>>
>>>
>>> Short Volume & Dark Pool Volume SearchEnter Ticker Symbol:
>>> {"cols":[{"label":"date","type":"date"},{"label":"Open Short
>>> Pct","type":"number"},{"label":"Total Short
>>> Pct","type":"number"}],"rows":[{"c":[{"v":"2014-10-20"},{"v"
>>> :50.28},{"v":43.92}]},{"c":[{"v":"2014-10-21"},{"v":48.84},{
>>> "v":52.51}]},{"c":[{"v":"2014-10-22"},{"v":62.18},{"v":52.88
>>> }]},{"c":[{"v":"2014-10-23"},{"v":74.94},{"v":138.07}]},{"c"
>>> :[{"v":"2014-10-27"},{"v":78.98},{"v":16.18}]},{"c":[{"v":"
>>> 2014-10-28"},{"v":54.11},{"v":39.22}]},{"c":[{"v":"2014-10-
>>> 29"},{"v":58.77},{"v":57.33}]},{"c":[{"v":"2014-10-30"},{"v"
>>> :43.02},{"v":41.5}]},{"c":[{"v":"2014-10-31"},{"v":61.03},{
>>> "v":54.9}]},{"c":[{"v":"2014-11-03"},{"v":52.6},{"v":69.08}
>>> ]},{"c":[{"v":"2014-11-05"},{"v":66.67},{"v":58.63}]},{"c":[
>>> {"v":"2014-11-06"},{"v":48.44},{"v":47.81}]},{"c":[{"v":"
>>> 2014-11-07"},{"v":48.57},{"v":43.04}]},{"c":[{"v":"2014-11-
>>> 10"},{"v":53.45},{"v":42.73}]},{"c":[{"v":"2014-11-11"},{"v"
>>> :62.89},{"v":64.35}]},{"c":[{"v":"2014-11-12"},{"v":67.48},{
>>> "v":69.58}]},{"c":[{"v":"2014-11-13"},{"v":58.34},{"v":62.
>>> 46}]},{"c":[{"v":"2014-11-14"},{"v":54.91},{"v":54.93}]},{"
>>> c":[{"v":"2014-11-17"},{"v":48.75},{"v":36.2}]}]}
>>>
>>> I'm stuck and exhausted///please help//
>>>
>>> Thank you in advance.....
>>>
>>>
>>> --
>> 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 google-visualization-api@
>> googlegroups.com.
>> Visit this group at http://groups.google.com/
>> group/google-visualization-api.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Visualization API" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-visualization-api/ux2Fz1BFwVg/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/d/optout.
>
--
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/d/optout.