mao ma
mao ma

Reputation: 23

Highcharts-browserify desn't work

error: Uncaught TypeError: undefined is not a function

But, I download the highcharts.src.js from http://www.highcharts.com/, and change the code at line 1201 from win.jQuery to $, add var $ = require('jquery');, then it work with browserify.

It's here something wrong? Thank you

Upvotes: 1

Views: 568

Answers (2)

RichS
RichS

Reputation: 3147

In case this is helpful to anyone else, I got this working by add this to my package.json:

{   
    ...,
    "browser": {
        "Highcharts": "./vendor/highcharts/highcharts.js",
        "HighchartsMore": "./vendor/highcharts/highcharts-more.js",
        "HighchartsAdapter": "./vendor/highcharts/standalone-framework.js"
    },
    "browserify": {
        "transform": [
            "browserify-shim"
        ]
    },
    "browserify-shim": {
        "Highcharts": {
            "depends": ["HighchartsAdapter:HighchartsAdapter"],
            "exports": "Highcharts"
        },
        "HighchartsMore": {
            "depends": ["Highcharts:Highcharts"]
        },
        "HighchartsAdapter": {
            "exports": "HighchartsAdapter"
        }
    }

Upvotes: 1

mao ma
mao ma

Reputation: 23

It seem something about browserify-shim with jQuery, config in browserify package.json, highcharts-browserify work well~

Upvotes: 0

Related Questions