473,609 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to draw a line graph using javascript

Hi all,
I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.

Thanks,
Srinivas

Oct 25 '05 #1
11 14877
srinivas wrote on 25 okt 2005 in comp.lang.javas cript:
I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.


For IE and probably other browsers too:

<http://groups.google.com/group/micro...ipting.jscript
/msg/2eb29ecafa6105b f>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 25 '05 #2

Evertjan. wrote:
srinivas wrote on 25 okt 2005 in comp.lang.javas cript:
I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.


For IE and probably other browsers too:

<http://groups.google.com/group/micro...ipting.jscript
/msg/2eb29ecafa6105b f>

Yes, you sometimes can create a simple graph with JS as suggested.
However if you do much of this, or wish to graph complex curves or
data-fit the curve to many points with some scatter, you need a math
program. The commercial programs are rather expensive. However you can
find a few free ones such as DataPlot. Such programs usually use a
higher level language such as Fortran or C+, but they are compiled so
that you do not have to have a compiler for the language installed on
your PC, and you do not have to know anything about a higher level
language to use them. These programs will draw the curve, show
individual data points if desired, and give the numerical units and
labels. Then you just use an image program to adjust the size as
desired and output as a jpg or other format suited for the web. This
method also has the advantage that it will work on any browser that can
view a jpg, even if script is turned off. It also saves you a large
amount of time if you use plots on the web very often. The down side is
that it can take a bit of time to learn how to use the math program the
first time.

Oct 25 '05 #3
srinivas said the following on 10/25/2005 11:04 AM:
Hi all,
I have one requirement.
And it is an impossible requirement.
Is there any way to create a line graph using javascript.
Yes.
If it is please send me the sample code.
Search the archives, produce your first attempt, post it here. This is a
Usenet discussion group, not a free "do my homework for me" group.
But the thing is it should work in all browsers.


That "thing" is what makes your requirement impossible.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 25 '05 #4
VK
> I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.


Look at:
<http://www.geocities.c om/schools_ring/archives/VML_SVG.html>
(click on graph canvas to mark new points)

You can get the sample from:
<http://www.geocities.c om/schools_ring/archives/VML_SVG.zip>

This VML script will work by default (no extra installations needed)
for all IE users (~82%)

Add SVG equivalents to cover the rest of the Web. For now it will
require SVG plugin installation. But the incoming major release of
FireFox (1.5) will have SVG support build-in.

Between VML & SVG (build-in or plugin) you cover all the web except
terminal browsers and few deviants you can crew on.

Oct 25 '05 #5
VK
> few deviants you can crew on.

Just got on me that it sounds ambiguous. Of course I did not mean any
physical impairment but people who prefer to use some totally fantastic
browsers.

Oct 25 '05 #6

cw******@yahoo. com wrote:
Evertjan. wrote:
srinivas wrote on 25 okt 2005 in comp.lang.javas cript:
I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.


For IE and probably other browsers too:

<http://groups.google.com/group/micro...ipting.jscript
/msg/2eb29ecafa6105b f>

Yes, you sometimes can create a simple graph with JS as suggested.
However if you do much of this, or wish to graph complex curves or
data-fit the curve to many points with some scatter, you need a math
program. The commercial programs are rather expensive. However you can
find a few free ones such as DataPlot. Such programs usually use a
higher level language such as Fortran or C+, but they are compiled so
that you do not have to have a compiler for the language installed on
your PC, and you do not have to know anything about a higher level
language to use them. These programs will draw the curve, show
individual data points if desired, and give the numerical units and
labels. Then you just use an image program to adjust the size as
desired and output as a jpg or other format suited for the web. This
method also has the advantage that it will work on any browser that can
view a jpg, even if script is turned off. It also saves you a large
amount of time if you use plots on the web very often. The down side is
that it can take a bit of time to learn how to use the math program the
first time.


If you are wanting to draw a curve that can be calculated from a
standard math formula rather than by fitting a curve to experimental
measurements with some scatter, then you can use the JS math functions
to do this. An old example of mine is at
http://www.cwdjr.net/math/bessel_function2.html . This plots the Bessel
function J0 . Since J0 is not part of JS math, this function is
evaluated from the definition of it, using the JS math functions that
are available. I have done a lot of math, so doing math using JS is no
problem for me. However those without a math background might find this
sort of thing difficult. Of course if you just want to plot some basic
math function such as sin that is built into JS, then there is nothing
difficult to calculate.

Oct 25 '05 #7
"srinivas" <ni********@gma il.com> writes:
Hi all,
I have one requirement.Is there any way to create a line graph
using javascript.If it is please send me the sample code.But the thing
is it should work in all browsers.

Thanks,
Srinivas


Maybe that will help:

http://www.walterzorn.com/

A.

--
Arnaud DIEDEREN
Software Developer
IONIC Software
Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
Tel: +32.4.3640364 - Fax: +32.4.2534737
mailto:ad@ionic soft.com
http://www.ionicsoft.com
Oct 26 '05 #8
JRS: In article <6d************ ********@comcas t.com>, dated Tue, 25 Oct
2005 12:06:44, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
srinivas said the following on 10/25/2005 11:04 AM:

I have one requirement.


And it is an impossible requirement.
Is there any way to create a line graph using javascript. But the thing is it should work in all browsers.


That "thing" is what makes your requirement impossible.


Well, it's pretty difficult to see how it could be done in Lynx, unless
Ascii-art is adequate, in which case any browser that can handle script
should do.

