Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Problem loading array into google chart graph

$
0
0

Hi, I'm trying to create a google chart inside a webview for my app. the sample code works fine, but I'm trying to pull the data from sqlite database, push it into an array and then populate the table data in the html file.

Right now nothing is appearing on the webview. Even the Ti.API.console calls in the html file are not printing to the console log, so I'm not sure where I'm going wrong.

My array data after pushing into an array looks like this

(
[INFO] :       "06-12-2014",
[INFO] :       162,
[INFO] :       204,
[INFO] :       90,
[INFO] :       81,
[INFO] :       0
[INFO] :   )
[INFO] :   (
[INFO] :       "06-18-2014",
[INFO] :       153,
[INFO] :       215,
[INFO] :       96,
[INFO] :       93,
[INFO] :       0
[INFO] :   )
[INFO] :   (
[INFO] :       "06-24-2014",
[INFO] :       153,
[INFO] :       215,
[INFO] :       96,
[INFO] :       93,
[INFO] :       0
[INFO] :   )
Here is the html file
<html>
  <head>
    <script type="text/javascript"
          src="https://www.google.com/jsapi?autoload={
            'modules':[{
              'name':'visualization',
              'version':'1',
              'packages':['corechart']
            }]
          }"></script>
 
    <script type="text/javascript">
      google.setOnLoadCallback(drawChart);
 
      function drawChart() {
          var data = new google.visualization.DataTable();
          data.addColumn('string', 'Date');
          data.addColumn('number', 'Squat');
          data.addColumn('number', 'Bench');
          data.addColumn('number', 'Press');
          data.addColumn('number', 'Deadlift');
          data.addColumn('number', 'PClean');
 
 
            SS.log("chartdata length: " + SS.chartData.length);
          for(i = 0; i < SS.chartData.length; i++){
            data.addRow([SS.chartData[i][0], SS.chartData[i][1], SS.chartData[i][2], SS.chartData[i][3], SS.chartData[i][4], SS.chartData[i][5]]);
        }
 
        var options = {
          title: 'Company Performance',
          curveType: 'function',
          legend: { position: 'bottom' }
        };
 
        var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
 
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="curve_chart" style="width: '100%'; height: '80%"></div>
  </body>
</html>

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>