FusionCharts Forum: No data to display - FusionCharts Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

No data to display for charts! other charts would just not display

#1 User is offline   eks 

  • Forum Newbie
  • Group: Members
  • Posts: 4
  • Joined: 14-June 10

Posted 15 June 2010 - 07:56 PM

Hi Guys, it's me again I've already implemented on applying Fusion Charts for our web page, the problem now is that it's likely to apply only for a 3D Column Chart :) can anyone help by the way I'm new at the XML thing :(



Here is the FusionChart.js for our code:



 /**

 * FusionCharts: Flash Player detection and Chart embed

 *

 * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:

 * http://www.opensource.org/licenses/mit-license.php

 *

 */

if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();

if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();

infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang){

	if (!document.getElementById) { return; }



	//Flag to see whether data has been set initially

	this.initialDataSet = false;



	//Create container objects

	this.params = new Object();

	this.variables = new Object();

	this.attributes = new Array();



	//Set attributes for the SWF

	if(swf) { this.setAttribute('swf', swf); }

	if(id) { this.setAttribute('id', id); }

	if(w) { this.setAttribute('width', w); }

	if(h) { this.setAttribute('height', h); }



	//Set background color

	if(c) { this.addParam('bgcolor', c); }



	//Set Quality

	this.addParam('quality', 'high');



	//Add scripting access parameter

	this.addParam('allowScriptAccess', 'always');



	//Pass width and height to be appended as chartWidth and chartHeight

	this.addVariable('chartWidth', w);

	this.addVariable('chartHeight', h);



	//Whether in debug mode

	debugMode = debugMode ? debugMode : 0;

	this.addVariable('debugMode', debugMode);

	//Pass DOM ID to Chart

	this.addVariable('DOMId', id);

	//Whether to registed with JavaScript

	registerWithJS = registerWithJS ? registerWithJS : 0;

	this.addVariable('registerWithJS', registerWithJS);



	//Scale Mode of chart

	scaleMode = scaleMode ? scaleMode : 'noScale';

	this.addVariable('scaleMode', scaleMode);

	//Application Message Language

	lang = lang ? lang : 'EN';

	this.addVariable('lang', lang);

}



infosoftglobal.FusionCharts.prototype = {

	setAttribute: function(name, value){

		this.attributes[name] = value;

	},

	getAttribute: function(name){

		return this.attributes[name];

	},

	addParam: function(name, value){

		this.params[name] = value;

	},

	getParams: function(){

		return this.params;

	},

	addVariable: function(name, value){

		this.variables[name] = value;

	},

	getVariable: function(name){

		return this.variables[name];

	},

	getVariables: function(){

		return this.variables;

	},

	getVariablePairs: function(){

		var variablePairs = new Array();

		var key;

		var variables = this.getVariables();

		for(key in variables){

			variablePairs.push(key +"="+ variables[key]);

		}

		return variablePairs;

	},

	getSWFHTML: function() {

		var swfNode = "";

		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {

			// netscape plugin architecture

			swfNode = ' 0){ swfNode += 'flashvars="'+ pairs +'"'; }

			swfNode += '/>';

		} else { // PC IE

			swfNode = '';

			swfNode += '';

			var params = this.getParams();

			for(var key in params) {

			 swfNode += '';

			}

			var pairs = this.getVariablePairs().join("&");

			if(pairs.length > 0) {swfNode += '';}

			swfNode += "";

		}

		return swfNode;

	},

	setDataURL: function(strDataURL){

		//This method sets the data URL for the chart.

		//If being set initially

		if (this.initialDataSet==false){

			this.addVariable('dataURL',strDataURL);

			//Update flag

			this.initialDataSet = true;

		}else{

			//Else, we update the chart data using External Interface

			//Get reference to chart object

			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));

			chartObj.setDataURL(strDataURL);

		}

	},

	setDataXML: function(strDataXML){

		//If being set initially

		if (this.initialDataSet==false){

			//This method sets the data XML for the chart INITIALLY.

			this.addVariable('dataXML',strDataXML);

			//Update flag

			this.initialDataSet = true;

		}else{

			//Else, we update the chart data using External Interface

			//Get reference to chart object

			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));

			chartObj.setDataXML(strDataXML);

		}

	},

	render: function(elementId){

		var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;

		n.innerHTML = this.getSWFHTML();

		return true;

	}

}



// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//

/* Fix for video streaming bug */

infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {

	if (window.opera || !document.all) return;

	var objects = document.getElementsByTagName("OBJECT");

	for (var i=0; i < objects.length; i++) {

		objects[i].style.display = 'none';

		for (var x in objects[i]) {

			if (typeof objects[i][x] == 'function') {

				objects[i][x] = function(){};

			}

		}

	}

}

// Fixes bug in fp9

infosoftglobal.FusionChartsUtil.prepUnload = function() {

	__flash_unloadHandler = function(){};

	__flash_savedUnloadHandler = function(){};

	if (typeof window.onunload == 'function') {

		var oldUnload = window.onunload;

		window.onunload = function() {

			infosoftglobal.FusionChartsUtil.cleanupSWFs();

			oldUnload();

		}

	} else {

		window.onunload = infosoftglobal.FusionChartsUtil.cleanupSWFs;

	}

}

if (typeof window.onbeforeunload == 'function') {

	var oldBeforeUnload = window.onbeforeunload;

	window.onbeforeunload = function() {

		infosoftglobal.FusionChartsUtil.prepUnload();

		oldBeforeUnload();

	}

} else {

	window.onbeforeunload = infosoftglobal.FusionChartsUtil.prepUnload;

}



/* Add Array.push if needed (ie5) */

if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}



/* Function to return Flash Object from ID */

infosoftglobal.FusionChartsUtil.getChartObject = function(id)

{

  if (window.document[id]) {

      return window.document[id];

  }

  if (navigator.appName.indexOf("Microsoft Internet")==-1) {

    if (document.embeds && document.embeds[id])

      return document.embeds[id];

  } else {

    return document.getElementById(id);

  }

}

/* Aliases for easy usage */

var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;

var FusionCharts = infosoftglobal.FusionCharts;




Here is the FusionChartExponent.js



 /**

 * FusionCharts: Flash Player detection and Chart embed

 *

 * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:

 * http://www.opensource.org/licenses/mit-license.php

 *

 */

if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();

if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();

infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang){

	if (!document.getElementById) { return; }



	//Flag to see whether data has been set initially

	this.initialDataSet = false;



	//Create container objects

	this.params = new Object();

	this.variables = new Object();

	this.attributes = new Array();



	//Set attributes for the SWF

	if(swf) { this.setAttribute('swf', swf); }

	if(id) { this.setAttribute('id', id); }

	if(w) { this.setAttribute('width', w); }

	if(h) { this.setAttribute('height', h); }



	//Set background color

	if(c) { this.addParam('bgcolor', c); }



	//Set Quality

	this.addParam('quality', 'high');



	//Add scripting access parameter

	this.addParam('allowScriptAccess', 'always');



	//Pass width and height to be appended as chartWidth and chartHeight

	this.addVariable('chartWidth', w);

	this.addVariable('chartHeight', h);



	//Whether in debug mode

	debugMode = debugMode ? debugMode : 0;

	this.addVariable('debugMode', debugMode);

	//Pass DOM ID to Chart

	this.addVariable('DOMId', id);

	//Whether to registed with JavaScript

	registerWithJS = registerWithJS ? registerWithJS : 0;

	this.addVariable('registerWithJS', registerWithJS);



	//Scale Mode of chart

	scaleMode = scaleMode ? scaleMode : 'noScale';

	this.addVariable('scaleMode', scaleMode);

	//Application Message Language

	lang = lang ? lang : 'EN';

	this.addVariable('lang', lang);

}



