Beispiel #1
0
  public void computeAxis(float xValAverageLength, List<String> xValues) {

    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());

    StringBuffer a = new StringBuffer();

    int max = (int) Math.round(xValAverageLength + mXAxis.getSpaceBetweenLabels());

    for (int i = 0; i < max; i++) {
      a.append("h");
    }

    mXAxis.mLabelWidth = Utils.calcTextWidth(mAxisLabelPaint, a.toString());
    mXAxis.mLabelHeight = Utils.calcTextHeight(mAxisLabelPaint, "Q");
    mXAxis.setValues(xValues);
  }
Beispiel #2
0
  @Override
  public void renderAxisLabels(Canvas c) {

    if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) return;

    float yoffset = Utils.convertDpToPixel(4f);

    mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
    mAxisLabelPaint.setColor(mXAxis.getTextColor());

    if (mXAxis.getPosition() == XAxisPosition.TOP) {

      drawLabels(c, mViewPortHandler.offsetTop() - yoffset);

    } else if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

      drawLabels(
          c,
          mViewPortHandler.contentBottom() * topchartScale
              + (mViewPortHandler.contentBottom() * 0.04f)
              + mXAxis.mLabelHeight / 2);

    } else if (mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE) {

      drawLabels(c, mViewPortHandler.contentBottom() - yoffset);

    } else if (mXAxis.getPosition() == XAxisPosition.TOP_INSIDE) {

      drawLabels(c, mViewPortHandler.offsetTop() + yoffset + mXAxis.mLabelHeight);

    } else { // BOTH SIDED

      drawLabels(c, mViewPortHandler.offsetTop() - yoffset);
      drawLabels(c, mViewPortHandler.contentBottom() + mXAxis.mLabelHeight + yoffset * 1.6f);
    }
  }