chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r812499 - in /hadoop/chukwa/trunk/src: java/org/apache/hadoop/chukwa/hicc/ web/hicc/js/ web/hicc/js/workspace/ web/hicc/jsp/
Date Tue, 08 Sep 2009 13:24:15 GMT
Author: eyang
Date: Tue Sep  8 13:24:14 2009
New Revision: 812499

URL: http://svn.apache.org/viewvc?rev=812499&view=rev
Log:
CHUKWA-384. Added REST API charting capability. (Eric Yang)

Modified:
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Chart.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/ColorPicker.java
    hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js
    hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js
    hadoop/chukwa/trunk/src/web/hicc/jsp/chart.jsp
    hadoop/chukwa/trunk/src/web/hicc/jsp/single-series-chart-javascript.jsp

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Chart.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Chart.java?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Chart.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/Chart.java Tue Sep  8 13:24:14
2009
@@ -41,6 +41,7 @@
   private String graphType;
   private ArrayList<TreeMap<String, TreeMap<String, Double>>> dataset;
   private ArrayList<String> chartType;
+  private ArrayList<String> restData;
   private boolean xLabelOn;
   private boolean yLabelOn;
   private boolean yRightLabelOn;
@@ -123,7 +124,7 @@
   }
 
   public void setDataSet(String chartType,
-      TreeMap<String, TreeMap<String, Double>> data) {
+    TreeMap<String, TreeMap<String, Double>> data) {
     if (this.dataset == null) {
       this.dataset = new ArrayList<TreeMap<String, TreeMap<String, Double>>>();
       this.chartType = new ArrayList<String>();
@@ -132,6 +133,19 @@
     this.chartType.add(chartType);
   }
 
+  public void setDataSet(String chartType, String series, String data) {
+    if (this.dataset == null) {
+      this.restData = new ArrayList<String>();
+      this.dataset = new ArrayList<TreeMap<String, TreeMap<String, Double>>>();
+      this.chartType = new ArrayList<String>();
+    }
+    this.chartType.add(chartType);
+    this.restData.add(data);
+    TreeMap<String, TreeMap<String, Double>> tree = new TreeMap<String, TreeMap<String,
Double>>();
+    tree.put(series, new TreeMap<String, Double>()); 
+    this.dataset.add(tree);
+  }
+
   public void setSeriesOrder(String[] metrics) {
     this.seriesOrder = metrics;
   }
@@ -177,38 +191,41 @@
   public String plot() {
     SimpleDateFormat format = new SimpleDateFormat("m:s:S");
     StringBuilder output = new StringBuilder();
-    if (dataset == null) {
+    if (dataset == null && restData == null) {
       output.append("No Data available.");
       return output.toString();
     }
     String dateFormat = "%H:%M";
     if (xLabel.intern() == "Time".intern()) {
-      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-      try {
-        long xMin = 0;
-        long xMax = 0;
-        if(xLabelRange!=null && xLabelRange.size()>0) {
-          xMin = Long.parseLong(xLabelRange.get(0));
-          xMax = Long.parseLong(xLabelRange.get(xLabelRange.size() - 1));
-        }
-        if (xMax - xMin > 31536000000L) {
-          dateFormat = "%y";
-        } else if (xMax - xMin > 2592000000L) {
-          dateFormat = "%y-%m";
-        } else if (xMax - xMin > 604800000L) {
-          dateFormat = "%m-%d";
-        } else if (xMax - xMin > 86400000L) {
-          dateFormat = "%m-%d %H:%M";
-        }
-      } catch (NumberFormatException e) {
-        dateFormat = "%y-%m-%d %H:%M";
-      }
+//      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//      try {
+//        long xMin = 0;
+//        long xMax = 0;
+//        if(xLabelRange!=null && xLabelRange.size()>0) {
+//          xMin = Long.parseLong(xLabelRange.get(0));
+//          xMax = Long.parseLong(xLabelRange.get(xLabelRange.size() - 1));
+//        }
+//        if (xMax - xMin > 31536000000L) {
+//          dateFormat = "%y";
+//        } else if (xMax - xMin > 2592000000L) {
+//          dateFormat = "%y-%m";
+//        } else if (xMax - xMin > 604800000L) {
+//          dateFormat = "%m-%d";
+//        } else if (xMax - xMin > 86400000L) {
+//          dateFormat = "%m-%d %H:%M";
+//        }
+//      } catch (NumberFormatException e) {
+//        dateFormat = "%y-%m-%d %H:%M";
+//      }
     }
     StringBuilder xAxisOptions = new StringBuilder();
     if (xLabel.intern() == "Time".intern()) {
-      xAxisOptions.append("timeformat: \"");
-      xAxisOptions.append(dateFormat);
-      xAxisOptions.append("\",mode: \"time\"");
+//      if(this.restData==null) {
+//        xAxisOptions.append("timeformat: \"");
+//        xAxisOptions.append(dateFormat);
+//        xAxisOptions.append("\",");
+//      }
+      xAxisOptions.append("mode: \"time\"");
     } else {
       xAxisOptions
           .append("tickFormatter: function (val, axis) { if(val!=0) { return xLabels[Math.round(val)];
} else { return \" \"; }; }, ticks: 5");
@@ -349,7 +366,7 @@
       }
       for (String seriesName : keyNames) {
         int counter2 = 0;
-        if (counter != 0) {
+        if ((counter != 0) || (i != 0)) {
           output.append(",");
         }
         String param = "fill: false";
@@ -371,7 +388,7 @@
         output.append(": { show: true, ");
         output.append(param);
         output.append(" }, color: \"");
-        output.append(cp.get(counter + 1));
+        output.append(cp.getNext());
         output.append("\", label: \"");
         output.append(seriesName);
         output.append("\", ");
@@ -436,9 +453,27 @@
       i++;
     }
     output.append(" ];\n");
+    if(this.restData!=null) {
+        output.append("var _rest = [");
+        boolean first=true;
+        for(String url : restData) {
+            if(!first) {
+                output.append(",");
+            }
+            output.append("\"");
+            output.append(url);
+            output.append("\"");
+            first=false;
+        }
+        output.append("];");
+    }
     if (request != null && xf.getParameter("format") == null) {
-	output.append("$(document).ready(function() { \n");	
-	output.append("   wholePeriod();\n");
+	output.append("$(document).ready(function() { \n");
+        if(this.restData!=null) {
+            output.append("   loadData();\n");
+        } else {
+	    output.append("   wholePeriod();\n");
+        }
 	output.append("   $(window).resize(function() { wholePeriod(); });\n");
 	output.append("});\n");
 	output.append("</script>\n");

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/ColorPicker.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/ColorPicker.java?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/ColorPicker.java (original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/hicc/ColorPicker.java Tue Sep  8
13:24:14 2009
@@ -21,6 +21,7 @@
 
 public class ColorPicker {
   private String color = "#ff5757";
+  private int index = 0;
 
   public ColorPicker() {
     color = "#ff5757";
@@ -28,11 +29,11 @@
 
   public String get(int counter) {
     if ((counter % 6) == 0) {
-      String cyan = Integer.toHexString(256 - (counter % 255));
-      color = "#57" + cyan + cyan;
-    } else if ((counter % 5) == 0) {
       String purple = Integer.toHexString(256 - (counter % 255));
       color = "#" + purple + "57" + purple;
+    } else if ((counter % 5) == 0) {
+      String red = Integer.toHexString(256 - (counter % 255));
+      color = "#" + red +"5757";
     } else if ((counter % 4) == 0) {
       String yellow = Integer.toHexString(256 - (counter % 255 * 20));
       color = "#FF" + yellow + "00";
@@ -40,11 +41,17 @@
       String green = Integer.toHexString(256 - (counter % 255));
       color = "#57" + green + "57";
     } else if ((counter % 2) == 0) {
+      String cyan = Integer.toHexString(256 - (counter % 255));
+      color = "#57" + cyan + cyan;
+    } else {
       String blue = Integer.toHexString(256 - (counter % 255));
       color = "#5757" + blue + "";
-    } else {
-      color = "#ff5757";
     }
     return this.color;
   }
+
+  public String getNext() {
+    index++;
+    return get(index);
+  }
 }

Modified: hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js (original)
+++ hadoop/chukwa/trunk/src/web/hicc/js/flot.extend.js Tue Sep  8 13:24:14 2009
@@ -1,5 +1,6 @@
 var zoom=false;
 var bound=null;
+var _chartSeriesSize=0;
 
 /*
  * calculcate the min, max, average of the data set
@@ -119,6 +120,7 @@
     total_height+=$("#placeholderLegend").height();
     total_height+=$("#statisLegend").height();
   }
+  total_height+=25;
   setIframeHeight(document.getElementById('boxId').value, total_height);
 };
 
@@ -127,15 +129,15 @@
  */
 options={
  points: { show: true },
- xaxis: {                timeformat: "%y/%O/%D<br/>%H:%M:%S",
-			 mode: "time"
+ xaxis: {
+   mode: "time"
  },
  selection: { mode: "xy" },
  grid: {
-  hoverable: false,
-  clickable: true,
-  tickColor: "#C0C0C0",
-  backgroundColor:"#FFFFFF"
+   hoverable: false,
+   clickable: true,
+   tickColor: "#C0C0C0",
+   backgroundColor:"#FFFFFF"
  },
  legend: { show: false }
 };
@@ -258,11 +260,32 @@
       } catch(err) {
         return false;
       }
-    });
+    });a
+    if(_rest!=null) {
+      loadData(url, parameters);
+    }
   }
   return true;
 }
 
+/*
+ * Initialize data from REST API.
+ */
+function loadData() {
+  for(var i=0;i<_series.length;i++) {
+    $.getJSON(_rest[i], function(json) {
+      var name=json.name;
+      _series[_chartSeriesSize].label=name
+      _series[_chartSeriesSize].data=json.data;
+      _chartSeriesSize++;
+      wholePeriod();
+    }); 
+  }
+}
+
+/*
+ * Generate static image report
+ */ 
 function saveReport() {
   var pattern = /https?:\/\/(.*?)\//;
   var baseUrl = pattern.exec(location.href)[0];

Modified: hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js (original)
+++ hadoop/chukwa/trunk/src/web/hicc/js/workspace/workspace.js Tue Sep  8 13:24:14 2009
@@ -597,7 +597,8 @@
     closeEditBox: function() {
 	// close the edit box
    	var editBox= $('dragableBoxEdit' + this.pageid+"_"+this.boxIndex);
-      	editBox.style.display='none';
+        new Effect.BlindUp(editBox);
+      	//editBox.style.display='none';
         $('dragableBoxHeader' + this.pageid+"_"+this.boxIndex).style.height = '20px';
     },
 
@@ -996,7 +997,7 @@
    if(!obj)obj=this;
    
    var id = obj.id.replace(/[^0-9|_]/g,'');
-   showHeader(id, 'hidden');
+   showHeader(id, 'visible');
 }
 	
 function initDragDropBox(e) {
@@ -1191,9 +1192,12 @@
    var numericId = this.id.replace(/[^0-9|_]/g,'');
    var obj = $('dragableBoxEdit' + numericId);
    if(obj.style.display=='none'){
-      obj.style.display='block';
+      //obj.style.display='block';
+      new Effect.BlindDown($('dragableBoxEdit'+numericId));
+
    }else{
-      obj.style.display='none';
+      new Effect.BlindUp($('dragableBoxEdit'+numericId));
+      //obj.style.display='none';
    }
    setTimeout('dragDropCounter=-5',5);
 }
@@ -1233,7 +1237,7 @@
                 alert(e);
             }
 	}
