G30071

Require.js and Fusioncharts

Recommended Posts

Hi,

 

What is your motive behind including FusionCharts JavaScript files in Require.js ?

 

"fusioncharts.js" file is added in the code explicitly. Rest of the JavaScript files will be loaded automatically. The only requirement is that all the *.js files should be present in the same folder as "fusioncharts.js".

Edited by Vishalika

Share this post


Link to post
Share on other sites

Hi

 

The issue is very simple. Will try to explain here since we found a few posts here as well as in stack overflow where the replies gave a sense of lack of clarity . 

 

Script loaders like requirejs, yepnope, headjs are used to manage script dependencies, load scripts conditionally, load scripts when required or to combine dependent scripts into one for faster loading.In this example, like in ours, the chart functionality is only available to a few power users. So why load it for all users. Also the charts are only a side functionality, so it only require to be loaded if the user wants to see the chart. So we use require in this project to manage when the scripts have to be loaded with the required dependencies. And we use a lot of open source js libraries as well as a lot of our own. But for minor glitches we have got them to work.

 

As of today (version 3.4.0), trial version downloaded a few weeks back, the fusion chart does not work with require. You do not need a testbed or test script, you just need to define the dependencies in a shim in require as shown below and try to get it working.

 

 shim: {

     'fusionchart':{deps:['jquery']},
    'fusionthemes':{deps:['fusionchart']},
...
...
}

 

 

We cannot point out the issue as we only have the minified files, but one reason could be that Raphael that Fusion is dependent on is not compatible with AMD or require.

 

Script loaders (especially require) are used by a lot of people and is still on the rise. I think it is really important for a company like fusion chart to support require. So instead of asking for test scripts and beds, you should really talk to your development team as well as the management about this. We are all sure they already understand the issue or/ and will definitely close this hole for the future.

 

Regards

sharbel

Share this post


Link to post
Share on other sites

Hi,

Sample:

require.config({
	paths: {
    fusioncharts: 'themes/alpha/assets/js/fusioncharts',
    fusionthemes: 'themes/alpha/assets/js/fusioncharts.charts'
	
	    },
 shim: {
     'fusioncharts':{deps:['jquery']},
     'fusionthemes':{deps:['fusioncharts']}
		
		}
	
});

in page :

<script>
            
 require(['fusioncharts', 'fusionthemes'], function() {
    FusionCharts.ready(function(){
    var revenueChart = new FusionCharts({
        "type": "column2d",
   
....
....
....


  });
revenueChart.render();
});
});

  
</script>

Error:

qPmdJ.png

Share this post


Link to post
Share on other sites

Hi,

Sample:

require.config({
	paths: {
    fusioncharts: 'themes/alpha/assets/js/fusioncharts',
    fusionthemes: 'themes/alpha/assets/js/fusioncharts.charts'
	
	    },
 shim: {
     'fusioncharts':{deps:['jquery']},
     'fusionthemes':{deps:['fusioncharts']}
		
		}
	
});

in page :

<script>
            
 require(['fusioncharts', 'fusionthemes'], function() {
    FusionCharts.ready(function(){
    var revenueChart = new FusionCharts({
        "type": "column2d",
   
....
....
....


  });
revenueChart.render();
});
});

  
</script>

Error:

qPmdJ.png

Hi,
Apologies for the delay.
 
Could you please upgrade your current version to the latest, i.e, FusionCharts Suite v3.4.1 that includes the fixes to the previously reported issues and see if this helps?
 
Awaiting your feedback.

Share this post


Link to post
Share on other sites

 

Hi,
Apologies for the delay.
 
Could you please upgrade your current version to the latest, i.e, FusionCharts Suite v3.4.1 that includes the fixes to the previously reported issues and see if this helps?
 
Awaiting your feedback.

 

Hi,

 

it works !!!  :) 

 

Thanks.

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