Home Forums Chart Support Error when using with RequireJS

Error when using with RequireJS

Viewing 7 posts - 1 through 7 (of 7 total)
  • #23873

    Hi,

    I have asked my question on StackOverflow already, but I didn’t realise this forum was here. My original question is:

    https://stackoverflow.com/questions/53959850/error-when-trying-to-use-canvasjs-via-requirejs

    The problem I’m having is that I get an error when trying to use CanvasJS with RequireJS:

    ReferenceError: intToHexColorString is not defined[Learn More] canvasjs.min.js:7:7042
        [33]</n.prototype.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:7:7042
        [28]</n.prototype.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:5:14150
        n/this.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:8:17771
        init_page_select https://www.test.org/2018/js/lib/spot_view_stats.js:83:2
        <anonymous> https://www.test.org/2018/js/lib/spot_view_stats.js:4:3
        domReady https://www.test.org/2018/js/lib/domready.js:105:13
        <anonymous> https://www.test.org/2018/js/lib/spot_view_stats.js:2:2
        execCb https://www.test.org/2018/js/lib/require.js:5:12859
        check https://www.test.org/2018/js/lib/require.js:5:6575
        enable/</< https://www.test.org/2018/js/lib/require.js:5:9031
        bind/< https://www.test.org/2018/js/lib/require.js:5:812
        emit/< https://www.test.org/2018/js/lib/require.js:5:9497
        each https://www.test.org/2018/js/lib/require.js:5:289
        emit https://www.test.org/2018/js/lib/require.js:5:9465
        check https://www.test.org/2018/js/lib/require.js:5:7169
        enable/</< https://www.test.org/2018/js/lib/require.js:5:9031
        bind/< https://www.test.org/2018/js/lib/require.js:5:812
        emit/< https://www.test.org/2018/js/lib/require.js:5:9497
        each https://www.test.org/2018/js/lib/require.js:5:289
        emit https://www.test.org/2018/js/lib/require.js:5:9465
        check https://www.test.org/2018/js/lib/require.js:5:7169
        enable https://www.test.org/2018/js/lib/require.js:5:9358
        init https://www.test.org/2018/js/lib/require.js:5:5716
        h https://www.test.org/2018/js/lib/require.js:5:4287
        completeLoad https://www.test.org/2018/js/lib/require.js:5:12090
        onScriptLoad https://www.test.org/2018/js/lib/require.js:5:13014

    I’m a bit confused as to why though, as I can see the code in require.js:

    function intToHexColorString(num) {
    	var r = ((num & 0xFF0000) >> 16).toString(16);
    	var g = ((num & 0x00FF00) >> 8).toString(16);
    	var b = ((num & 0x0000FF) >> 0).toString(16);
    
    	r = r.length < 2 ? "0" + r : r;
    	g = g.length < 2 ? "0" + g : g;
    	b = b.length < 2 ? "0" + b : b;
    
    	return "#" + r + g + b;
    }

    Any suggestions?

    #23874

    @andynewby,

    Can you please check your project with the latest version of CanvasJS. In case it doesn’t help can you please create a sample project and share it over Google-Drive or Onedrive so that we can look into your code understand the issue and help you out.

    ____________
    Indranil Deo,
    Team CanvasJS

    #23875

    Thanks for the reply. This is what my package.json has:

    “_from”: “canvasjs@latest”,
    “_id”: “canvasjs@1.8.1”,
    “_inCache”: true,
    “_installable”: true,
    “_location”: “/canvasjs”,
    “_nodeVersion”: “5.1.0”,

    Is that the latest version? It was installed using npm.

    Thanks

    Andy

    #23876

    Ah interesting – if I download that link you sent, and manually push that up – it works fine. I wonder why npm is running such an old version?

    Cheers

    Andy

    #23877

    @andynewby,

    The CanvasJS npm package listed is not an official release but from a third party. We currently have plans for building and publishing npm package but no definite timeline yet.

    __________
    Indrail Deo,
    Team CanvasJS

    #23878

    Ahhh ok that makes sense. Well, all working fine now – thanks and happy new year :)

    #42741

    @andynewby,

    We have just added CanvasJS Chart & StockChart packages to NPM registry. Now, you can add our charts & stockcharts to your application via NPM. Please refer to the release blog for more information. Please check out our NPM package and let us know your feedback.


    Thangaraj Raman,
    Team CanvasJS

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.