PDA

View Full Version : Drawing charts with ASP



Zvona
07-04-2002, 02:52 PM
I need to build up an application, which will draw stock value charts dynamically, based on resultset from db.

There are already many applications (http://www.aspobjects.com/ASP_Components/graphics_charts/charts/) which would do the job, but their price is a bit salty. Besides I like doing everything by myself, allowing endless possibilities to customize charts.

Is there any functions I could use for drawing lines between points? I mean I can bring the offset points for stock values, but I need something for connecting the points.

All kind of suggestions are well heard, so bring 'em on. :p

QuackHead
07-04-2002, 03:04 PM
Zvona,

you have a cool idea, and I wish I could help you out.

My guess is that they're using a server component to do this.

I don't know of a way to accomplish this manualy.. I wish I did.

~Quack

Roelf
07-05-2002, 06:31 AM
Hi, if you have Excel installed, it should be easy, you can create an excel activeXobject in a web page, using javascript. then you have access to all functionality of excel, you can create a chart (do you need more options then excel gives you) then save the chart as a file (save for web or something like that) this can all be done serverside, return the filename to the client an voila, your graph is there

Zvona
07-05-2002, 09:51 AM
Originally posted by Roelf
Hi, if you have Excel installed, it should be easy, you can create an excel activeXobject in a web page, using javascript. then you have access to all functionality of excel, you can create a chart (do you need more options then excel gives you) then save the chart as a file (save for web or something like that) this can all be done serverside, return the filename to the client an voila, your graph is there

Hmm..sounds handy. But I'm not very familiar with activeX objects. Are there any tutorials (besides at MSDN) that would help me on my "quest"? :)

Flamerule
07-05-2002, 11:07 AM
I think you should be able to do it with javascript like that :
http://www.javascriptkit.com/script/script2/graphit.shtml
But I don't think this is exactly the kind of graph you wanted.

You could probably those lines in Flash since it is vector based but I don't know how...

Zvona
07-05-2002, 02:14 PM
Originally posted by Flamerule
I think you should be able to do it with javascript like that :
http://www.javascriptkit.com/script/script2/graphit.shtml
But I don't think this is exactly the kind of graph you wanted.

You could probably those lines in Flash since it is vector based but I don't know how...

Currently I'm doing more efficient graph, where the details (date & value) are displayed in status bar when mouse is moved over graph (every day and dot is unique table cell). However, I'm more after a graph like on http://www.eqonline.fi

Thanks for your effort Flamerule, though.

head8k
07-05-2002, 03:38 PM
Here's some code I wrote a while ago to draw a bar chart. It's not exactly what you want but it might give you some inspiration. You'll need a 1x1 pixel gif in the same directory called "red.gif" to give the bars some colour.


<html>

<head>
<title>Bar Chart</title>
</head>

<body>

<table width="500" border="0" cellspacing="0" cellpadding="1">

<%
call makeBar (10, "chose this option")
call makeBar (24, "did this")
call makeBar (31, "like yoghurt")
call makeBar (43, "are aliens")
call makeBar (88, "think this code is good")
%>

</table>

</body>
</html>

<%
Function makeBar (percentage, description)

Response.Write("<tr>" &vbcrlf)
Response.Write("<td width=""5"" height=""10"">&nbsp;</td>" &vbcrlf)
Response.Write("<td width=""200"" height=""10""><img src=""red.gif"" height=""10"" width=""" & (percentage*2) & """></td>" &vbcrlf)
Response.Write("<td width=""295"" height=""10""><font face=""arial"" size=""1"">" &percentage& "% " &description& "</font></td>" &vbcrlf)
Response.Write("</tr>" &vbcrlf &vbcrlf)

End function
%>

whammy
07-08-2002, 04:40 AM
The only decent things graphwise I've been able to come up with in ASP are horizontal or vertical bar charts (using different colors, and printable regardless of browser)...

Anything else is a real pain, especially when you don't really have the time to research it... but there are some tools (third-party software you can use for pie charts and stuff like that, that I've seen)... I believe I saw some references to those on http://www.haneng.com - disregarding the guy's english, he seems to know his stuff ;)