Using Javascript for graphics?

I'm new to the forum so please forgive me if this is a silly question.

I'm trying to write a program for my website that essentially displays a bunch of colored dots and draws a path through the dots using a complex algorithm(I realize that's not very descriptive). My problem is that I don't know if javascript is even the best method for implementing my project.

I know how to write the correct arrays for the algorithm using c++ and I know how to create the right graphics using flash but I want my program to work across all platforms so flash is out. My major problem is that I have no idea how to combine my algorithm with my graphics.

Can anyone help by pointing me in the right direction? Maybe someone can come up with some sample code for me to look at?

Thanks!

**UPDATE:**

I decided to use the Raphael js library and so far it's great. I just have one question that maybe one of you can help me with. Does anyone know how to populate a grid with circles. I need it to look roughly like this:

Code:

` `

o

o o

o o o

o o o o

The triangle can really go in any direction I just need to be able to index each dot individually and be able to draw lines connecting them along a specific path. I can create an array and draw a box of dots like this:

o o o o

o o o o

o o o o

o o o o

and I feel like it should be really easy to only use half of those to create a triangle but I'm having a bit of a hard time figuring it out. I was hoping to end up with a more symmetrical triangle than occurs when just cutting out half of the values. When I use an if statement i.e. If rows < cols I end up with something more like this:

o

o o

o o o

o o o o

It's just not quite what I'm looking for.

Any help would be greatly appreciated!

Thanks!