-1

I'm finding difficulties in overcoming the issue with moment() in latest version 1.8 within apex class. Previously, I had version 1.6 which was working without any issues. Had the below error message in console:

Uncaught ReferenceError: moment is not defined

I have included the latest zoomchart.js file in my code. Any solution?

Sender
  • 6,660
  • 12
  • 47
  • 66
Rv1
  • 185
  • 1
  • 10
  • Make sure you include your moment.js file before using it, since that seems to be the problem. – Sotiris Kiritsis Oct 13 '15 at 06:54
  • Yes, I have added before my usage begins. – Rv1 Oct 13 '15 at 06:59
  • Another important note is wheni replace latest version 1.8 with v1.6, my code is working fine – Rv1 Oct 13 '15 at 07:02
  • Instead of degrading this question, please let me know the solution – Rv1 Oct 13 '15 at 07:15
  • This is awkward and should not be like that. We are investigating issue and will update this ticket. Thanks for noting. – jancha Oct 13 '15 at 15:10
  • I just downloaded latest version from zoomcharts.com (go to download) and I cannot see any problem. Please share your exact code. Also, have you edited the library. Please share url if possible as well. – jancha Oct 13 '15 at 15:12
  • can you post the stack trace for the error? Most likely you are using `moment()` in your own code. ZoomCharts wraps the included moment code in an internal namespace so it can use it itself but your own code has to use a manually included version. This is done because the moment code bundled has been slightly modified. – Knaģis Oct 13 '15 at 15:22
  • Here,is my piece of code which fails to execute with zoom charts version 1.8: // Zoom Charts Versio 1.8 – Rv1 Oct 15 '15 at 06:35

3 Answers3

1

The reason is that you are using moment() in your own code. For that to work you have to include moment.js reference as well.

ZoomCharts wraps the included moment code in an internal namespace so it can use it itself but your own code has to use a manually included version. This is done because the moment code bundled has been modified and thus might not conform to moment.js documentation.

Knaģis
  • 20,827
  • 7
  • 66
  • 80
  • Yes. It should have been great if Zoom Charts might have included this point in their release notes. Thanks for your help. – Rv1 Oct 16 '15 at 14:53
0

It works fine with 1.8. Have a look at this JSFiddle example:

var t = new TimeChart({
    container: document.getElementById("demo"),
    area: { height: 350 },
    data: {
        preloaded: {
            values: [
                [0, 100],
                [1000, 200],
                [2000, 300],
                [3000, 400],
                [4000, 500]
            ],
            unit: 's'
        },
        timestampInSeconds: true
    }
});

https://jsfiddle.net/2fguq058/

It must be your local code/modifications that are breaking your app. Please share more details.

jancha
  • 4,916
  • 1
  • 24
  • 39
  • I'm facing the issue only with the presence of 'moment' tag. Your code works perfect. Thanks for that. – Rv1 Oct 15 '15 at 06:39
-1

The Problem is, in latest version of Zoom charts (version 1.8) they have removed the supported files of moment.js where in v1.6 they have given by default. So, whoever install latest version of zoom charts must include an another file for moment.js. Reference link: http://momentjs.com/

URL of downloadable file: http://momentjs.com/downloads/moment.min.js

Hope it helps.

Rv1
  • 185
  • 1
  • 10
  • 1
    this is not true - ZoomCharts bundles the required moment code, it just does not expose it so that it does not pollute the global namespace with a customized moment instance. – Knaģis Oct 13 '15 at 15:24
  • @Knagiz Here,is my piece of code which fails to execute with zoom charts version 1.8 without moment js file: // Zoom Charts Versio 1.8 – Rv1 Oct 15 '15 at 06:36
  • yes, this is the case where you need to include moment yourself. The version ZoomCharts bundles is for its internal use only as it is modified. – Knaģis Oct 15 '15 at 10:27