Exemplo n.º 1
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.º 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
  public String getXYChartCode() {
    xyChartCode = getDataCode();
    xyChartCode += (xAxis.getDateLen() > -1) ? getXTimeScale() : getXLinearScale();
    xyChartCode += getYArea();
    xyChartCode += getSvgRegion();

    xyChartCode += getDomainCode();
    xyChartCode += getAxisCode();
    xyChartCode += getTitleCode();
    xyChartCode +=
        "svg.append(\"g\")"
            + ".attr(\"class\",\"x axis\")"
            + textStyle.getStyles()
            + ".attr(\"transform\", \"translate(0,"
            + getHeight()
            + ")\")"
            + ".call(xAxis);\n";
    xyChartCode +=
        "svg.append(\"text\").attr(\"x\","
            + (getTotalWidth() / 2)
            + ").attr(\"y\","
            + (getHeight() + getBottomMargin())
            + ")"
            + textStyle.getStyles()
            + ".attr(\"text-anchor\", \"middle\").text(\""
            + xAxis.getTitle()
            + "\");\n";
    xyChartCode +=
        "svg.append(\"g\")"
            + ".attr(\"class\", \"y axis\")"
            + textStyle.getStyles()
            + ".call(yAxis);\n";
    xyChartCode +=
        "svg.append(\"text\").attr(\"y\","
            + (0 - getLeftMargin())
            + ").attr(\"dy\", \"1em\").attr(\"transform\",\"rotate(-90)\")"
            + textStyle.getStyles()
            + ".attr(\"x\","
            + (0 - getHeight() / 2)
            + ").attr(\"text-anchor\", \"middle\").text(\""
            + yAxis.getTitle()
            + "\");\n";
    xyChartCode += lineStyle.getStyleCode();
    return xyChartCode;
  }