-        showHeader(boxId, 'hidden');
+        showHeader(boxId, 'visible');
    }
 }
 

Modified: hadoop/chukwa/trunk/src/web/hicc/jsp/chart.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/chart.jsp?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/chart.jsp (original)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/chart.jsp Tue Sep  8 13:24:14 2009
@@ -17,56 +17,136 @@
  * limitations under the License.
  */
 %>
-<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter"  %>
-
-<%
-   XssFilter = new XssFilter(request);
-   response.setHeader("boxId", xf.getParameter("boxId"));
-%>
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
-    pageEncoding="ISO-8859-1"%>
-<div style="height:250px">
+<%@ page import = "java.sql.*" %>
+<%@ page import = "java.io.*" %>
+<%@ page import = "java.util.Calendar" %>
+<%@ page import = "java.util.Date" %>
+<%@ page import = "java.text.SimpleDateFormat" %>
+<%@ page import = "java.util.*" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.ClusterConfig" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.TimeHandler" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.Chart" %>
+<%@ page import = "org.apache.hadoop.chukwa.hicc.DatasetMapper" %>
+<%@ page import = "org.apache.hadoop.chukwa.database.DatabaseConfig" %>
+<%@ page import = "org.apache.hadoop.chukwa.database.Macro" %>
+<%@ page import = "org.apache.hadoop.chukwa.util.XssFilter" %>
 <%
