add canvas render 0.4.8 version of c3.js #1436
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the html5 application my company is working on, we needed to draw more data points than C3 was capable of, but liked the overall functionality of the library and usage of D3 as a model. The major bottleneck was SVG rendering. This fork contains a reimplementation of a subset of C3's rendering using a Canvas element.
Capabilities include:
-canvas rendering nearly identically to SVG version
-hover color highlighting
-massive increase in the number of data points that can be drawn to a graph
Animation is not implemented in this version.
In the tests I ran, the maximum number of data points displayed increased my more than a factor of 10 (possibly closer to 50-100, still running tests). This is possible because by doing procedural rendering to a Canvas element, the large memory overhead of storing individual SVG DOM elements for every graph shape element is eliminated. Mouse position detection is also performed algorithmically instead of by tiny SVG strips, again cutting down on memory footprint for graphs with lots of x-axis points.
Changes are localized to between lines 695 and 1197. As mentioned in the commit title, this is actually a branch of the 0.4.8 version of c3.js. I tried copying in the changes into the head version, but it looks like rendering has changed too much for a straight copy/paste to work. If this seems like a worthwhile piece of functionality, I'd be happy to work with other devs on the project to integrate Canvas graphs into the latest version, perhaps to be activated with an alternate parameter as an alternative to SVG rendering when users need more speed and can make do with the subset of functionality provided.
Note that only the c3.js file of this fork features the canvas graphs implementation.
Known issues:
-for graph redraws triggered by user callbacks, an extra chart.defocus() call is necessary to trigger the canvas redraw by C3