Syntax error in RGraph.radar.js

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Joseph R on 1st January 2014
Using RGraph version RGraph2_2013-10-01-stable.
In an environment which has its own JS libraries and a code checker.
When using a radar graph, my environment throws this error:

SyntaxError: identifier starts immediately after numeric literal
localhost/.../RGraph/RGraph.radar.js
...,size:size,x:centerx,y:centery,text:RG.number_format (this,0.toFixeddecimals),units_pre,units_post),valign:'center',ha
------

Diagnostic: I already had this same syntax error in a previous version of RGraph, in the RGraph.radar.js library, which I had solved.

In RGraph2_2013-10-01-stable, RGraph.radar.js, this error can be solved by replacing, line 1003:

'text':RG.number_format(this, (0).toFixed(decimals), units_pre, units_post),

with the equivalent line found in e.g. RGraph.rose.js:

'text':typeof(prop['chart.ymin']) == 'number' ? RG.number_format(this, Number(prop['chart.ymin']).toFixed(prop['chart.scale.decimals']), units_pre, units_post) : '0',

Hope this helps,

Joseph
Posted by RGraph support on 1st January 2014
Hi there,

Thanks, but ymin isn't available on the Radar so using the property would not be a good idea. (0).toFixed() is valid JavaScript so it may be be your minifier being overly aggressive. Regardless I've changed it to:

Number(0).toFixed(decimals);

If you need a good minifier that works well with RGraph then jsmin by Douglas Crockford works well and is the one used on the RGraph website and to create the minified archive.

Richard
Posted by Joseph R on 3rd January 2014
Thanks for the tip, Richard. Adding "Number" before (0).toFixed(decimals) does work.

I didn't know minifiers could cause this kind of problem. I cannot change the minifier used by the Moodle CMS, but I will enquire.
Thanks again,
Joseph
Posted by Joseph R on 3rd January 2014
Further to my previous message minutes ago, I have disabled the "JS compression" feature on my Moodle CMS test site and ... the original line with
(0).toFixed(decimals)
now works.
You were right, Richard, the problem does come from the "overly aggressive" minifier. I will tell the Moodle programmers about it.

Add a reply




« Back to message list