Beispiel #1
0
  /*
   * (non-Javadoc)
   *
   * @see glowaxes.plots.IPlotter#render()
   */
  public Element render() {

    Data data = getData();

    logger.info("Generating chart from " + this.getClass().getCanonicalName());

    if (data.getParentArea().getYAxis().getType() != "date"
        && data.getParentArea().getYAxis().getType() != "category"
        && data.getParentArea().getYAxis().getType() != "number") {
      throw new RuntimeException("Chart must have a date, category or number axis!");
    }

    Element area = new Element("g");
    area.setAttribute("desc", "data");
    Group plotSet = data.getGroup();

    // debug code
    // logger.error("max of x: " + data.getGroup().getXMaxSeriesList());
    // logger.error("min of x: " + data.getGroup().getXMinSeriesList());
    // logger.error("max of y: " + data.getGroup().getYMaxSeriesList());
    // logger.error("min of y: " + data.getGroup().getYMinSeriesList());

    for (int i = 0; i < plotSet.getSize(); i++) {

      Series mySeries = plotSet.getSeries(i);

      for (int j = 0; j < mySeries.getSize(); j++) {

        Value myValue = plotSet.getSeries(i).getValue(j);

        // add the polygon (the bar)
        area.addContent(drawValue(myValue));
      } // for mySeries
    } // for plotSet

    return area;
  }
Beispiel #2
0
  /*
   * (non-Javadoc)
   *
   * @see glowaxes.plots.IPlotter#drawValue(glowaxes.data.Value)
   */
  public Element drawValue(Value value) {

    double x;
    double y;
    Data data = getData();

    // get svg x point
    x = data.getParentArea().getXAxis().getSVGOffset(value);

    // get svg y point
    y = data.getParentArea().getYAxis().getSVGOffset(value);

    // get svn 0 point
    Value v = new Value();
    v.setY(0);
    double y0 = data.getParentArea().getYAxis().getSVGOffset(v);

    // get ready to process element polygon
    Element polygon = new Element("polygon");
    polygon.setAttribute("desc", "column");
    if (data.getEffect() != null) {
      polygon.setAttribute("filter", "url(#" + data.getEffect() + ")");
    }

    double yd = y;
    // negative numbers are taken into account
    double yOffset =
        data.getParentArea().getGlyphHeight() - (data.getParentArea().getGlyphHeight() - y0);

    double x0 = x + getWidth() / 2;
    double x1 = x - getWidth() / 2;

    if (x1 < 0) x1 = 0;

    double length = data.getParentArea().getXAxis().getLength();
    if (x0 > length) x0 = length;

    // if value has a style: use it, otherwise use the default
    if (value.getShapeStyle() != null) polygon.setAttribute("style", value.getShapeStyle());

    polygon.setAttribute(
        "points",
        x0 + "," + yOffset + " " + x0 + "," + yd + " " + x1 + "," + yd + " " + x1 + "," + yOffset);

    double xMap = data.getParentArea().getXOffsetChart();
    double yMap = data.getParentArea().getYOffsetChart();
    x0 += xMap;
    yOffset += yMap;
    yd += yMap;
    x1 += xMap;

    if (data.getLabels().getPopup().equalsIgnoreCase("true")) {
      data.getParentArea()
          .getParentChart()
          .setAreaMap(
              "polygon",
              "" + x0 + "," + yOffset + ", " + x0 + "," + yd + ", " + x1 + "," + yd + ", " + x1
                  + "," + yOffset,
              value.getLabelEvents(),
              replaceLabel(
                  (value.getLabel() != null) ? value.getLabel().getText().toString() : "", value),
              value.getLabelHref());
    } else if (data.getLabels().getPopup().equalsIgnoreCase("html")
        && data.getLabels().getText() != null) {

      String xml = replaceLabel(data.getLabels().getText(), value);

      data.getParentArea()
          .getParentChart()
          .setAreaMap(
              "polygon",
              "" + x0 + "," + yOffset + ", " + x0 + "," + yd + ", " + x1 + "," + yd + ", " + x1
                  + "," + yOffset,
              null,
              xml,
              value.getLabelHref());
    }
    return polygon;
  }