<%@ page import = "com.gp.api.jsp.MxServerComponent" %>
<%@ page import = "com.gp.api.jsp.MxChartDescription"%>
<%@ page import = "com.gp.api.styles.*"%>
<%@ page import = "com.gp.api.styles.chart.*"%>
<%@ page import = "com.gp.api.styles.elements.*"%>
<table cellspacing=0 cellpadding=0 border=0><tr><td class=bodyText>
<%!
// This function produces combobox named name with values vals, currently selected item defined by
// the value of the request parameter named name or default index if the request parameter is not
// defined
public String combo(HttpServletRequest request, String name, String [] vals, int defind) {
StringBuffer sb = new StringBuffer();
String param = request.getParameter(name);
if(param == null)
param = vals[defind];
sb.append("<select id=").append(name).append(" name=").append(name);
sb.append(" onchange=\"javascript:document.StyleForm.submit()\"");
sb.append(">\n");
for(int i=0;i<vals.length;i++) {
sb.append("<option value=\"").append(vals[i]).append('"');
if(vals[i].equals(param))
sb.append(" selected");
sb.append('>');
sb.append(vals[i]);
sb.append("</option>\n");
}
sb.append("</select>\n");
return sb.toString();
}
%>
<%
// Create and polulate style object
String defStyleXML = "<frameChart is3D=\"false\"><frame isHStripVisible=\"true\" stripColor=\"#40CCAAEE\"/>"+
"<xAxis isAntialiased=\"true\"> <labelFormat pattern=\"#,##0.###\"/> <parseFormat pattern=\"#,##0.###\"/>"+
"<titleStyle font=\"Arial-12-bold\">Year </titleStyle> </xAxis> <yAxis scaleMin=\"0\" isAntialiased=\"true\">"+
"<labelFormat pattern=\"#,##0.###\"/><parseFormat pattern=\"#,##0.###\"/> <titleStyle margin=\"4\" font=\"Arial-12-bold\">"+
"<![CDATA[ Sales ('000) ]]></titleStyle></yAxis><legend spacing=\"0\" halign=\"Right\" isAntialiased=\"true\">"+
"<decoration style=\"None\"/></legend><elements drawShadow=\"true\">"+
"</elements><popup background=\"#CCFFFF\" isAntialiased=\"true\" foreground=\"black\"/>"+
"<paint isVertical=\"true\" min=\"47\" max=\"83\"/></frameChart>" ;
String styleXML = request.getParameter("styleXML");
MxFrameChartStyle style = (MxFrameChartStyle) MxChartStyle.read(styleXML != null ? styleXML : defStyleXML,null);
String is3D = request.getParameter("is3D");
style.is3D = "on".equalsIgnoreCase(is3D);
String hideGrid = request.getParameter("hideGrid");
style.frame.isHGridVisible = !"on".equalsIgnoreCase(hideGrid);
String isTransluent = request.getParameter("isTransluent");
boolean transluent = "on".equalsIgnoreCase(isTransluent);
String palette = request.getParameter("palette");
if("Pastel".equals(palette))
style.paint.palette = transluent ? MxPaletteStyle.PASTELTRANSLUENT : MxPaletteStyle.PASTEL;
else
if("Sunburn".equals(palette))
style.paint.palette = transluent ? MxPaletteStyle.SUNBURNTRANSLUENT : MxPaletteStyle.SUNBURN;
else
if("Dawn".equals(palette))
style.paint.palette = transluent ? MxPaletteStyle.DAWNTRANSLUENT : MxPaletteStyle.DAWN;
else
if("Modern".equals(palette))
style.paint.palette = transluent ? MxPaletteStyle.MODERNTRANSLUENT : MxPaletteStyle.PASTELDARK;
else
if("Steel".equals(palette))
style.paint.palette = transluent ? MxPaletteStyle.STEELTRANSLUENT : MxPaletteStyle.SUNBURNTDARK;
else
style.paint.palette = transluent ? MxPaletteStyle.TRANSLUENT : MxPaletteStyle.STANDARD;
String frame = request.getParameter("frame");
if("Thick".equals(frame))
style.frame.type = MxFrameStyle.FrameDecoration.THICK;
else
if("Tray".equals(frame))
style.frame.type = MxFrameStyle.FrameDecoration.TRAY;
else
if("None".equals(frame))
style.frame.type = MxFrameStyle.FrameDecoration.NONE;
else
style.frame.type = MxFrameStyle.FrameDecoration.SIMPLE;
// Create and display the chart
MxServerComponent svr = MxServerComponent.getDefaultInstance(application);
MxChartDescription myChart = svr.newImageSpec();
myChart.width = 320 ;
myChart.height= 300 ;
myChart.type = "PNG" ;
myChart.style = style.toXML();
myChart.model = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<XML type=\"default\">\n<COL>2000</COL>\n<COL>2001</COL>\n<COL>2002</COL>\n<COL>2003</COL>\n<COL>2004</COL>\n<ROW col0=\"100.0\" col1=\"200.0\" col2=\"100.0\" col3=\"180.0\" col4=\"200.0\">Laptops</ROW>\n<ROW col0=\"150.0\" col1=\"300.0\" col2=\"250.0\" col3=\"230.0\" col4=\"250.0\">Desktops</ROW>\n</XML>";
out.write(svr.getImageTag(myChart,"getimage.jsp?image="));
%>
</td><td width=20></td><td valign=top style="font-family:Arial; font-size:10pt">
<form name=StyleForm id=StyleForm method="POST">
<input type=hidden name="styleXML" value="<%=myChart.style.replace('"', '\'') %>">
<table class=bodyText cellpadding=4 cellspacing=4 border=0>
<tr><td colspan=2>Modify the chart's style using the controls below:</td></tr>
<tr><td colspan=2><input type=checkbox name=is3D onclick="javascript:document.StyleForm.submit()" <%="on".equalsIgnoreCase(is3D) ? "checked" : ""%>>Is 3D</td></tr>
<tr><td colspan=2><input type=checkbox name=hideGrid onclick="javascript:document.StyleForm.submit()" <%="on".equalsIgnoreCase(hideGrid) ? "checked" : ""%>>Hide Y Axis grid</td></tr>
<tr><td colspan=2><input type="checkbox" name="isTransluent" onclick="javascript:document.StyleForm.submit()" <%=("on".equalsIgnoreCase(isTransluent)) ? "checked" :"" %>>Is Transluent</td></tr>
<tr><td>Palette: </td>
<td width='100%'><%=combo(request,"palette", new String[] {"Standard", "Pastel", "Sunburn", "Dawn", "Modern", "Steel"},0) %></td>
</tr><tr><td>Frame: </td>
<td width='100%'><%=combo(request,"frame", new String[] {"Thin", "Thick", "Tray", "None"},0) %></td>
</tr></table>
</td>
</form>
</td></tr></table>
|