-if(request.getParameter("period")==null && ((request.getParameter("start")==null
|| request.getParameter("end")==null))) {
-  out.println("<h2>Select a time range, and host list.</h2>");
-} else {
-String base = "";
-int width = 500;
-int height = 250;
-String dataurl = request.getRequestURL().toString();
-//
-// escape the & and stuff:
-//
-String url = java.net.URLEncoder.encode(dataurl.replace("/chart.jsp", "/chart-data.jsp?"+request.getQueryString()),
"UTF-8");
-
-//
-// if there are more than one charts on the
-// page, give each a different ID
-//
-//int open_flash_chart_seqno;
-String obj_id = "chart";
-//String div_name = "flashcontent";
-// These values are for when there is >1 chart per page
-//    $open_flash_chart_seqno++;
-//    $obj_id .= '_<%=open_flash_chart_seqno;
-//    $div_name .= '_<%=open_flash_chart_seqno;
-// Not using swfobject: <script type="text/javascript" src="< % = base % >js/swfobject.js"></script>
+    XssFilter xf = new XssFilter(request);
+    String boxId=xf.getParameter("boxId");
+    response.setHeader("boxId", xf.getParameter("boxId"));
+    response.setContentType("text/html; chartset=UTF-8//IGNORE");
+
+    /*
+     * Set chart title, and output type.
+     */
+    String title = xf.getParameter("title");
+    String graphType = xf.getParameter("graph_type");
+
+    /*
+     * Set chart width.
+     */
+    int width=300;
+    if(request.getParameter("width")!=null) {
+      width=Integer.parseInt(request.getParameter("width"));
+    }
+
+    /*
+     * Set chart height.
+     */
+    int height=200;
+    if(request.getParameter("height")!=null) {
+      height=Integer.parseInt(request.getParameter("height"));
+    }
+
+    /*
+     * Set series data source.
+     */
+    String[] seriesName = xf.getParameterValues("series_name");
+    String[] data = xf.getParameterValues("data");
+
+    /*
+     * Set series render format.
+     */
+    String[] render = null;
+    if(request.getParameter("render")!=null) {
+      render=xf.getParameterValues("render");
+    } 
+    if(render==null || render.length!=data.length) { 
+      render = new String[data.length];
+      for(int i=0;i<data.length;i++) {
+        render[i] = "line";
+      }
+    }
+
+    Chart c = new Chart(request);
+
+    /*
+     * Setup x axis display.
+     */
+    if(request.getParameter("x_label")!=null && xf.getParameter("x_label").equals("on"))
{
+      c.setXAxisLabels(true);
+    } else {
+      c.setXAxisLabels(false);
+    }
+    if(request.getParameter("x_axis_label")!=null) {
+      c.setXAxisLabel(xf.getParameter("x_axis_label"));
+    } else {
+      c.setXAxisLabel("Time");
+    }
+
+    /*
+     * Setup y axis display.
+     */
+    if(request.getParameter("y_label")!=null && xf.getParameter("y_label").equals("on"))
{
+      c.setYAxisLabels(true);
+      c.setYAxisLabel(xf.getParameter("y_axis_label"));
+    } else {
+      c.setYAxisLabels(false);
+      c.setYAxisLabel("");
+    }
+    if(request.getParameter("y_axis_max")!=null) {
+      double max = Double.parseDouble(xf.getParameter("y_axis_max"));
+      c.setYMax(max);
+    }
+    if(request.getParameter("display_percentage")!=null) {
+      c.setDisplayPercentage(true);
+    }
+
+    /*
+     * Setup title.
+     */
+    if(title!=null) {
+      c.setTitle(title);
+    }
+
+    /*
+     * Setup legend display.
+     */
+    if(request.getParameter("legend")!=null && xf.getParameter("legend").equals("off"))
{
+      c.setLegend(false);
+    }
+
+    /*
+     * Setup series display.
+     */
+    c.setGraphType(graphType);
+    c.setSize(width,height);
+
+    /*
+     * Setup data structure.
+     */
+    if(seriesName!=null && data.length==seriesName.length) {
+      for(int i=0;i<data.length;i++) {
+        c.setDataSet(render[i],seriesName[i],data[i]);
+      }
+    } else {
+      for(int i=0;i<data.length;i++) {
+        c.setDataSet(render[i],"",data[i]);
+      }
+    }
+
+    /*
+     * Render graph
+     */
+    out.println(c.plot());
 %>
-<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
-	codebase="<%= request.getProtocol() %>://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
-	width="100%" height="100%" id="ie_<%=obj_id %>" align="middle" style="z-index: 1;">
-  <param name="allowScriptAccess" value="sameDomain" />
-  <param name="movie" value="<%=base%>open-flash-chart.swf?width=<%=width%>&height=<%=height%>&data=<%=url%>"
/>
-  <param name="quality" value="high" />
-  <param name="bgcolor" value="#ffffff" />
-  <param name="wmode" value="transparent" />
-  <embed src="<%=base%>open-flash-chart.swf?data=<%=url%>&metric=CPUBusy"

-    quality="high" bgcolor="#ffffff" 
-  	width="100%" height="100%" name="<%=obj_id%>" align="middle" allowScriptAccess="sameDomain"
-	type="application/x-shockwave-flash" 
-	pluginspage="<%=request.getProtocol()%>://www.macromedia.com/go/getflashplayer" 
-	id="<%=obj_id%>"
-	/>
-</object>
-<% } %>
-</div>

