Quick start
 
 Dynamic style
 
 Dynamic model
 
 Drill-down
 
 Real time
 
 Ajax
 
 Embedded
 
 
 
 
   Overview         Example         Source       

<%@ page import = "com.gp.api.jsp.MxServerComponent" %>
<%@ page import = "com.gp.api.jsp.MxChartDescription"%>
<%@ page import = "com.gp.api.model.MxStandardChartModel"%>

<table><tr><td>
<%
    // 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 = " <frameChart is3D=\"false\"> <frame xDepth=\"12\" yDepth=\"11\" 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 action=\"javascript:submitForm($(colIndex),$(rowIndex))\" drawShadow=\"true\"> <morph morph=\"Grow\"/> </elements> <title halign=\"Left\" isAntialiased=\"true\" font=\"Arial-12-bold\" foreground=\"blue\" isMultiline=\"false\"> <decoration style=\"None\"/>Computer Sales by Year </title> <popup background=\"#CCFFFF\" isAntialiased=\"true\" foreground=\"black\"/> <paint isVertical=\"true\" min=\"47\" max=\"83\"/> </frameChart>" ;   
    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 style='font-family: Arial; font-size:14px; font-weight: 400; color: blue'>
<% 
	// Get request parameters 

	String col = request.getParameter("colIndex");
	String row = request.getParameter("rowIndex");
	
	// Check if this is actually a POST request with filled values

	if(col != null && row!=null) {  
		int colIndex = Integer.parseInt(col);
		int rowIndex = Integer.parseInt(row);
		
		// Make sure that a chart element (not legend element) was clicked on.

		if(colIndex != -1 && rowIndex != -1) { 
			// Create object model 

			MxStandardChartModel model = (MxStandardChartModel)MxStandardChartModel.fromXML(myChart.model, null);
			// Write table with values for the particular column and row extracted from the model

			%>
			<table style='font-family: Arial; font-size:14px; font-weight: 400; color: blue'>
			<tr><td>Year: </td><td><%=model.getColLabelAt(colIndex)%></td></tr>
			<tr><td>Type:</td><td><%=model.getRowLabelAt(rowIndex) %></td></tr>
			<tr><td>Sales:</td><td><%=Double.toString(model.getValueAt(rowIndex, colIndex))%></td></tr>
			</table>
			<%
		}
	   }
else {%>Click on one of the chart's elements<%}%>
</td>

</tr>
</table>

<form name=OnClickForm id=OnClickForm method="POST">
<input type=hidden name=colIndex value="">
<input type=hidden name=rowIndex value="">
</form>

<script>
function submitForm(colIndex, rowIndex) {
	document.OnClickForm.colIndex.value = colIndex;
	document.OnClickForm.rowIndex.value = rowIndex;
	document.OnClickForm.submit();
}
</script>

 

   Copyright © 1994-2010 GreenPoint, Inc. All rights reserved.