c3-angular-directive icon indicating copy to clipboard operation
c3-angular-directive copied to clipboard

Using c3-angular with require.js - problem!!

Open marco-faustinelli opened this issue 9 years ago • 4 comments

Hello, I am introducing require.js modularisation in my app, which uses c3-angular.

I get an error c3 is not defined which puzzles me a lot, because I have specified that c3-angular depends on c3.

Here are a couple of my requirejs shims for c3-angular. Have you got any experience with this sort issues?

'c3-angular' : { deps: ['angular','c3'] },
'c3' : { deps: ['d3'], exports: 'c3' },   

One of the major reasons of trouble in this case is that all c3-angular code is minified. An uncompressed version would help me enormously with analyzing this problem, and I am opening another issue just for that.

marco-faustinelli avatar Jan 01 '16 23:01 marco-faustinelli

Hm, sorry, I have o experience with requirejs. If I can find the time I'll try to investigate. At the moment I ignore the non minified version. I do not really see a problem to include it. Will do that in the next release. The non minified version is in the examples folder by the way. So you can check it. Also in browsers the .map file is used to make the minified version readable again.

jettro avatar Jan 02 '16 07:01 jettro

+1

pascalbaljet avatar Jan 20 '16 00:01 pascalbaljet

The latest release does contain the non minified version. Since I have no experience with RequireJS I am not sure a fix will come soon from my hand. Any help would be nice

jettro avatar Jan 20 '16 14:01 jettro

in case of requirejs, external libraries are visible only when required ( define(...) clause or require(...). here c3 is called after timer expired, which is not in the scope of requirejs.

to overcome the case, if not defined c3 is init by calling require(...) in controller.js (2 cases)

if (typeof c3 === 'undefined') {
                c3 = require('c3');
}
$scope.chart = c3.generate($scope.config);

This is not clean solution (but working) since it solve only requirejs case and it assume 'c3' is the requirejs name.

gkaspi avatar Jun 19 '16 20:06 gkaspi