Allen

Forced Html Rendering And Disabling Automatic Loading Of Javascript Libraries

Recommended Posts

So here's the situation, I need to always force rendering of the charts in HTML rather than flash and that part's fairly easy. Now, the problem I have is that due to our environment, we have a firewall that does some file manipulation and/or injecting of scripts. So, the auto-includes that occur when trying to render and HTML 5 chart just flat out doesn't work. The files I'm talking about are: FusionCharts.HC.Charts.js, FusionCharts.HC.js, and jquery.min.js.

I found, while digging through the source code, that there's a function that's supposed to let you leave off the auto-loading of the files:

if (FusionCharts._doNotLoadExternalScript) {
 FusionCharts._doNotLoadExternalScript({ jQuery: true, base:true, charts:true, powercharts:true, widgets:true, maps:true });
}

 

Unfortunately, that code doesn't work. After stepping through the debugger and trying to identify the problem, what I've come across in the main FusionCharts.js file is that calling this function is trying to set a boolean property on a string - this won't work as you can only set a property on a Javascript Object, not a string. Here's the code from FusionCharts.js:

       _doNotLoadExternalScript: function (flags) {
           var item, srcKey;
           for (item in flags) {
               srcKey = item.toLowerCase();
               if (moduleMeta[srcKey]) {
    moduleMeta[srcKey] = {};
                   moduleMeta[srcKey].blocked = new Boolean(flags[item]);
               }
           }
       },

 

The problem occurs in the moduleMeta[srcKey] line. moduleMeta[srcKey] is always a string - here's the excerpt from the source:

   moduleMeta = lib.moduleMeta = {
       jquery: 'jquery.min.js',
       base: 'FusionCharts.HC.js',
       charts: 'FusionCharts.HC.Charts.js',
       powercharts: 'FusionCharts.HC.PowerCharts.js',
       widgets: 'FusionCharts.HC.Widgets.js',
       maps: 'FusionCharts.HC.Maps.js'
   }

 

So, essentially you're trying to set moduleMeta.jquery.blocked = true...but you can't do that. Because moduleMeta.jquery is "jquery.min.js". So you're really trying to do this: moduleMeta."jquery.min.js".blocked = true ...this is invalid and will never work because you can't set a property on a string value.

 

All that being said, is there any way that anyone is aware of that I can merge all the necessary files and this thing just work? I've now spent two full days trying to work around this to no avail. It seems like every time I fix one thing another issue is broken, plus, my biggest fear is that as soon as a new release comes out I'll be back at square one. I really need a FusionCharts.all.js that includes everything so I don't have to mess with all this.

 

Thanks in advance,

 

Allen Underwood

Share this post


Link to post
Share on other sites
Guest Angshu

Hi,

 

Welcome to FusionCharts Forum! smile.gif

 

Please note that for rendering JavaScript charts, FusionCharts makes use of FusionCharts.HC.js, FusionCharts.HC.Charts.js and jquery.min.js. These files are present in Charts folder of the Download Pack. You do not need to load these files explicitly in HTML. FusionCharts.js automatically takes care of the loading.

 

If you wish to render JavaScript charts only, you just have to add a line of code as shown below:

 

FusionCharts.setCurrentRenderer('javascript') ;

 

This code will ask FusionCharts renderer to skip Flash rendering and create pure JavaScript charts.

 

More details at : http://docs.fusionch...singPureJS.html

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hi,

 

Let's see how your issue can be resolved. :)

 

In essence, you do not need to call "_doNotLoadExternalScript" if all your JS is loaded in a single file in a proper order. The order being: jQuery > FusionCharts.js > FusionCharts.HC.JS > FusionCharts.Charts.js. If the files are already loaded, the FusionCharts JS Library does not seek to load anything further.

 

So, essentially you're trying to set moduleMeta.jquery.blocked = true...but you can't do that. Because moduleMeta.jquery is "jquery.min.js". So you're really trying to do this: moduleMeta."jquery.min.js".blocked = true ...this is invalid and will never work because you can't set a property on a string value.

Thanks for investigating that deep. This and other related items will be addressed in our next service release. However, we do not recommend to depend on "_doNotLoadExternalScript" as it is merely an internal function designed for specific releases and specific workarounds.

Could you please elaborate as to why you needed to use this function "_doNotLoadExternalScript"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now