Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Possible bug? #87

Open
unitymarc opened this issue Mar 2, 2016 · 3 comments
Open

Possible bug? #87

unitymarc opened this issue Mar 2, 2016 · 3 comments

Comments

@unitymarc
Copy link

This commit...
2210b5d
...seems to break export-csv for me. Maybe I'm being an idiot?

    if (typeof module === 'object' && module.exports) {
         module.exports = factory;
    } else {
         factory(Highcharts);
    }

If we fall into the first clause, there's no opportunity for factory() to run. So the methods never get added to Highcharts.Chart.prototype. On the other hand...

    if (typeof module === 'object' && module.exports) {
         module.exports = factory;
    }
    factory(Highcharts);

Works just fine for me. Apologies if I'm being thick.

@TorsteinHonsi
Copy link
Contributor

By assigning the factory to module.exports, this will run in a CommonJS environment. The only case where I can see this failing is if you have defined an object called module, containing a property called exports, and it is not CommonJS.

This patterns is consistent with how it is done for example in jQuery.

@jon-a-nygaard Any comments?

@unitymarc
Copy link
Author

Hmmm....well, perhaps there's some other explanation that's eluding me. If I change back to your code, I can see the module.exports in window...

screen shot 2016-03-04 at 1 26 27 pm

But the relevant methods don't show up in Highcharts.Chart.prototype...

screen shot 2016-03-04 at 1 27 17 pm

With my fix, I get it all and my life is good. We're operating within an AngularJS page, if that's helpful or relevant.

@jon-a-nygaard
Copy link
Contributor

@unitymarc I am not sure if you are using Node.js, but if so you will have to execute the Highcharts modules after requiring them. Examples below.

var Highcharts = require('highcharts');
// Require and execute export csv module
require('_path_to_export_csv')(Highcharts);

// Alternative method, store the Exports CSV factory function to execute it on a later stage.
var Highcharts = require('highcharts');
// Require and and store export csv factory function
var ExportCSV = require('_path_to_export_csv');
// Execute the factory function
ExportCSV(Highcharts);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants