I couldn't find any example describing the creation of Dojo Widget using C3 library.
Before trying to create a widget, I tried to create a module, and it worked.
I am new with Dojo ... so here is what I tried to create a Widget with c3 :
require([
"dojo/_base/declare", "dojo/parser", "dojo/dom-construct", "dojo/ready", "dojo/_base/window",
"dijit/_WidgetBase", "d3/d3", "c3/c3"
],function(declare, parser, domConstruct, ready, win, _WidgetBase, d3, c3){
declare("LineChart", [_WidgetBase], {
_options: {
bindTo : '#kpi1_chart',
data : {
columns : [
['data', 23, 50, 22, 41, 10]
]
},
zoom :{
enabled : true
}
},
_chart: undefined,
constructor: function(params, srcNodeRef){
if(params.hasOwnProperty('id'))
this._options.bindTo = "#"+params.id;
else
console.log("widget LineChart : id couldn't be found");
},
buildRendering: function(){
this._chart = c3.generate(this._options);
}
});
ready(function(){
parser.parse();
});
});
And here is how I initialize the widget in HTML
<div id="kpi1_chart" data-dojo-type="LineChart"></div>
When I start the page the div tag is just empty, I don't get any errors, could you help ?
this.inherited(arguments);
at the start of the constructor function. Also have you defined d3 and c3 packages correctly in the dojoConfig.this.inherited(arguments);
at the beginning of the constructor function, and for dojoConfig, I think it is well set, because I can use c3 as a dojo module. I did a little experiment by wrapping the previous module in an object (using declare, without inheriting from WidgetBase) and it didn't work ... Maybe c3 doesn't like when it is wrapped with declare ?