Exemplo n.º 1
0
  // returns the number of points in this graph (equal to the
  // *maximum* length of an axis, or zero if at least one axis is
  // completely empty)
  private int getNumberOfPoints() {
    int xSize = xAxis.getData().length;
    int ySize = yAxis.getData().length;

    if (xSize == 0 || ySize == 0) {
      return 0;
    } else if (xSize > ySize) {
      return xSize;
    } else {
      return ySize;
    }
  }
Exemplo n.º 2
0
 public String convertData(int s[]) {
   dataCode = "";
   if (xAxis.getDataLen() != s.length) return "";
   //	dataCode += "var "+varName+"=[";
   dataCode += "[";
   for (int i = 0; i < s.length; i++) {
     if (xAxis.getDateLen() > -1)
       dataCode += "{x:parseDate(\"" + xAxis.getData(i) + "\"),y:" + s[i] + "},";
     else dataCode += "{x:" + xAxis.getData(i) + ",y:" + s[i] + "},";
   }
   dataCode += "]\n";
   return dataCode;
 }
Exemplo n.º 3
0
 private Boolean convertData() {
   dataCode = "";
   if (xAxis.getDataLen() != yAxis.getDataLen()) return false;
   if (xAxis.getDateLen() > -1)
     dataCode += "var parseDate = d3.time.format(\"%d-%m-%Y\").parse;\n";
   dataCode += "var data=[";
   for (int i = 0; i < xAxis.getDataLen(); i++) {
     if (xAxis.getDateLen() > -1)
       dataCode += "{x:parseDate(\"" + xAxis.getData(i) + "\"),y:" + yAxis.getData(i) + "},";
     else dataCode += "{x:" + xAxis.getData(i) + ",y:" + yAxis.getData(i) + "},";
   }
   dataCode += "];\n";
   return true;
 }
Exemplo n.º 4
0
  // returns the Y value of the nth point in this graph.  If the y
  // axis does not have an nth point but the graph does, uses the last
  // point in the y axis.  If the y axis has no data, or if the entire
  // graph does not have an nth point, throws an
  // IndexOutOfBoundsException.
  private BigDecimal getYValue(int n) {
    if (n >= this.getNumberOfPoints()) throw new IndexOutOfBoundsException();

    BigDecimal[] data = yAxis.getData();

    if (n < data.length) return data[n];
    else return data[data.length - 1];
  }