diff --git a/htdocs/js/samples/plugin.js b/htdocs/js/samples/plugin.js new file mode 100644 index 0000000..e5a0718 --- /dev/null +++ b/htdocs/js/samples/plugin.js @@ -0,0 +1,13 @@ +c3.chart.internal.fn.isTimeSeries = function () { + console.log('custom isTimeSeries'); + return false; +}; +c3.chart.internal.fn.additionalConfig.test1 = undefined; +c3.chart.internal.fn.additionalConfig.test2 = undefined; + +c3.chart.fn.hoge = function () { + console.log("hoge()", this.internal.isTimeSeries()); +}; +c3.chart.fn.test = function () { + console.log('test()', this.internal.config.test1); +}; diff --git a/htdocs/samples/plugin.html b/htdocs/samples/plugin.html new file mode 100644 index 0000000..cba5227 --- /dev/null +++ b/htdocs/samples/plugin.html @@ -0,0 +1,27 @@ + + + + + +
+ + + + + + + + diff --git a/src/config.js b/src/config.js index 466cba0..56193a9 100644 --- a/src/config.js +++ b/src/config.js @@ -326,8 +326,13 @@ c3_chart_internal_fn.getDefaultConfig = function () { config[__tooltip_init_x] = 0; config[__tooltip_init_position] = {top: '0px', left: '50px'}; + Object.keys(this.additionalConfig).forEach(function (key) { + config[key] = this.additionalConfig[key]; + }, this); + return config; }; +c3_chart_internal_fn.additionalConfig = {}; c3_chart_internal_fn.loadConfig = function (config) { var this_config = this.config, target, keys, read;