Solved

How to pass ASP values to a javascript Google chart

Posted on 2013-11-04
1
647 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now