Modified: hadoop/chukwa/trunk/src/web/hicc/jsp/single-series-chart-javascript.jsp
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/web/hicc/jsp/single-series-chart-javascript.jsp?rev=812499&r1=812498&r2=812499&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/web/hicc/jsp/single-series-chart-javascript.jsp (original)
+++ hadoop/chukwa/trunk/src/web/hicc/jsp/single-series-chart-javascript.jsp Tue Sep  8 13:24:14
2009
@@ -38,6 +38,7 @@
     String render="line";
     String cluster = (String) session.getAttribute("cluster");
     String graphType = xf.getParameter("graph_type");
+    String data = xf.getParameter("data");
     ArrayList<Object> parms = new ArrayList<Object>();
     int width=300;
     int height=200;
@@ -135,30 +136,31 @@
     if(start<=0 || end<=0) { %>
 No time range specified.  Select a time range through widget preference, or use Time widget.
 <%  } else {
-       String dateclause = " timestamp between ? and ? ";
-       if(request.getParameter("period")!=null && request.getParameter("period").equals("0"))
{
-           dateclause = "";
-       }
-       try {
-           org.apache.hadoop.chukwa.util.DriverManagerUtil.loadDriver().newInstance();
-       } catch (Exception ex) {
-       }
-       Connection conn = null;
-       Statement stmt = null;
-       ResultSet rs = null;
-       String table = (String)xf.getParameter("table");
-       if(table==null) {
-           table = "cluster_system_metrics";
-       }
-       if(request.getParameter("group_override")!=null) {
-           group=(xf.getParameter("group_override").replaceAll("%27","'").replaceAll(";",""));
-       }
-       String[] tables = null;
-       DatabaseConfig dbc = new DatabaseConfig();
-       tables = dbc.findTableNameForCharts(table,start,end);
        ArrayList<String> labels = new ArrayList<String>();
        TreeMap<String, TreeMap<String, Double>> dataMap = new TreeMap<String,
TreeMap<String, Double>>();
-       for(String tmpTable : tables) {
+       if(data==null) {
+         String dateclause = " timestamp between ? and ? ";
+         if(request.getParameter("period")!=null && request.getParameter("period").equals("0"))
{
+             dateclause = "";
+         }
+         try {
+             org.apache.hadoop.chukwa.util.DriverManagerUtil.loadDriver().newInstance();
+         } catch (Exception ex) {
+         }
+         Connection conn = null;
+         Statement stmt = null;
+         ResultSet rs = null;
+         String table = (String)xf.getParameter("table");
+         if(table==null) {
+             table = "cluster_system_metrics";
+         }
+         if(request.getParameter("group_override")!=null) {
+             group=(xf.getParameter("group_override").replaceAll("%27","'").replaceAll(";",""));
+         }
+         String[] tables = null;
+         DatabaseConfig dbc = new DatabaseConfig();
+         tables = dbc.findTableNameForCharts(table,start,end);
+         for(String tmpTable : tables) {
            String query = null;
            StringBuilder q = new StringBuilder();
            q.append("select ");
@@ -214,47 +216,50 @@
                    dataMap.put(ts,tmpDataMap.get(ts));
                }
            } 
+         }
        }
