Sign in to follow this  
navaneeswar

Use of variable for providing dataSource in fusioncharts

Recommended Posts

var arrcolor = ["00ff00", "800080", "ffa500", "ff0000"];            
            var count = data.length;
            for(var i=0;i<count;i++)
            {
                var obj = {
                    label : data.Description,
                    value : data.Value,
                    link : "JavaScript: AnalysisByDrillDownLaceScoreGraph(" + data.Description + ")",
                    color : arrcolor
                }
                data_array.push(obj);
            }
            var objJSON = { chart :  {
                                 "bgcolor": "ffffff",
                                 "xAxisName": "Range",
                                 "yAxisName": "Count",
                                 "formatnumber": "1",
                                 "formatnumberscale": "6",
                                 "sformatnumber": "1",
                                 "showplotborder": "0",
                                 "canvasborderalpha": "0",
                                 "theme": "zune"
                             }, data : (data_array)
    };
    var newdata = JSON.stringify(objJSON);
    var AnalysisChart = new FusionCharts({
        type: 'mscolumn2d',
        renderAt: 'divChartAnalysis',
        width: '110%',
        height: '250',
        dataFormat: 'json',
        dataSource: newdata
       
    });
    AnalysisChart.render();
This is how i prepared the chart . the newdata is as follows
newdata = {"chart":{"bgcolor":"ffffff","xAxisName":"Range","yAxisName":"count","formatnumber":"1","formatnumberscale":"6", sformatnumber":"1", "showplotborder":"0","canvasborderalpha":"0","theme":"zune"},"data":[{"label":"0-4","value":426,"color":"00ff00"},{"label":"5-9","value":2655,"color":"800080"},{"label":"10-14","value":1808,"color":"ffa500"},{"label":"15-19","value":45,"color":"ff0000"}]}
Yet the fusionChart is displaying no data to display.. Pls someone help me with this. the state of dataready is shown as false.
 

Edited by navaneeswar

Share this post


Link to post
Share on other sites

Hi, 

 

Welcome to FusionCharts Forum!!

 

Please check this for reference: http://jsfiddle.net/vishalika/Tu57h/145/

 

Provide some data in the format so that the chart will render accordingly.

 

Hope this helps.

Thank you Vishalika, 

                I have data in my code and and i used your suggestion to keep the Fusioncharts.ready() . But still it is displaying no data to display. during render, i have seen the dataReady to be false. Thanks in Advance. I changed the code like this:

 

 

FusionCharts.ready(function () {
 
var newdata=  {
    "chart":{
        "bgcolor":"ffffff",
        "xAxisName":"Range","yAxisName":"count",
        "formatnumber":"1",
        "formatnumberscale":"6",
        "sformatnumber":"1",
        "showplotborder":"0",
        "canvasborderalpha":"0",
        "theme":"zune"
            },
    "data":[
        {
            "label":"0-4",
            "value":426,
            "color":"00ff00"
        },{
            "label":"5-9",
            "value":2655,
            "color":"800080"
        },{
            "label":"10-14",
            "value":1808,
            "color":"ffa500"
        },{
            "label":"15-19",
            "value":45,
            "color":"ff0000"
          }
    ]
};
    
    var AnalysisChart = new FusionCharts({
        type: 'mscolumn2d',
        renderAt: 'divChartAnalysis',
        width: '110%',
        height: '250',
        dataFormat: 'json',
        dataSource: newdata
 
    });
    AnalysisChart.render();
 
 
});
Edited by navaneeswar

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
Sign in to follow this