CompGeoJS 2D Graph Axes and Grid

compgeojs-blog

I’ve enjoyed an opportunity to enhane the graphing tools in GompGeoJS.  Having a good baseline graphing capability is very useful for many of the demos that are to come, especially parametric curves.

The CompGeoJS GraphAxis class allows a single horizontal or vertical axis to be managed inside a 2D drawing area that is bounded by user coordinates.  The user bounds as well as pixel width and height of the drawing area are provided as initial inputs along with the axis orientation.  A GraphAxis composes a CompGeoJS Axis and triangular shape to help manage axis display.  An arbitrary graphic context that supports a minimal API (moveTo, lineTo, curveTo) is passed to many of the GraphAxis methods to automatically draw the axis, arrows, tic marks, and grid.  Since text must be managed to render tic labels, this is the only aspect of the 2D graph that is managed outside of CompGeoJS, although (just as with NumberLine) the library handles most of the heavy lifting.  The actual required user code is rather trivial.

You may view the online demo here, and the library source code as well as the GraphAxis source code may be readily downloaded or displayed.

I will be out of town on business for the next two weeks, so the next library update will probably be some time in very late Jan. or early Feb.


Comments are closed.