How many images can one put on a single page, if the images themselves
are simple?

In graphics\, fig-dot.gif (if I remember to upload it; otherwise use
fig-_) and fig-0.gif are here images of dot and 0, but pretend they are
white and black bricks and smaller. Then the following javascript code,
tested in my js-quick.htm, generated a very crude diagram of a black-
filled parabola.

for (y=-6;y<7;y++) {
for (x=-2;x<15;x++) { Z = ["dot", "0"][+(2*x>y*y)]
document.writel n("<img src='graphics/fig-", Z, ".gif'>") }
document.writel n("<br>") }

On a more recent machine, presumably more images can be used at
reasonable speed.
Also, if you prepare a set of 64 square GIFs, one for each combination
of the 8 principal spokes being present or absent, you can generate a
line drawing by computing which to write in a grid.

If they are transparent GIFs, then I think you can absolutely position
them on top of each other, and stretch/squash them to get lines at
computed angles. The axes, of course, would be prepared as a single
GIF, if of constant scale.

You'd prepare your data as a list or array, of course, and run through
it computing the output of each element.

If you can use only more recent browsers, you should probably use DOM
methods to construct the relevant part of the page.

Note also that HTML can display a BMP file, and AIUI the BMP format is
simple. You could use an application to compute a BMP, by adding your
overlay to your template, and display that.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
The Big-8 newsgroup management is attempting to legitimise its questionable
practices while retaining its elitist hegemony. Read <URL:news:news. groups>.
Oct 26 '05 #9
Dr John Stockton said the following on 10/26/2005 9:23 AM:
JRS: In article <6d************ ********@comcas t.com>, dated Tue, 25 Oct
2005 12:06:44, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted :
srinivas said the following on 10/25/2005 11:04 AM:
I have one requirement.


And it is an impossible requirement.

Is there any way to create a line graph using javascript.
But the thing is it should work in all browsers.


That "thing" is what makes your requirement impossible.

Well, it's pretty difficult to see how it could be done in Lynx, unless
Ascii-art is adequate, in which case any browser that can handle script
should do.


And non-JS browsers? That was the reason behing my "impossible
requirement". You could always simple generate the image on the server,
send it to the browser. But you still fall into the non-image capable
browsers.
How many images can one put on a single page, if the images themselves
are simple?


It's unlimited, based solely on the externals of the browser. RAM, CPU, etc.

This page:
<URL: http://members.aol.com/_ht_a/HikksNo...hit/index.html >
Is one that was written a while back that allows a user to click on two
points and a line is drawn between them. It uses a 1x1 gif image and
moves them accordingly. Any grid larger than the one there tended to get
extremely slow to the point of hanging the browser.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 26 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4189
by: noise | last post by:
Hello, I have problem with drawing running graph. What I want to draw is: I have an object O which as a real number r associated with it. In the main() (in main class) i have a for loop which do something o that object O to modify its real number r. The loop runs 5000 times. I want to draw the real number r. I can draw the grap but only after the for loop finished running. What i want to do is to draw the grap while the for loop still...
1
12715
by: balakrishnan.dinesh | last post by:
Hi frnds, Im creating function to plot line graph in javascript . I have marked the points in graph. but what i need to do is, i want to draw the line between those marked point, but i dont konw how to draw line betwwen the marked points The output for my function will be like this , So the marked point (*) should be connected through lines,
9
7077
by: balakrishnan.dinesh | last post by:
Hi frnds, I want to draw pie graph or line graph through javascript. Can anyone give me a sample code for these charts. Thank you Dinesh
2
3455
by: Lamis | last post by:
Hi, I want to draw a line graph in my C# form. it is in real time so the graph will constantly get new values. it should show one line for maximum value, one line for minimum value and a third for the current value.. any idea how to do that in C#. I am thank full for all help coz I dont know even how to start. -- LZ
0
2700
by: suedasszyy | last post by:
Haiiii.... i'm new for VB.net. can someone help me to solve those question? is it possible to draw a graph such as Sin graph using console application? if not, how can i draw a graph ,example sin graph in window form but i must give the commands in console application ?
0
2506
by: vimalapalanichamy | last post by:
Actually i am using PIC16F877 controller for my project.The inputs for the line graph are came from controller (through RS232).Now i am trying to get the data through RS232 from the controller to vb frontend (using mscomm).My next step is,draw the line graph to show the variation of that received data's.please help me for this.And also send some source code for this
4
9195
by: hastalavista | last post by:
HI I'm very new to C# and I've got a big project to do in C# for uni until july. I've been trying do draw lines in C# (arrows to be precise). I can draw them allright but once I minimize the program and maximize it again, the arrows dissapear :S. this also happens if I open another program on top of the program I'm creating. Is their a way to correct this? To draw the lines I've been using this piece of code.
1
4381
by: berry | last post by:
Hi all.. How to draw a line graph? My axis-x is the daily hour from 8am to 8pm. Can i use a XY mschart type to draw it? Or I must use a picture box to draw it? If with XY chart type, how to draw? Thank you..
7
3422
by: =?iso-8859-1?Q?Vicente_Garc=EDa?= | last post by:
Hi, I need to programmatically draw a graph (his nodes and his edges) from dynamic XML file. The graph is very complex and I don't know how I could do this task. Any ideas please? Microsoft Sparkle? Thanks in advance, Vicente.
0
8573
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8406
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7002
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4021
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2531
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.