Solved

How to pass ASP values to a javascript Google chart

Posted on 2013-11-04
1
696 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

770 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