예제 #1
0
  @Override
  public RectF getBarBounds(BarEntry e) {

    BarDataSet set = mData.getDataSetForEntry(e);

    if (set == null) return null;

    float barspace = set.getBarSpace();
    float y = e.getVal();
    float x = e.getXIndex();

    float spaceHalf = barspace / 2f;

    float top = x - 0.5f + spaceHalf;
    float bottom = x + 0.5f - spaceHalf;
    float left = y >= 0 ? y : 0;
    float right = y <= 0 ? y : 0;

    RectF bounds = new RectF(left, top, right, bottom);

    getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

    return bounds;
  }
예제 #2
0
  /**
   * Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the
   * Entry could not be found in the charts data.
   *
   * @param e
   * @return
   */
  public RectF getBarBounds(final BarEntry e) {

    final BarDataSet set = this.mData.getDataSetForEntry(e);

    if (set == null) return null;

    final float barspace = set.getBarSpace();
    final float y = e.getVal();
    final float x = e.getXIndex();

    final float barWidth = 0.5f;

    final float spaceHalf = barspace / 2f;
    final float left = x - barWidth + spaceHalf;
    final float right = x + barWidth - spaceHalf;
    final float top = y >= 0 ? y : 0;
    final float bottom = y <= 0 ? y : 0;

    final RectF bounds = new RectF(left, top, right, bottom);

    this.getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

    return bounds;
  }