Re: How to draw a line graph using javascript



JRS: In article <6didnYn9zb2excPeRVn-jQ@xxxxxxxxxxx>, dated Tue, 25 Oct
2005 12:06:44, seen in news:comp.lang.javascript, Randy Webb
<HikksNotAtHome@xxxxxxx> 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.writeln("<img src='graphics/fig-", Z, ".gif'>") }
document.writeln("<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.demon.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>.
.



Relevant Pages

  • Re: IE only bmp, no jpg etc also scripting error
    ... regsvr32 /i shimgvw.dll " ... only managing to save as bmp, I was not able to locate the bmp anywhere other ... user profile, folder by foldr all the while checking to see what file ... > 810978 - Internet Explorer Saves Images As Bitmaps ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: help with arrays
    ... The tags you found so confusing are in fact, ... JavaScript, but they are variant objects, and do not support ... looks like what it's doing is using an array of images, ... images, and a button which invokes a JS function which simply uses setInterval to cycle through the images. ...
    (microsoft.public.frontpage.programming)
  • RE: Hiding Data in jpg or bmp files
    ... Catch me if I am wrong, since i am no expert in the area of images. ... Each pixel in a BMP with 16M colors is made up of 3 bytes, one each for Red, ... "Kahuna" wrote: ... > dont understand how a security data string could be encoded into the file ...
    (microsoft.public.vb.general.discussion)
  • Re: Please help us Oh Great Masters
    ... Many _images_ are more than 8k, ... most likely provide provide less value than javascript functionality. ... If you just want to handle standard-format dates, ... FAQish topics, links, acronyms ...
    (comp.lang.javascript)
  • Re: Somethings not right.??!!
    ... If you are going to do this, then you will be importing those images vs. ... leave the text a bit blurry and webbots will not be able to read and index. ... He originally was using a javascript menu with mouseover ...
    (microsoft.public.publisher.webdesign)