Solved

How to pass ASP values to a javascript Google chart

Posted on 2013-11-04
1
763 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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.
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.

695 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