Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know any good graph utilities?

Status
Not open for further replies.

Cineno

Programmer
Jul 24, 2006
142
US
I have a page where I need to be able to have graphs generated. I've used JPGraph before with PHP. Now I'll probably be using ASP, so I'm looking for another graphing utility I can use.

I've looked at ChartDirector. Does anyone know any other (free) ones? Thanks for any help.
 
By nature ASP has built-in support for generating MS Excel graphs. We've created some very nice ones. Here's a really rough cut from what we use to get you pointed in the right direction:
Code:
' DISPLAY CHART HERE
'################################
Set Session("FSO") = CreateObject("Scripting.FileSystemObject")

' Create a Chart Object
Set oChart = CreateObject("OWC.Chart")
Set c = oChart.Constants

' Set the different parameters for the ChartSpace
oChart.Border.Color = c.chColorNone

' Get Organization number and use it to set the Caption
sCaption = "Chart Title"

' Add a chart and set parameters for the chart
oChart.Charts.Add
oChart.Charts(0).Type = c.chChartTypeLineMarkers
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(0).Caption = "Weekly"
oChart.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, dates
oChart.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, wvals
oChart.Charts(0).SeriesCollection(0).Line.Color = "#000066"
oChart.Charts(0).SeriesCollection(0).Interior.Color = "#000066"
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(1).Caption = "Target"
oChart.Charts(0).SeriesCollection(1).SetData c.chDimCategories, c.chDataLiteral, dates
oChart.Charts(0).SeriesCollection(1).SetData c.chDimValues, c.chDataLiteral, tvals
oChart.Charts(0).SeriesCollection(1).Line.Color = "#FFCC00"
oChart.Charts(0).SeriesCollection(1).Interior.Color = "#FFCC00"
oChart.Charts(0).SeriesCollection.Add
oChart.Charts(0).SeriesCollection(2).Caption = "Annual"
oChart.Charts(0).SeriesCollection(2).SetData c.chDimCategories, c.chDataLiteral, dates
oChart.Charts(0).SeriesCollection(2).SetData c.chDimValues, c.chDataLiteral, gvals
oChart.Charts(0).SeriesCollection(2).Line.Color = "#009999"
oChart.Charts(0).SeriesCollection(2).Interior.Color = "#009999"
oChart.Charts(0).HasLegend = True
oChart.Charts(0).HasTitle = True
oChart.Charts(0).Title.Caption = sCaption

set objAxis = oChart.Charts(0).Axes(c.chAxisPositionBottom)
objAxis.HasTitle = True
objAxis.Title.Caption = "Dates"
set objFont = objAxis.Font
'objFont.size = 8
set objAxis = oChart.Charts(0).Axes(c.chAxisPositionLeft)
objAxis.HasTitle = True
objAxis.Title.Caption = "%"

' Get a temporary filename to save chart in that file
sFname = "/charts/" & Session("FSO").GetTempName & session.SessionID & ".gif"

' Export the chart to the temporary file
oChart.ExportPicture server.MapPath(sFname), "gif", 900, 500

' Create a link to the generated file
Response.Write "<img src='" & sFname & "'>"
Hope this helps you with the basic structure. You can search for information on creating Excel charts in ASP and probably find a lot of guidance. Obviously in this one we've gone through a lot of steps earlier to set up the data we're putting into the chart, but I wanted to give you something to look at that generates Excel charts without buying a component.
 
Thanks a lot for your response! This is exactly what I was looking for.

I've tried to manipulate your code and others using ASP and Excel I've found, but haven't gotten it to work yet. For example I tried the code below that I found at _________________________________________________________-
<%@ LANGUAGE="VBSCRIPT" %>
<%
' Create Object
Set MyExcelChart = CreateObject("Excel.Sheet")

' show or dont show excel to user, TRUE or FALSE
MyExcelChart.Application.Visible = True

' populate the cells
MyExcelChart.ActiveSheet.Range("B2:k2").Value = Array("Week1", "Week2", "Week3", "Week4", "Week5", "Week6", "Week7", "Week8", "Week9", "Week10")
MyExcelChart.ActiveSheet.Range("B3:k3").Value = Array("67", "87", "5", "9", "7", "45", "45", "54", "54", "10")
MyExcelChart.ActiveSheet.Range("B4:k4").Value = Array("10", "10", "8", "27", "33", "37", "50", "54", "10", "10")
MyExcelChart.ActiveSheet.Range("B5:k5").Value = Array("23", "3", "86", "64", "60", "18", "5", "1", "36", "80")
MyExcelChart.ActiveSheet.Cells(3,1).Value="Internet Explorer"
MyExcelChart.ActiveSheet.Cells(4,1).Value="Netscape"
MyExcelChart.ActiveSheet.Cells(5,1).Value="Other"

' Select the contents that need to be in the chart
MyExcelChart.ActiveSheet.Range("b2:k5").Select

' Add the chart
MyExcelChart.Charts.Add
' Format the chart, set type of chart, shape of the bars, show title, get the data for the chart, show datatable, show legend
MyExcelChart.activechart.ChartType = 97
MyExcelChart.activechart.BarShape =3
MyExcelChart.activechart.HasTitle = True
MyExcelChart.activechart.ChartTitle.Text = "Visitors log for each week shown in browsers percentage"
MyExcelChart.activechart.SetSourceData MyExcelChart.Sheets("Sheet1").Range("A1:k5"),1
MyExcelChart.activechart.Location 1
MyExcelChart.activechart.HasDataTable = True
MyExcelChart.activechart.DataTable.ShowLegendKey = True


' Save the the excelsheet to chart.xls
MyExcelChart.SaveAs "c:\chart.xls"


%>
<HTML>
<HEAD>
<TITLE>MyExcelChart</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
____________________________________________________-

I get an error at line 4 "Set MyExcelChart = CreateObject("Excel.Sheet")" saying it can't create the object. Do you know why this is?
 
You get the same error with my line?

Set oChart = CreateObject("OWC.Chart")
 
Yeah, I get this error message:
_________________________________________________
Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'OWC.Chart'

/Turnover Test/graphs.asp, line 8
_________________________________________________

Have any ideas what I need to do?
 
Well I'm not positive on the magic that uses the driver/component to create the object we're trying to work with... My first idea is to ask if you have Office/Excel installed on the web server? Perhaps without it installed it's missing the vital component.
 
OH I didn't even think about that. No, I don't think Office/Excel is installed on the server. I'll try to see if that fixes it. Thanks a lot.
 
I believe there is an option to download OWC only from MS and install it on your server. That might be nicer then installing all of Excel :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top