Solved

How to pass ASP values to a javascript Google chart

Posted on 2013-11-04
1
711 Views
Last Modified: 2013-11-04
How do I get my asp values to pass into the google chart below?


<%
Set rsset = Server.CreateObject("ADODB.Recordset")
 
	sql="SELECT builder, ytd_production, weekly_production, report_date "_
	& "FROM velocity_tick_history "_
	& "ORDER BY weekly_production DESC"
	
rsset.Open sql, conn
%>

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable
        ([
         ['Builder','YTD', 'Week'],
         <%
         do while not rsset.eof
	         %>
	         [<%=rsset("builder")%>,<%=rsset("ytd_production")%>,<%=rsset("weekly_production")%>],
	         
	         <%
	         rsset.movenext
         loop
         %>
         
         ['ORL',66.36,68.94]
        ]);

        var options = {
          title: 'Velocity Tick History Report - Week of 10/21/13 - 10/25/13',
          vAxis: {title: 'Builder',  titleTextStyle: {color: 'red'}}
          //xAxis: {title: 'Production Percentage', titleTextStyle: {color: 'blue'}}
        };

        var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 700px;"></div>
  </body>
</html>

Open in new window

0
Comment
Question by:mfinocc
1 Comment
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39622571
What does your rendered html look like and where is the error in your rendered html?

Maybe this
 <%
         do while not rsset.eof
	         %>
	         [<%=rsset("builder")%>,<%=rsset("ytd_production")%>,<%=rsset("weekly_production")%>],
	         
	         <%
	         rsset.movenext
         loop
         %>

Open in new window

should be
 <%
            do while not rsset.eof
	      %>[<%=rsset("builder")%>,<%=rsset("ytd_production")%>,<%=rsset("weekly_production")%>]<%
                if not rsset.eof then
                     response.write "," ' only add the comma if there is more data
                end if
	         rsset.movenext
         loop
         %>

Open in new window

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
html input 8 44
Implement a function similar to grep in vanilla Javascript 3 22
asp.net open new page without popup blocker 8 19
Button on Table, name table1 not working 4 22
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question