0

Imagine something like Pascals triangle, made up of many circles, with a number written on each circle.

This Pascal's triangle might be 200 rows or more, which obviously wont fit on screen.

As such, I need a JavaScript library to draw circles (in a triangle formation) and pan and zoom around Pascals triangle.

I'm not sure if an SVG library is best or canvas or something else. I'm open to suggestions. Anyone know of a good JavaScript lib? npm modules are fine too.

Help much appreciated. Many thanks.

1

My suggestion for custom javascript drawings is d3.js.

As an example, http://bl.ocks.org/edrex/1920883 shows a way to draw pascal's triangle.

https://github.com/d3/d3-zoom shows how to do some zoom/pan activities.

This library also makes it possible to render in svg or canvas, depending on your needs.

| improve this answer | |
  • awesome answer - previously I was using SVG.js which is a nice library but one of its functions was too slow - switching to D3 fixed the performance issue - I am also going to try d3-zoom over my current solution svg-pan-zoom - I have no complaints with svg-pan-zoom but d3-zoom is far more popular so worth a look - many many thanks – danday74 Jul 14 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.