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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Chart with JS is possible?

Status
Not open for further replies.

Vadim

Programmer
Feb 5, 2002
75
US
I need add line chart on my page. I cannot use applet because my user do not have a java plug-in.
Is it possible to do it with javascript?
May be you know some inexpensive product that create a chart and could be located on server?
 
sure, you could do it with javascript...but you need to have the data to generate the chart first, which i'm guessing will come from a database, and if so it would be easier to create the chart server-side.

i would accomplish either method using a <div> X pixels high to represent your data


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Lining up rows of divs or columns of spans would create bar charts. If that's what you want, you can produce nicer effects by stretching tiny images in the same way.

The only way I can see of making a true line graph would be to use vectors (VML) which is supported by MSIE without plugins but I'm fairly sure Gecko cannot render this.

I do use use VML and I know it can draw the line graph using text values, but I haven't used it in that way so hopefully someone with more experience will come along and answer :)
 
Jeff, when you said <div> you min bar code?
I need a line chart. Yes, I hava a database for the chart.
 
I don't believe it, I was dismissed! :'(

You don't like vector graphics? ???

========= STUPID STRAIGHT LINE EXAMPLE ==========
<html xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot;>
<head>
<style>
v\:* { behavior: url(#default#VML); }
</style>
</head>
<body>
<v:line from=&quot;0,0&quot; to=&quot;400,400&quot;></v:line>
</body>
</html>
=================================================

So you could plot your points (with HTML or VML elements) and draw a line of best fit, or join up the dots or whatever.
 
Vadim,

>>>when you said <div> you min bar code?
no, i mean <div> with a specific width or height, like
<div style=&quot;background:#ff0000; width:20px; height:150px;&quot;></div>



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
stormbind,

VML would be IE only...divs will work cross-browser

=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Here's a pure JavaScript graphing function. It accepts an array-of-arrays, which represents a grid. Each element is a hex value, which is the color.

There is included a simple graphing function, as well as an example circle, drawn mathematically.

You can draw anything you want with this.

faq216-3516

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top