Sign in to follow this  
Dhruva

Fusion Chart Drill down Problem

Recommended Posts

Dear all,

 

 

 

Some body please help me to solve this issue.

 

 

 

I am facing a fusion chart Drill down problem.

 

 

 

 

 

i was trying to create a drill down chart. Please find my attached files.(java file and javascript files)

 

 

 

 

 




private String getStack2D_Request_XML1(HttpServletRequest request,String condQuery,boolean forDataURL, String kpi, String L1, String L2, String L3, String condtion, boolean links, String DrillDownKPI) {





	SqlMapClient sqlMapClient = (SqlMapClient) getServletContext().getAttribute("sqlMapClient");

	Map sqlParams = new HashMap();

	String FuncName;



	List> resultList = null;

	sqlParams.put("whereCase",condQuery);

	sqlParams.put("whereCase_ServProvider",condtion);

	StringWriter chartXML = new StringWriter();

	try {

		resultList = (List>) sqlMapClient.queryForList(kpi, sqlParams);





		XMLOutputFactory xOutputFactory = XMLOutputFactory.newInstance();

		XMLStreamWriter2 xStreamWriter2 = (XMLStreamWriter2) xOutputFactory.createXMLStreamWriter(chartXML);



		xStreamWriter2.writeStartDocument();

		xStreamWriter2.writeStartElement("chart");



		if(resultList.size() >=1 ){





			xStreamWriter2.writeAttribute("palette", "2");



			xStreamWriter2.writeAttribute("showValues", "0");





			xStreamWriter2.writeAttribute("animation", "1");

			xStreamWriter2.writeAttribute("formatNumberScale", "0");



			xStreamWriter2.writeStartElement("categories");

			int start = 0;

			List funcNameList = new ArrayList();

			List statusNameList = new ArrayList();



			for (Map map : resultList) {



				FuncName = (String) map.get("func_name");// Human Resources,

				if (FuncName != null)

					FuncName = FuncName.replaceAll("&", "And");

				else

					FuncName = "ALL";



				funcNameList.add(FuncName); 



				String status_name = (String) map.get("status_name");

				statusNameList.add(status_name);



				xStreamWriter2.writeStartElement("category");

				xStreamWriter2.writeAttribute("label", (String) map.get("status_name"));

				xStreamWriter2.writeEndElement();// category

			}



			xStreamWriter2.writeEndElement(); // categories



			int i,k ;

			Object[] series = (Object[]) resultList.get(0).keySet().toArray();

			for (int j = 2; j < series.length-1; j++) {





				xStreamWriter2.writeStartElement("dataset");



				xStreamWriter2.writeAttribute("seriesName", (String) series[j]);





				for (i = start,k = 0; i < resultList.size(); i++,k++) {



					Object[] record = (Object[]) resultList.get(i).values().toArray();



					xStreamWriter2.writeStartElement("set");



					    String newCondQuery = URLEncoder.encode(condQuery);

						xStreamWriter2.writeAttribute("value", "" + record[j]);



						/*xStreamWriter2.writeAttribute("link","j-updateFusionChart(""+newCondQuery+"",""+funcNameList.get(k)+"",""+statusNameList.get(k)+"",""+DrillDownKPI+"");");*/

						xStreamWriter2.writeAttribute("link","JavaScript:updateFusionChart(""+newCondQuery+"",""+funcNameList.get(k)+"",""+statusNameList.get(k)+"",""+DrillDownKPI+"" );");



					xStreamWriter2.writeEndElement(); // set

				}

				xStreamWriter2.writeEndElement(); // dataset

			}

			xStreamWriter2.writeStartElement("styles");



			xStreamWriter2.writeStartElement("definition");

			xStreamWriter2.writeStartElement("style");

			xStreamWriter2.writeAttribute("name", "CaptionFont");

			xStreamWriter2.writeAttribute("type", "font");

			xStreamWriter2.writeAttribute("size", "11");



			xStreamWriter2.writeAttribute("bold", "1");

			xStreamWriter2.writeAttribute("color", "666666");

			xStreamWriter2.writeEndElement(); // style



			xStreamWriter2.writeStartElement("style");

			xStreamWriter2.writeAttribute("name", "LabelsFont");

			xStreamWriter2.writeAttribute("type", "font");

			xStreamWriter2.writeAttribute("size", "11");



			xStreamWriter2.writeAttribute("bold", "1");



			xStreamWriter2.writeEndElement(); // style

			xStreamWriter2.writeEndElement(); // definition



			xStreamWriter2.writeStartElement("application");



			xStreamWriter2.writeStartElement("apply");

			xStreamWriter2.writeAttribute("toObject", "CAPTION");

			xStreamWriter2.writeAttribute("styles", "CaptionFont");

			xStreamWriter2.writeEndElement(); // apply



			xStreamWriter2.writeStartElement("apply");

			xStreamWriter2.writeAttribute("toObject", "DataLabels");

			xStreamWriter2.writeAttribute("styles", "LabelsFont");

			xStreamWriter2.writeEndElement(); // apply



			xStreamWriter2.writeEndElement(); // application



			xStreamWriter2.writeEndElement(); // styles



		}



		xStreamWriter2.writeEndElement(); // chart



		xStreamWriter2.writeEndDocument();



		xStreamWriter2.flush();

		xStreamWriter2.close();

	} catch (Exception e) {



		System.out.println("Exception occurred" + e.toString());

		e.printStackTrace();

	}

		return chartXML.toString().replace(""", "'");



}

 

 

 

 

 

My javascript function:

 


function updateFusionChart(condQuery,Mngmnt,stutus,kpi,serviceID){		



	alert("hi");

	if ( !serviceID){			



		var strURL = "ChartServlet?GM=" + Mngmnt + "&status=" +stutus + "&kpi=" +kpi+ "&condQuery=" +condQuery;			

		strURL = escape(strURL);			

	 	var chart_CityDetails = new FusionCharts('FusionCharts/StackedBar3D.swf?ChartNoDataText=Click right chart to view Services Details', 

		'ServDetails', '550', '450', '0', '1');	

		chart_CityDetails.setDataURL(strURL);

		chart_CityDetails.render(Mngmnt+kpi+"ServDetailsDiv");			

	}

	else if (serviceID){			

		var strURL = "ChartServlet?GM=" + Mngmnt + "&status=" +stutus + "&serviceID=" +serviceID + "&kpi=" +kpi+"&condQuery="+condQuery;									

		//URLEncode it - NECESSARY.

		strURL = escape(strURL);

	 	var chart_CityDetails = new FusionCharts('FusionCharts/StackedBar3D.swf?ChartNoDataText=Click right chart to view Services Details', 

		'SubServDetails', '800', '450', '0', '1');				

		chart_CityDetails.setDataURL(strURL);

		chart_CityDetails.render(Mngmnt+kpi+"SubServDetailsDiv");			

	}  	

	else {

		//Show error

		alert("Please wait for the charts to load.");

		return;

	}

}

 

 

 

My first chart is generating successfully. But when i clicked on a bar the link is not calling my javascript function .I tried with firebug .I am using a StackedBar3D.

 

 

 

it was telling "syntax error

 

javascript:updateFusionChart("1=1%20AND%20THE_DATE%20>=%20TO_DATE('01.01.2008',%20'DD.MM.YYYY')","Human%20Resources%20(Development)","Closed",""%20);

 

Line 1

 

 

 

Please help me.

Share this post


Link to post
Share on other sites

Hi,

 

I find from your post that the link generated is :

 

updateFusionChart("1=1%20AND%20THE_DATE%20>=%20TO_DATE('01.01.2008',%20'DD.MM.YYYY')","Human%20Resources%20(Development)","Closed",""%20);

 

Could you please try using " for all the " and ' for all ' in side the link attribute's value?

Edited by Guest

Share this post


Link to post
Share on other sites

Hi sudipto,

 

 

 

This is my link attribute value

 

 

 


String newCondQuery = URLEncoder.encode(condQuery);



xStreamWriter2.writeAttribute("link","JavaScript:updateFusionChart(""+newCondQuery+"",""+funcNameList.get(k)+"",""+statusNameList.get(k)+"",""+DrillDownKPI+"" );");

 

 

 

and this is the value that i am getting for newCondQuery

 

 

 

1%3D1+AND+THE_DATE+%3E%3D+TO_DATE%28%2701.01.2008%27%2C+%27DD.MM.YYYY%27%29

 

 

 

the " and ' are replaced by URLEncoder.

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