infosoftglobal.FusionCharts.prototype = {

	setAttribute: function(name, value){

		this.attributes[name] = value;

	},

	getAttribute: function(name){

		return this.attributes[name];

	},

	addParam: function(name, value){

		this.params[name] = value;

	},

	getParams: function(){

		return this.params;

	},

	addVariable: function(name, value){

		this.variables[name] = value;

	},

	getVariable: function(name){

		return this.variables[name];

	},

	getVariables: function(){

		return this.variables;

	},

	getVariablePairs: function(){

		var variablePairs = new Array();

		var key;

		var variables = this.getVariables();

		for(key in variables){

			variablePairs.push(key +"="+ variables[key]);

		}

		return variablePairs;

	},

	getSWFHTML: function() {

		var swfNode = "";

		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {

			// netscape plugin architecture

			swfNode = ' 0){ swfNode += 'flashvars="'+ pairs +'"'; }

			swfNode += '/>';

		} else { // PC IE

			swfNode = '';

			swfNode += '';

			var params = this.getParams();

			for(var key in params) {

			 swfNode += '';

			}

			var pairs = this.getVariablePairs().join("&");

			if(pairs.length > 0) {swfNode += '';}

			swfNode += "";

		}

		return swfNode;

	},

	setDataURL: function(strDataURL){

		//This method sets the data URL for the chart.

		//If being set initially

		if (this.initialDataSet==false){

			this.addVariable('dataURL',strDataURL);

			//Update flag

			this.initialDataSet = true;

		}else{

			//Else, we update the chart data using External Interface

			//Get reference to chart object

			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));

			chartObj.setDataURL(strDataURL);

		}

	},

	setDataXML: function(strDataXML){

		//If being set initially

		if (this.initialDataSet==false){

			//This method sets the data XML for the chart INITIALLY.

			this.addVariable('dataXML',strDataXML);

			//Update flag

			this.initialDataSet = true;

		}else{

			//Else, we update the chart data using External Interface

			//Get reference to chart object

			var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));

			chartObj.setDataXML(strDataXML);

		}

	},

	render: function(elementId){

		var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;

		n.innerHTML = this.getSWFHTML();

		return true;

	}

}



// ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//

/* Fix for video streaming bug */

infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {

	if (window.opera || !document.all) return;

	var objects = document.getElementsByTagName("OBJECT");

	for (var i=0; i < objects.length; i++) {

		objects[i].style.display = 'none';

		for (var x in objects[i]) {

			if (typeof objects[i][x] == 'function') {

				objects[i][x] = function(){};

			}

		}

	}

}

// Fixes bug in fp9

infosoftglobal.FusionChartsUtil.prepUnload = function() {

	__flash_unloadHandler = function(){};

	__flash_savedUnloadHandler = function(){};

	if (typeof window.onunload == 'function') {

		var oldUnload = window.onunload;

		window.onunload = function() {

			infosoftglobal.FusionChartsUtil.cleanupSWFs();

			oldUnload();

		}

	} else {

		window.onunload = infosoftglobal.FusionChartsUtil.cleanupSWFs;

	}

}

if (typeof window.onbeforeunload == 'function') {

	var oldBeforeUnload = window.onbeforeunload;

	window.onbeforeunload = function() {

		infosoftglobal.FusionChartsUtil.prepUnload();

		oldBeforeUnload();

	}

} else {

	window.onbeforeunload = infosoftglobal.FusionChartsUtil.prepUnload;

}



/* Add Array.push if needed (ie5) */

if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}



/* Function to return Flash Object from ID */

infosoftglobal.FusionChartsUtil.getChartObject = function(id)

{

  if (window.document[id]) {

      return window.document[id];

  }

  if (navigator.appName.indexOf("Microsoft Internet")==-1) {

    if (document.embeds && document.embeds[id])

      return document.embeds[id];

  } else {

    return document.getElementById(id);

  }

}

/* Aliases for easy usage */

var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;

var FusionCharts = infosoftglobal.FusionCharts;




Here is the FusionChartsRenderer.js:



<%

	/*

	 * Works with all jdk versions >=1.4.

	 * Creates the JavaScript + HTML code required to embed a chart.


	 * Uses the javascript FusionCharts class to create the chart by supplying 


	 * the required parameters to it.


	 * Note: Only one of the parameters strURL or strXML has to be non-empty for this


	 * method to work. If both the parameters are provided then strURL is used for further processing.


	 *

	 * @param chartSWF -

	 *                SWF File Name (and Path) of the chart which you intend

	 *                to plot

	 * @param strURL -

	 *                If you intend to use dataURL method for this chart,

	 *                pass the URL as this parameter. Else, set it to "" (in

	 *                case of dataXML method)

	 * @param strXML -

	 *                If you intend to use dataXML method for this chart,

	 *                pass the XML data as this parameter. Else, set it to ""

	 *                (in case of dataURL method)

	 * @param chartId -

	 *                Id for the chart, using which it will be recognized in

	 *                the HTML page. Each chart on the page needs to have a

	 *                unique Id.

	 * @param chartWidth -

	 *                Intended width for the chart (in pixels)

	 * @param chartHeight -

	 *                Intended height for the chart (in pixels)

  	 * @param debugMode -

   	 *                Whether to start the chart in debug mode

       * @param registerWithJS -

       *                Whether to ask chart to register itself with

       *                JavaScript

	 */

%>

<%

	String chartSWF = request.getParameter("chartSWF");

	String strURL = request.getParameter("strURL");

	String strXML = request.getParameter("strXML");

	String chartId = request.getParameter("chartId");

	String chartWidthStr = request.getParameter("chartWidth");

	String chartHeightStr = request.getParameter("chartHeight");

	String debugModeStr= request.getParameter("debugMode");

	String registerWithJSStr= request.getParameter("registerWithJS");



	int chartWidth = 600;

	int chartHeight = 300;

	Boolean debugMode=new Boolean("false");

	Boolean registerWithJS=new Boolean("false");

	int debugModeInt = 0;

	int regWithJSInt = 0;





	if (null != chartWidthStr && !chartWidthStr.equals("")) {

		chartWidth = Integer.parseInt(chartWidthStr);

	}

	if (null != chartHeightStr && !chartHeightStr.equals("")) {

		chartHeight = Integer.parseInt(chartHeightStr);

	}

	if(null!=debugModeStr && !debugModeStr.equals("")){

		debugMode = new Boolean(debugModeStr);

		debugModeInt=boolToNum(debugMode);

	}

	if(null!=registerWithJSStr && !registerWithJSStr.equals("")){

		registerWithJS = new Boolean(registerWithJSStr);

		regWithJSInt=boolToNum(registerWithJS);

	}





%>

			

			
Chart
<%! /** * Converts a Boolean value to int value * * @param bool Boolean value which needs to be converted to int value * @return int value correspoding to the boolean : 1 for true and 0 for false */ public int boolToNum(Boolean bool) { int num = 0; if (bool.booleanValue()) { num = 1; } return num; } %>




Here's also a sample how I connect to MySQL (and it's working):



String strXML = "";



strXML = "";



String cxz = "";

int zxc = 0;



Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");

String dsn = "jdbc:odbc:abc";

String user="root";

String pass="";



Connection con=DriverManager.getConnection(dsn,user,pass);

Statement st = con.createStatement();



String query1 = "Select * from votes";

ResultSet rs1 = st.executeQuery(query1);



        while(rs1.next())

        {

         school = rs1.getString(2);

         num_votes = (Integer.parseInt(rs1.getString(3)));



         strXML += "";

        }

         strXML += "";




and finally, the code for the chart insertion:





              

              

              

              

              

              

              

              

         




also I would like to ask am I placing the FusionCharts folder in the right place? btw, I'm using Netbeans, for the column3D I'm using right now (the one currently working) it's in my images folder that can be found in the web folder. I tried pasting all the swf files for accessing the charts but it's not working, below are pics where am I right or wrong in placing the FC Folder.



Pic 1 (will I put it here?):

Posted Image



Pic 2 (or here?):

Posted Image



Thanks Guys, Hope someone can help me :( this is a bit urgent
0

Other Replies To This Topic

#2 User is offline   Basundhara Ghosal 

  • Supreme Being
  • PipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 2459
  • Joined: 15-September 09

Posted 18 June 2010 - 06:08 AM

Hi,

Could you please send us the XML codes that you are using to render the chart as an attachment?

Awaiting your reply.

Regards,

Basundhara Ghosal

Follow us on Twitter :D
0

Other Replies To This Topic

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic