views:

316

answers:

4

Hi,

I would like to plot points in two dimensional fashion (each have an x and y coordinates). I was wondering if you know of a library or project that does this so that I don't have to build this from scratch.

Thanks,

Tam

+2  A: 

Here you have one: http://jsdraw2d.jsfiction.com/

Luis Lobo Borobia
+2  A: 

Raphaël - a small JavaScript library that should simplify your work with vector graphics on the web.

Alex Barrett
+1  A: 

Use canvas. The canvas tag is the best way of doing this. Here is how to create a Canvas:

// Create a canvas that extends the entire screen
// and it will draw right over the other html elements, like buttons, etc
var canvas = document.createElement("canvas");
canvas.setAttribute("width", window.innerWidth);
canvas.setAttribute("height", window.innerHeight);
canvas.setAttribute("style", "position: absolute; x:0; y:0;");
document.body.appendChild(canvas);

Then you can draw a point at (10,10) like this:

var ctx = canvas.getContext(2d);
ctx.fillRect(10,10,1,1);

Furthermore, you can manipulate all the pixels on the screen using ImageData.

https://developer.mozilla.org/En/HTML/Canvas/Pixel%5Fmanipulation%5Fwith%5Fcanvas

jhuni
+1  A: 

If you've using jQuery already, then Flot is a very very simple (but powerful) way to draw graphs.

You could also look at the Google Charts API -- guaranteed cross-browser: it gives you a graph as an image, instead of canvas or VML, etc.

nickf