Sign in to follow this  
aman0711

Cannot display multiple charts on one jsp page

Recommended Posts

Hi ppl,

I have a jsp page where I am trying to display two Line charts. Both the charts are produced in seperate jsp pages and I am including both the pages in the page where I am displaying those charts.

I am able to produce one chart on my page, but when I am including the jsp page containing the other chart, all I am seeing is "chart" getting displayed at the place where I have provided the include jsp directive. Can anyone please help me out with this problem.

Share this post


Link to post
Share on other sites

Hi Arindam,

I checked the javascript path and its perfect. Let me explain it to you.

I have 3 pages - aaa.jsp, bbb.jsp, ccc.jsp

bbb.jsp and ccc.jsp produces the chart and I am including these two jsps in my main page aaa.jsp.

I can perfectly see bbb.jsp on my main page aaa.jsp. But right below it where I am trying to show ccc.jsp, all I can see is "chart" written.

Share this post


Link to post
Share on other sites

Hi Arindam,

It still didnt work. It's confusing me now. When i can display one chart perfectly. why cant I display the other one the same page.

  I tried this as well.

I put

<script language="JavaScript" src="../FusionCharts/FusionCharts.js"></script>

  under the head section on aaa.jsp. but still all I can see is "chart". what could be wrong? because the other chart ie. bbb.jsp is getting displayed perfectly on aaa.jsp. why cant ccc.jsp is coming up. please help.

Then I made a totally blank jsp page and tried to include both the chart jsp's inside that and it still didnt work. just displaying one chart.

Here is the code for that jsp. both fc.jsp and sample_exe_fusion.jsp contains line charts.

 

>
</pre>
<table cellspacing="0" cellpadding="0" width="100%">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>dual</title>
<script language="JavaScript" src="../FusionCharts/FusionCharts.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Rational Application Developer">
</head>
<body>

<jsp:include page="fc.jsp" flush="false"></jsp:include>
<p> </p>
<jsp:include page="sample_exe_fusion.jsp" flush="false"></jsp:include>
</body>
</html>

</t

Share this post


Link to post
Share on other sites

Hi,

What might be that you are using same DIV id names in the 2 pages that you are including.

Could you please check that you are using Different DIV id names in the 2 pages that you are including?

Moreover, please note to give unique and different ChartID and JasvaScript object names for each chart.

This is my assumption that since you are using <jsp:include> you are basically adding the content of the included file to the main file. So the HTML is getting added to the main file and the 2 DIV ids are getting conflicted in the Browser. The javaScript can not determent where to render the chart.

I would also suggest you to check the file in all major browsers and let us know.

Share this post


Link to post
Share on other sites

Hi Sudipto...

  This time I included both the charts inside different div id's but still the same result.

HOw to give different chart id's?

I tried almost everythign I could. :) I have attached the files.. please go through with it and if possible, let me know the changes u make.

Main_jsp is including other two chart rendering jsp pages.

 

 

 

fus_APP.txt

Fus_ASSP.txt

Main_jsp.txt

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

Please modify your code. There FusionCharts Id are same both the file. Please follow this.

 

Change Code:

Fus_App.jsp page

String chartCode=createChart("../FusionCharts/MSLine.swf", "", strXml, "SLA", 745, 300, false, false);

 

Fus_ASSP.jsp

String chartCode2=createChart("../FusionCharts/MSLine.swf", "", strXml, "SLA1", 745, 300, false, false);

Main_jsp

<jsp:include page=" Fus_App.jsp" flush="false"></jsp:include>

<jsp:include page=" Fus_ASSP.jsp " flush="false"></jsp:include>

 

Note:

If you intend to include the same chart jsp page (with chart) a number of times in your main page, you would need to take care of the chart id of each chart being generated thus. You would need to provide unique chart id to each of the chart. For this you might pass a querystring (that provides chart id) to the include file which in turn would place the chart id passed through the querystring when rendering the chart. Thus you would be able to generate each chart having different chart id.

e.g.

 

Main_jsp  Page

<jsp:include page="sample_exe_app_fusion.jsp?chartID=ch1" flush="false"></jsp:include>

<jsp:include page="sample_exe_asp_fusion.jsp?chartID=ch2" flush="false"></jsp:include>

 

sample_exe_app_fusion.jsp  Page

String chart_id=request.getParameter("chartID")

String chartCode=createChart("../FusionCharts/MSLine.swf", "", strXml, chart_id, 745, 300, false, false);

Edited by Guest

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