Sign in to follow this  
ktsha

Problem Regarding Link in Drill Down Fusion Chart

Recommended Posts

Dear all,

 

 

 

I had created a fusion chart of StackedBar3D .I am successfull in getting the fusion chart.

 

Now i am trying to implement a Drill down chart by caling a javascript function.

 

 

 

My codes are like written below

 


StringWriter chartXML = new StringWriter();

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



xStreamWriter2.writeStartDocument();

 xStreamWriter2.writeStartElement("chart");

   xStreamWriter2.writeStartElement("categories");

     for (Map map : resultList) {



        xStreamWriter2.writeStartElement("category");

          xStreamWriter2.writeAttribute("label", (String) map.get("status_name")); // label names are displaying successfully

          //for implementing drill down chart from the documentation i found using the link attribute and calling the javascript function. According to documentation i written like this where updateFusionChart is the Javascript function.

          xStreamWriter2.("link","j-updateFusionChart-""+newCondQuery+"",""

             +FuncName+"",""+status_name+"",""+DrillDownKPI+""");

         //xStreamWriter2.writeAttribute("link","javaScript:updateFusionChart(""+newCondQuery+"",""

             +FuncName+"",""+(String)map.get("status_name")+"",""+DrillDownKPI+"" )");

         xStreamWriter2.writeEndElement();// category

      }

    xStreamWriter2.writeEndElement(); // categories

 

I am trying to implement a Stacked Column 3D chart and i am successfull in generating it. When i pointed my mouse curson on the generated chart even the link cursor is also not displaying.I am facing the problem of link. Is there any problem with my link attribute and the javascript calling method.

 

 

 

i tried with the two ways of calling javascript function.The second one is commented in the code

 

 

 

I am a premium customer of Fusion Chart.

 

Currently i am using Fusion chart version 3.1.

 

 

 

Please Help me ....

Share this post


Link to post
Share on other sites

Hi shajeerkt,

 

 

 

Could you please send us the XML that is being generated.

 

 

 

Please also specify whether you are using dataXML or dataURL method.

 

 

 

You might pass us the code that you are using to render the chart.

 

 

 

It seems that there might be some issue with the quote that is encapsulating the parameter that for the link.

Share this post


Link to post
Share on other sites

here is my javascript function i am calling

 


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;

	}

}

 

 

 

 

 

i am using dataURL method.

 

 

 

 

 

This is my java file

 


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");

				System.out.println(" ================ > (String) series[j] :" + (String) series[j]);

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



				// xStreamWriter2.writeAttribute("color", "A66EDD");



				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.writeAttribute("link","JavaScript:sample();");





						//k++;

					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("bgColor", "666666");

			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("bgColor", "666666");

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

			// xStreamWriter2.writeAttribute("color", "FFFFFF");

			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(""", "'");



}

 

 

 

When i tried with fire bug the error was "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

 

 

 

 

 

Any help will be appreciated.

 

 

 

I am unable to post my XML generated .How can i post my XML.

Share this post


Link to post
Share on other sites

Hi ,

I find your link definition is as follows:

1 sample:

updateFusionChart(&quot;1%3D1+AND+THE_DATE+%3E%3D+TO_DATE%28%2701.01.2008%27%2C+%27DD.MM.YYYY%27%29&quot;,&quot;HumanResources (Development)&quot;,&quot;Canceled&quot;,&quot;&quot; );'

Please note that instead of " you have used &quot;.

This is invalid.

Please change your code so that it renders the link as this:

updateFusionChart("1%3D1+AND+THE_DATE+%3E%3D+TO_DATE%28%2701.01.2008%27%2C+%27DD.MM.YYYY%27%29","HumanResources (Development)","Canceled","" );

I have tried reaplacing all &quot;. to " and it worked! :D

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

You are most welcome.

We are glad to help you.

Happy FusionCharting. :D

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