Pie chart with Dynamic Exploding

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sreenivas
Posts: 1
Joined: Thu Sep 30, 2010 5:06 am
antibot: No, of course not.

Pie chart with Dynamic Exploding

Post by sreenivas » Thu Sep 30, 2010 5:18 am

Hi

I am facing problem with JFree Pie chart,Chart generating related on all the operations in servlet, but this image is displays in jsp page. My requirement is when the cursor is place in the pie chart sector will be explode automatically the Pie chart it should be effected dynamically for all the sections how can i do using
JFree chart API.Please send complete solution with code.

Email id: Sreenivasreddy.tatikunta@pradhamas.com,sreenivasreddy_java@yahoo.com


My JSP Code:
____________________________________________________________________________________________
<body>
<%
String filename =DB_3D_PieServlet.generatePieChart( session,
new PrintWriter(out));
String graphURL = request.getContextPath() +
"/servlet/DisplayChart?filename=" + filename;
List li=(List)session.getAttribute("coursenames");


%>
<form name="rightclik_check" action="./NewCourse_Servlet">
<table>
<tr><td>
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%=
filename %>">
</body>
</html>
____________________________________________________________________
Code in servlet
____________________


public static String generatePieChart(HttpSession session, PrintWriter pw) {
String filename = null;
try {

String query = "SELECT CourseName,Sems FROM Course";

JDBCPieDataset dataset = new
JDBCPieDataset(getLocalConnection());
dataset.executeQuery(query);
// Create the chart object
PiePlot plot = new PiePlot(dataset);
plot.setInsets(new Insets(5, 5, 5, 5));

//this is for the border is empty
plot.setOutlinePaint(null);
plot.setURLGenerator(new
StandardPieURLGenerator("Pie_Chart1.jsp", "section"));
//plot.setToolTipGenerator(new
StandardPieItemLabelGenerator("{0} = {1} ({2})"));
//var gen = new StandardPieSectionLabelGenerator("{0} = {1}
({2})");

plot.setLabelGenerator(new
StandardPieItemLabelGenerator("{0} = {1} ({2})"));
JFreeChart chart = new JFreeChart("Courses with Sems",
JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(java.awt.Color.white);
//chart.getLegend().WEST_NORTHWEST;//setItemFont(new
java.awt.Font("Arial",0,20));
plot.setStartAngle(180);
plot.setDirection(Rotation.ANTICLOCKWISE);
plot.setForegroundAlpha(1.0f);
// plot.setExplodePercent(4,0.2);
// Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new
StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300,
info, session);

// Write the image map to the PrintWriter
ChartUtilities.writeImageMap(pw, filename, info, true);
pw.flush();

} catch (Exception e) {
System.out.println("Exception -" + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}
return filename;
}



Thanks& Regards
Sreenivas Reddy.T

Locked