+       if(request.getParameter("render")!=null) {
+           render=xf.getParameter("render");
+       }
+       Chart c = new Chart(request);
+       c.setYAxisLabels(false);
+       if(request.getParameter("x_label")!=null && xf.getParameter("x_label").equals("on"))
{
+           c.setXAxisLabels(true);
+       } else {
+           c.setXAxisLabels(false);
+       }
+       c.setYAxisLabel("");
+       if(request.getParameter("x_axis_label")!=null) {
+           c.setXAxisLabel(xf.getParameter("x_axis_label"));
+       } else {
+           c.setXAxisLabel("Time");
+       }
+       if(title!=null) {
+           c.setTitle(title);
+       } else {
+           c.setTitle(metrics.toString());
+       }
+       if(request.getParameter("y_axis_max")!=null) {
+           double max = Double.parseDouble(xf.getParameter("y_axis_max"));
+           c.setYMax(max);
+       }
+       if(request.getParameter("display_percentage")!=null) {
+           c.setDisplayPercentage(true);
+       }
+       if(request.getParameter("legend")!=null && xf.getParameter("legend").equals("off"))
{
+           c.setLegend(false);
+       }
+       c.setGraphType(graphType);
+       c.setXLabelsRange(labels);
+       c.setSize(width,height);
        if(dataMap.size()!=0) {
-           if(request.getParameter("render")!=null) {
-               render=xf.getParameter("render");
-           }
-           Chart c = new Chart(request);
-           c.setYAxisLabels(false);
-           if(request.getParameter("x_label")!=null && xf.getParameter("x_label").equals("on"))
{
-               c.setXAxisLabels(true);
-           } else {
-               c.setXAxisLabels(false);
-           }
-           c.setYAxisLabel("");
-           if(request.getParameter("x_axis_label")!=null) {
-               c.setXAxisLabel(xf.getParameter("x_axis_label"));
-           } else {
-               c.setXAxisLabel("Time");
-           }
-           if(title!=null) {
-               c.setTitle(title);
-           } else {
-               c.setTitle(metrics.toString());
-           }
-           if(request.getParameter("y_axis_max")!=null) {
-               double max = Double.parseDouble(xf.getParameter("y_axis_max"));
-               c.setYMax(max);
-           }
-           if(request.getParameter("display_percentage")!=null) {
-	       c.setDisplayPercentage(true);
-	   }
-           if(request.getParameter("legend")!=null && xf.getParameter("legend").equals("off"))
{
-               c.setLegend(false);
-           }
-           c.setGraphType(graphType);
-           c.setXLabelsRange(labels);
-           c.setSize(width,height);
            c.setDataSet(render,dataMap);
-           if(metric!=null && group==null) {
-               c.setSeriesOrder(metric);
-           }
-           out.println(c.plot());
-        }
+       } else if(data!=null) {
+           c.setDataSet(render,"series",data);
+       }
+       if(metric!=null && group==null) {
+           c.setSeriesOrder(metric);
+       }
+       out.println(c.plot());
     }
 %>



Mime
View raw message