DmitryBaranovskiy/g.raphael — pull request #125 by rzurad (2011-10-23 21:49:58+00:00)
Title: Refactored and removed 'g' namespace to port g.Raphael to Raphael 2.0

This is a port of g.Raphael to make it compatible with Raphael 2.0 by completely removing the `g` namespace from the Paper prototype.

This was achieved by doing two things:

- Hiding all utility functions inside function closures
- Moving all of the tooltip functions into the main Raphael repo as plugins, similar to what was done with the primitives plugin [see pull request: https://github.com/DmitryBaranovskiy/raphael/pull/429 ]

In order to make g.Raphael have a small footprint on the host Raphael instance, only the functions `barchart`, `hbarchart`, `piechart`, `linechart`, and `dotchart` are attached to the `fn` object. Each function retains its original parameters and options, with one change: There is no more `g.marker` object. Instead, the graph functions defer to the paper instance for function names. This means that you can use any function on the Paper prototype or instance as your marker function by simply supplying that function's name as the marker option.

This refactor lead to a few noteworthy changes in the code base. First, the `g.raphael.js` file has been deleted. All of its contents were either moved into function closures for the graph types that required them or were moved into the main Raphael repo as a plugin package.

As a result of this, each chart file has grown slightly larger in file size. This also means that there is some duplication of code between some of the graphs (bar and pie share equivalent definitions of `snapEnds` and `_axis` functions), but this was chosen to make each graph only dependent on the raphael.js library file (unless you want to use some of the shapes defined in the primatives or tooltips plugins as markers for your graphs).

All original examples from http://g.raphaeljs.com/ are working as before. They are located in the `test/` directory and can be temporarily viewed here:
http://www.srsfknbzns.com/graphael/test/

In order to make tests easily work, I've included my fork of the main Raphael repository with the tooltips plugin as a git submodule (make sure it is set to the 'tooltips' branch if you check it out). In its current state, this pull request depends on my pull request that was made to the Raphael repository. If, instead, you would rather have the tooltips and brightness plugins shipped with g.Raphael instead of Raphael, then they can be easily moved back into here making this pull request no longer have any dependencies.