Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2004, 08:11 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default line graph

Hi all,

Im trying to draw a line graph using asp. Ive downloaded the required dll file, however whenever i try to run the code i get the error message 20/07/04 is not a valid floating point. Below is my code






<%@ language=vbscript %>

<%

Dim strConnect

%>


<!-- metadata type="typelib"
              file="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
  'This script generates a line graph using all the data from the database.
  'It shows 4 different lines for the 4 different sets of values.
  'Instead of showing numbers along the x-axis it uses the names of the days.

  Response.Expires = 0
  Response.Buffer = true
  Response.Clear

  'Use one of the following lines depending on the component version
  'Set Chart = Server.CreateObject("csDrawGraph.Draw")
  Set Chart = Server.CreateObject("csDrawGraphTrial.Draw")


   Set objRS = Server.CreateObject("ADODB.Recordset")
          strSql = "SELECT * FROM tbl_furnace_test ORDER BY Date"
          objRS.Open strSql, strConnect


    While Not objRS.Eof
      Chart.AddPoint CLng(CDate(objRS("Date"))), CInt(objRS("Case_Depth_Flank")), "ff0000", "Red"
      Chart.AddPoint CLng(CDate(objRS("Date"))), CInt(objRS("Case_Depth_Root")), "0000ff", "Blue"

      'Chart.AddXValue objRS("Date"), objRS("Date")
      objRS.MoveNext
    Wend

  'Close the database at the first opportunity
  objRS.Close


  'The following component properties are set.
  'XOffset starts the x-axis at 1 instead of 0.
  'XTop and XGrad calibrate the x-axis instead of allowing the component to do it.
   Chart.UseXAxisDates = true
  Chart.Title = "Case Depth"
  Chart.TitleX = 100
  Chart.YAxisText = "Case Depth"
  Chart.OriginY = 220

  Chart.XOffset = CLng(CDate("19-07-04"))
  Chart.XTop = CLng(CDate("24-07-04"))
  Chart.XGrad = 1
  Chart.UseXAxisLabels = true
  Chart.LineWidth = 2
  Chart.PointSize = 3
  Chart.PointStyle = 1

  'Finally the image is sent to the browser in GIF format
  Response.ContentType = "image/gif"
  Response.BinaryWrite Chart.GIFLine
  Response.End
%>

Any help will be much appreciated, oh all the dates in the database are stored in the format dd-mm-yy. Is there any easier way of doing this?

many thanks
Paul

 
Old July 22nd, 2004, 08:39 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I don't know how the component wants data to be passed to it. But the "Date" field of the table tbl_furnace_test is storing a date value which you are passing to the function CLNG in the following piece of code.

 
Quote:
quote:
Quote:
Chart.AddPoint CLng(CDate(objRS("Date"))), CInt(objRS("Case_Depth_Flank")), "ff0000", "Red"
      Chart.AddPoint CLng(CDate(objRS("Date"))), CInt(objRS("Case_Depth_Root")), "0000ff", "Blue"
This is wrong.

If you want to plot dates on the x axis, you need only pass the date part of the value. You can use the function day(<date>) for this purpose. Also CLNG is not required.
 
Old July 22nd, 2004, 08:43 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
thanks for getting back to me, sorry im being a bit thick....the component wants all information to be a numerical value ie int, how would i convert the date into a numerical value?

 
Old July 22nd, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

But the function CLNG cannot convert a date value to an integer. You will have to extract date/month/year part of the date value.

day(<date>) will extract the date part of date value.
month(<date>) will extract the month part of date value.
year(<date>) will extract the year part of date value.
 
Old July 22nd, 2004, 09:09 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok thansk ill give it whirl.

thanks again






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to draw indicator line in owc line chart AlexOo General .NET 0 July 9th, 2007 10:32 PM
Reading a string from line by line vaidyapragati ASP.NET 2.0 Professional 1 May 3rd, 2007 08:43 AM
How to read file line by line in EVC++ iriskab Visual C++ 0 September 27th, 2006 01:39 PM
Reading line by line from a .txt file x_ray VB.NET 2002/2003 Basics 5 February 10th, 2006 01:55 PM
graph pab006 Classic ASP Basics 1 April 30th, 2004 10:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.