Introduce new architecture

@masayuki0812 masayuki0812 released this Aug 22, 2014 · 593 commits to master since this release

  • Introduced new architecture, but the interface is the same as the previous version
  • Modified data.x_format to data.xFormat
  • Modified data.x_localtime to data.xLocaltime

The idea of this architecture is suggested by @lblb and @yuvii . I appreciate your contribution. And please see this PR #486 for the detail of the new architecture.

Please let me explain what the new architecture enables.

From this version, it's possible to extend c3 by using c3.chart.fn and c3.chart.internal.fn like this:

// same interface with the current version
var chart = c3.generate({ ... });

// introduce internal API so that we can access internal variables and functions
chart.internal.isTimeseries(); // isTimeseries is an internal function, but now we can access

// you can define custom API through c3.chart.fn
c3.chart.fn.myApi = function(){
   // isTimeseries is an internal variable, but now we can access in API definition
chart.myApi() // now we can call this

// you can change the behavior of internal functions through c3.chart.internal.fn
c3.chart.internal.fn.drawLine = function() {
   if (this.isTimeseries()) {
     // do something
   } else {
     // do something

// you can define your own option through c3.chart.internal.fn.additionalConfig
c3.chart.internal.fn.additionalConfig = {
    myOption: undefined; // default value
// then, you can use this option
chart = c3.generate({
    myOption: true
c3.chart.fn.myApi = function () {
chart.myApi(); // true

There are some remaining tasks such as adding unit tests, custom build and etc. We'll keep developing these for next version together with issues reported.