nus-yam/ex-repair huggingface dataset:
Program: 18348
Project: 18348
Buggy source:
@Override protected float[] getMarkerPosition(Entry e,Highlight highlight){
  int dataSetIndex=highlight.getDataSetIndex();
  float xPos=e.getXIndex();
  float yPos=e.getVal();
  if (this instanceof BarChart) {
    BarData bd=(BarData)mData;
    float space=bd.getGroupSpace();
    int setCount=mData.getDataSetCount();
    int i=e.getXIndex();
    if (this instanceof HorizontalBarChart) {
      float y=i + i * (setCount - 1) + dataSetIndex + space * i + space / 2f;
      yPos=y;
      BarEntry entry=(BarEntry)e;
      if (entry.getVals() != null) {
        xPos=highlight.getRange().to;
      }
 else {
        xPos=e.getVal();
      }
    }
 else {
      float x=i + i * (setCount - 1) + dataSetIndex + space * i + space / 2f;
      xPos=x;
      BarEntry entry=(BarEntry)e;
      if (entry.getVals() != null) {
        yPos=highlight.getRange().to;
      }
 else {
        yPos=e.getVal();
      }
    }
  }
  float[] pts=new float[]{xPos,yPos * mAnimator.getPhaseY()};
  getTransformer(mData.getDataSetByIndex(dataSetIndex).getAxisDependency()).pointValuesToPixel(pts);
  return pts;
}

Fixed version (ground truth):
@Override protected float[] getMarkerPosition(Entry e,Highlight highlight){
  int dataSetIndex=highlight.getDataSetIndex();
  float xPos=e.getXIndex();
  float yPos=e.getVal();
  if (this instanceof BarChart) {
    BarData bd=(BarData)mData;
    float space=bd.getGroupSpace();
    int setCount=mData.getDataSetCount();
    int i=e.getXIndex();
    if (this instanceof HorizontalBarChart) {
      float y=i + i * (setCount - 1) + dataSetIndex + space * i + space / 2f;
      yPos=y;
      BarEntry entry=(BarEntry)e;
      if (entry.getVals() != null) {
        xPos=highlight.getRange().to;
      }
 else {
        xPos=e.getVal();
      }
      xPos*=mAnimator.getPhaseY();
    }
 else {
      float x=i + i * (setCount - 1) + dataSetIndex + space * i + space / 2f;
      xPos=x;
      BarEntry entry=(BarEntry)e;
      if (entry.getVals() != null) {
        yPos=highlight.getRange().to;
      }
 else {
        yPos=e.getVal();
      }
      yPos*=mAnimator.getPhaseY();
    }
  }
 else {
    yPos*=mAnimator.getPhaseY();
  }
  float[] pts=new float[]{xPos,yPos};
  getTransformer(mData.getDataSetByIndex(dataSetIndex).getAxisDependency()).pointValuesToPixel(pts);
  return pts;
}
Program: 18349
Project: 18349
Buggy source:
@Override protected void calcMinMax(){
  super.calcMinMax();
  if (getBarData() != null || getCandleData() != null || getBubbleData() != null) {
    mXChartMin=-0.5f;
    mXChartMax=mData.getXVals().size() - 0.5f;
    if (getBubbleData() != null) {
      for (      BubbleDataSet set : getBubbleData().getDataSets()) {
        final float xmin=set.getXMin();
        final float xmax=set.getXMax();
        if (xmin < mXChartMin)         mXChartMin=xmin;
        if (xmax > mXChartMax)         mXChartMax=xmax;
      }
    }
  }
 else {
    mXChartMin=0f;
    mXChartMax=mData.getXValCount() - 1;
  }
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
}

Fixed version (ground truth):
@Override protected void calcMinMax(){
  super.calcMinMax();
  if (getBarData() != null || getCandleData() != null || getBubbleData() != null) {
    mXChartMin=-0.5f;
    mXChartMax=mData.getXVals().size() - 0.5f;
    if (getBubbleData() != null) {
      for (      BubbleDataSet set : getBubbleData().getDataSets()) {
        final float xmin=set.getXMin();
        final float xmax=set.getXMax();
        if (xmin < mXChartMin)         mXChartMin=xmin;
        if (xmax > mXChartMax)         mXChartMax=xmax;
      }
    }
  }
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
}
Program: 18350
Project: 18350
Buggy source:
@Override public void calculateOffsets(){
  super.calculateOffsets();
  if (mDataNotSet)   return;
  float diameter=getDiameter();
  float boxSize=diameter / 2f;
  PointF c=getCenterOffsets();
  mCircleBox.set(c.x - boxSize,c.y - boxSize,c.x + boxSize,c.y + boxSize);
}

Fixed version (ground truth):
@Override public void calculateOffsets(){
  super.calculateOffsets();
  if (mDataNotSet)   return;
  float diameter=getDiameter();
  float radius=diameter / 2f;
  PointF c=getCenterOffsets();
  final List<PieDataSet> dataSets=mData.getDataSets();
  float maxShift=0.f;
  for (int i=0; i < dataSets.size(); i++) {
    final float shift=dataSets.get(i).getSelectionShift();
    if (shift > maxShift)     maxShift=shift;
  }
  final float halfMaxShift=maxShift / 2.f;
  mCircleBox.set(c.x - radius + halfMaxShift,c.y - radius + halfMaxShift,c.x + radius - halfMaxShift,c.y + radius - halfMaxShift);
}
Program: 18351
Project: 18351
Buggy source:
@Override protected void calcMinMax(int start,int end){
  if (mYVals.size() == 0)   return;
  List<CandleEntry> entries=mYVals;
  int endValue;
  if (end == 0)   endValue=mYVals.size() - 1;
 else   endValue=end;
  mLastStart=start;
  mLastEnd=endValue;
  mYMin=mYVals.get(start).getLow();
  mYMax=mYVals.get(start).getHigh();
  for (int i=start + 1; i <= endValue; i++) {
    CandleEntry e=entries.get(i);
    if (e.getLow() < mYMin)     mYMin=e.getLow();
    if (e.getHigh() > mYMax)     mYMax=e.getHigh();
  }
}

Fixed version (ground truth):
@Override protected void calcMinMax(int start,int end){
  if (mYVals.size() == 0)   return;
  List<CandleEntry> entries=mYVals;
  int endValue;
  if (end == 0 || end >= mYVals.size())   endValue=mYVals.size() - 1;
 else   endValue=end;
  mLastStart=start;
  mLastEnd=endValue;
  mYMin=mYVals.get(start).getLow();
  mYMax=mYVals.get(start).getHigh();
  for (int i=start + 1; i <= endValue; i++) {
    CandleEntry e=entries.get(i);
    if (e.getLow() < mYMin)     mYMin=e.getLow();
    if (e.getHigh() > mYMax)     mYMax=e.getHigh();
  }
}
Program: 18352
Project: 18352
Buggy source:
@Override public void drawData(Canvas c){
  BarData barData=mChart.getBarData();
  for (int i=0; i < barData.getDataSetCount(); i++) {
    BarDataSet set=barData.getDataSetByIndex(i);
    if (set.isVisible()) {
      drawDataSet(c,set,i);
    }
  }
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  BarData barData=mChart.getBarData();
  for (int i=0; i < barData.getDataSetCount(); i++) {
    BarDataSet set=barData.getDataSetByIndex(i);
    if (set.isVisible() && set.getEntryCount() > 0) {
      drawDataSet(c,set,i);
    }
  }
}
Program: 18354
Project: 18354
Buggy source:
@Override public void drawData(Canvas c){
  BubbleData bubbleData=mChart.getBubbleData();
  for (  BubbleDataSet set : bubbleData.getDataSets()) {
    if (set.isVisible())     drawDataSet(c,set);
  }
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  BubbleData bubbleData=mChart.getBubbleData();
  for (  BubbleDataSet set : bubbleData.getDataSets()) {
    if (set.isVisible() && set.getEntryCount() > 0)     drawDataSet(c,set);
  }
}
Program: 18356
Project: 18356
Buggy source:
@Override public void drawData(Canvas c){
  CandleData candleData=mChart.getCandleData();
  for (  CandleDataSet set : candleData.getDataSets()) {
    if (set.isVisible())     drawDataSet(c,set);
  }
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  CandleData candleData=mChart.getCandleData();
  for (  CandleDataSet set : candleData.getDataSets()) {
    if (set.isVisible() && set.getEntryCount() > 0)     drawDataSet(c,set);
  }
}
Program: 18358
Project: 18358
Buggy source:
@Override public void drawValues(Canvas c){
  if (mChart.getCandleData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<CandleDataSet> dataSets=mChart.getCandleData().getDataSets();
    for (int i=0; i < dataSets.size(); i++) {
      CandleDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled())       continue;
      applyValueTextStyle(dataSet);
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      List<CandleEntry> entries=dataSet.getYVals();
      Entry entryFrom=dataSet.getEntryForXIndex(mMinX);
      Entry entryTo=dataSet.getEntryForXIndex(mMaxX);
      int minx=Math.max(dataSet.getEntryPosition(entryFrom),0);
      int maxx=Math.min(dataSet.getEntryPosition(entryTo) + 1,entries.size());
      float[] positions=trans.generateTransformedValuesCandle(entries,mAnimator.getPhaseX(),mAnimator.getPhaseY(),minx,maxx);
      float yOffset=Utils.convertDpToPixel(5f);
      for (int j=0; j < positions.length; j+=2) {
        float x=positions[j];
        float y=positions[j + 1];
        if (!mViewPortHandler.isInBoundsRight(x))         break;
        if (!mViewPortHandler.isInBoundsLeft(x) || !mViewPortHandler.isInBoundsY(y))         continue;
        float val=entries.get(j / 2 + minx).getHigh();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),x,y - yOffset,mValuePaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  if (mChart.getCandleData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<CandleDataSet> dataSets=mChart.getCandleData().getDataSets();
    for (int i=0; i < dataSets.size(); i++) {
      CandleDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      applyValueTextStyle(dataSet);
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      List<CandleEntry> entries=dataSet.getYVals();
      int minx=Math.max(mMinX,0);
      int maxx=Math.min(mMaxX + 1,entries.size());
      float[] positions=trans.generateTransformedValuesCandle(entries,mAnimator.getPhaseX(),mAnimator.getPhaseY(),minx,maxx);
      float yOffset=Utils.convertDpToPixel(5f);
      for (int j=0; j < positions.length; j+=2) {
        float x=positions[j];
        float y=positions[j + 1];
        if (!mViewPortHandler.isInBoundsRight(x))         break;
        if (!mViewPortHandler.isInBoundsLeft(x) || !mViewPortHandler.isInBoundsY(y))         continue;
        float val=entries.get(j / 2 + minx).getHigh();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),x,y - yOffset,mValuePaint);
      }
    }
  }
}
Program: 18360
Project: 18360
Buggy source:
@Override public void drawData(Canvas c){
  int width=(int)mViewPortHandler.getChartWidth();
  int height=(int)mViewPortHandler.getChartHeight();
  if (mDrawBitmap == null || (mDrawBitmap.getWidth() != width) || (mDrawBitmap.getHeight() != height)) {
    if (width > 0 && height > 0) {
      mDrawBitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_4444);
      mBitmapCanvas=new Canvas(mDrawBitmap);
    }
 else     return;
  }
  mDrawBitmap.eraseColor(Color.TRANSPARENT);
  LineData lineData=mChart.getLineData();
  for (  LineDataSet set : lineData.getDataSets()) {
    if (set.isVisible())     drawDataSet(c,set);
  }
  c.drawBitmap(mDrawBitmap,0,0,mRenderPaint);
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  int width=(int)mViewPortHandler.getChartWidth();
  int height=(int)mViewPortHandler.getChartHeight();
  if (mDrawBitmap == null || (mDrawBitmap.getWidth() != width) || (mDrawBitmap.getHeight() != height)) {
    if (width > 0 && height > 0) {
      mDrawBitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_4444);
      mBitmapCanvas=new Canvas(mDrawBitmap);
    }
 else     return;
  }
  mDrawBitmap.eraseColor(Color.TRANSPARENT);
  LineData lineData=mChart.getLineData();
  for (  LineDataSet set : lineData.getDataSets()) {
    if (set.isVisible() && set.getEntryCount() > 0)     drawDataSet(c,set);
  }
  c.drawBitmap(mDrawBitmap,0,0,mRenderPaint);
}
Program: 18361
Project: 18361
Buggy source:
@Override public void drawValues(Canvas c){
  if (mChart.getLineData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<LineDataSet> dataSets=mChart.getLineData().getDataSets();
    for (int i=0; i < dataSets.size(); i++) {
      LineDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled())       continue;
      applyValueTextStyle(dataSet);
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      int valOffset=(int)(dataSet.getCircleSize() * 1.75f);
      if (!dataSet.isDrawCirclesEnabled())       valOffset=valOffset / 2;
      List<Entry> entries=dataSet.getYVals();
      Entry entryFrom=dataSet.getEntryForXIndex(mMinX);
      Entry entryTo=dataSet.getEntryForXIndex(mMaxX);
      int minx=Math.max(dataSet.getEntryPosition(entryFrom),0);
      int maxx=Math.min(dataSet.getEntryPosition(entryTo) + 1,entries.size());
      float[] positions=trans.generateTransformedValuesLine(entries,mAnimator.getPhaseX(),mAnimator.getPhaseY(),minx,maxx);
      for (int j=0; j < positions.length; j+=2) {
        float x=positions[j];
        float y=positions[j + 1];
        if (!mViewPortHandler.isInBoundsRight(x))         break;
        if (!mViewPortHandler.isInBoundsLeft(x) || !mViewPortHandler.isInBoundsY(y))         continue;
        float val=entries.get(j / 2 + minx).getVal();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),x,y - valOffset,mValuePaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  if (mChart.getLineData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<LineDataSet> dataSets=mChart.getLineData().getDataSets();
    for (int i=0; i < dataSets.size(); i++) {
      LineDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      applyValueTextStyle(dataSet);
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      int valOffset=(int)(dataSet.getCircleSize() * 1.75f);
      if (!dataSet.isDrawCirclesEnabled())       valOffset=valOffset / 2;
      List<Entry> entries=dataSet.getYVals();
      Entry entryFrom=dataSet.getEntryForXIndex(mMinX);
      Entry entryTo=dataSet.getEntryForXIndex(mMaxX);
      int minx=Math.max(dataSet.getEntryPosition(entryFrom),0);
      int maxx=Math.min(dataSet.getEntryPosition(entryTo) + 1,entries.size());
      float[] positions=trans.generateTransformedValuesLine(entries,mAnimator.getPhaseX(),mAnimator.getPhaseY(),minx,maxx);
      for (int j=0; j < positions.length; j+=2) {
        float x=positions[j];
        float y=positions[j + 1];
        if (!mViewPortHandler.isInBoundsRight(x))         break;
        if (!mViewPortHandler.isInBoundsLeft(x) || !mViewPortHandler.isInBoundsY(y))         continue;
        float val=entries.get(j / 2 + minx).getVal();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),x,y - valOffset,mValuePaint);
      }
    }
  }
}
Program: 18362
Project: 18362
Buggy source:
@Override public void drawData(Canvas c){
  int width=(int)mViewPortHandler.getChartWidth();
  int height=(int)mViewPortHandler.getChartHeight();
  if (mDrawBitmap == null || (mDrawBitmap.getWidth() != width) || (mDrawBitmap.getHeight() != height)) {
    if (width > 0 && height > 0) {
      mDrawBitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_4444);
      mBitmapCanvas=new Canvas(mDrawBitmap);
    }
 else     return;
  }
  mDrawBitmap.eraseColor(Color.TRANSPARENT);
  PieData pieData=mChart.getData();
  for (  PieDataSet set : pieData.getDataSets()) {
    if (set.isVisible())     drawDataSet(c,set);
  }
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  int width=(int)mViewPortHandler.getChartWidth();
  int height=(int)mViewPortHandler.getChartHeight();
  if (mDrawBitmap == null || (mDrawBitmap.getWidth() != width) || (mDrawBitmap.getHeight() != height)) {
    if (width > 0 && height > 0) {
      mDrawBitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_4444);
      mBitmapCanvas=new Canvas(mDrawBitmap);
    }
 else     return;
  }
  mDrawBitmap.eraseColor(Color.TRANSPARENT);
  PieData pieData=mChart.getData();
  for (  PieDataSet set : pieData.getDataSets()) {
    if (set.isVisible() && set.getEntryCount() > 0)     drawDataSet(c,set);
  }
}
Program: 18363
Project: 18363
Buggy source:
@Override public void drawData(Canvas c){
  RadarData radarData=mChart.getData();
  for (  RadarDataSet set : radarData.getDataSets()) {
    if (set.isVisible())     drawDataSet(c,set);
  }
}

Fixed version (ground truth):
@Override public void drawData(Canvas c){
  RadarData radarData=mChart.getData();
  for (  RadarDataSet set : radarData.getDataSets()) {
    if (set.isVisible() && set.getEntryCount() > 0)     drawDataSet(c,set);
  }
}
Program: 18364
Project: 18364
Buggy source:
@Override public void drawValues(Canvas c){
  float sliceangle=mChart.getSliceAngle();
  float factor=mChart.getFactor();
  PointF center=mChart.getCenterOffsets();
  float yoffset=Utils.convertDpToPixel(5f);
  for (int i=0; i < mChart.getData().getDataSetCount(); i++) {
    RadarDataSet dataSet=mChart.getData().getDataSetByIndex(i);
    if (!dataSet.isDrawValuesEnabled())     continue;
    applyValueTextStyle(dataSet);
    List<Entry> entries=dataSet.getYVals();
    for (int j=0; j < entries.size(); j++) {
      Entry e=entries.get(j);
      PointF p=Utils.getPosition(center,(e.getVal() - mChart.getYChartMin()) * factor,sliceangle * j + mChart.getRotationAngle());
      c.drawText(dataSet.getValueFormatter().getFormattedValue(e.getVal()),p.x,p.y - yoffset,mValuePaint);
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  float sliceangle=mChart.getSliceAngle();
  float factor=mChart.getFactor();
  PointF center=mChart.getCenterOffsets();
  float yoffset=Utils.convertDpToPixel(5f);
  for (int i=0; i < mChart.getData().getDataSetCount(); i++) {
    RadarDataSet dataSet=mChart.getData().getDataSetByIndex(i);
    if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)     continue;
    applyValueTextStyle(dataSet);
    List<Entry> entries=dataSet.getYVals();
    for (int j=0; j < entries.size(); j++) {
      Entry e=entries.get(j);
      PointF p=Utils.getPosition(center,(e.getVal() - mChart.getYChartMin()) * factor,sliceangle * j + mChart.getRotationAngle());
      c.drawText(dataSet.getValueFormatter().getFormattedValue(e.getVal()),p.x,p.y - yoffset,mValuePaint);
    }
  }
}
Program: 18365
Project: 18365
Buggy source:
@Override public void drawValues(Canvas c){
  if (mChart.getScatterData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<ScatterDataSet> dataSets=mChart.getScatterData().getDataSets();
    for (int i=0; i < mChart.getScatterData().getDataSetCount(); i++) {
      ScatterDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled())       continue;
      applyValueTextStyle(dataSet);
      List<Entry> entries=dataSet.getYVals();
      float[] positions=mChart.getTransformer(dataSet.getAxisDependency()).generateTransformedValuesScatter(entries,mAnimator.getPhaseY());
      float shapeSize=dataSet.getScatterShapeSize();
      for (int j=0; j < positions.length * mAnimator.getPhaseX(); j+=2) {
        if (!mViewPortHandler.isInBoundsRight(positions[j]))         break;
        if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1])))         continue;
        float val=entries.get(j / 2).getVal();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),positions[j],positions[j + 1] - shapeSize,mValuePaint);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  if (mChart.getScatterData().getYValCount() < mChart.getMaxVisibleCount() * mViewPortHandler.getScaleX()) {
    List<ScatterDataSet> dataSets=mChart.getScatterData().getDataSets();
    for (int i=0; i < mChart.getScatterData().getDataSetCount(); i++) {
      ScatterDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      applyValueTextStyle(dataSet);
      List<Entry> entries=dataSet.getYVals();
      float[] positions=mChart.getTransformer(dataSet.getAxisDependency()).generateTransformedValuesScatter(entries,mAnimator.getPhaseY());
      float shapeSize=dataSet.getScatterShapeSize();
      for (int j=0; j < positions.length * mAnimator.getPhaseX(); j+=2) {
        if (!mViewPortHandler.isInBoundsRight(positions[j]))         break;
        if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1])))         continue;
        float val=entries.get(j / 2).getVal();
        c.drawText(dataSet.getValueFormatter().getFormattedValue(val),positions[j],positions[j + 1] - shapeSize,mValuePaint);
      }
    }
  }
}
Program: 18368
Project: 18368
Buggy source:
@Override protected float getRequiredBaseOffset(){
  return mXAxis.isEnabled() ? mXAxis.mLabelWidth : Utils.convertDpToPixel(10f);
}

Fixed version (ground truth):
@Override protected float getRequiredBaseOffset(){
  return mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled() ? mXAxis.mLabelWidth : Utils.convertDpToPixel(10f);
}
Program: 18369
Project: 18369
Buggy source:
@Override protected void calcMinMax(){
  super.calcMinMax();
  float minLeft=mData.getYMin(AxisDependency.LEFT);
  float maxLeft=mData.getYMax(AxisDependency.LEFT);
  mXChartMax=mData.getXVals().size() - 1;
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
  float leftRange=Math.abs(maxLeft - (mYAxis.isStartAtZeroEnabled() ? 0 : minLeft));
  float topSpaceLeft=leftRange / 100f * mYAxis.getSpaceTop();
  float bottomSpaceLeft=leftRange / 100f * mYAxis.getSpaceBottom();
  mXChartMax=mData.getXVals().size() - 1;
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
  mYAxis.mAxisMaximum=!Float.isNaN(mYAxis.getAxisMaxValue()) ? mYAxis.getAxisMaxValue() : maxLeft + topSpaceLeft;
  mYAxis.mAxisMinimum=!Float.isNaN(mYAxis.getAxisMinValue()) ? mYAxis.getAxisMinValue() : minLeft - bottomSpaceLeft;
  if (mYAxis.isStartAtZeroEnabled())   mYAxis.mAxisMinimum=Math.min(0f,mYAxis.mAxisMinimum);
  mYAxis.mAxisRange=Math.abs(mYAxis.mAxisMaximum - mYAxis.mAxisMinimum);
}

Fixed version (ground truth):
@Override protected void calcMinMax(){
  super.calcMinMax();
  float minLeft=mData.getYMin(AxisDependency.LEFT);
  float maxLeft=mData.getYMax(AxisDependency.LEFT);
  mXChartMax=mData.getXVals().size() - 1;
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
  float leftRange=Math.abs(maxLeft - (mYAxis.isStartAtZeroEnabled() ? 0 : minLeft));
  float topSpaceLeft=leftRange / 100f * mYAxis.getSpaceTop();
  float bottomSpaceLeft=leftRange / 100f * mYAxis.getSpaceBottom();
  mXChartMax=mData.getXVals().size() - 1;
  mDeltaX=Math.abs(mXChartMax - mXChartMin);
  if (mYAxis.isStartAtZeroEnabled()) {
    if (minLeft < 0.f && maxLeft < 0.f) {
      mYAxis.mAxisMinimum=Math.min(0.f,!Float.isNaN(mYAxis.getAxisMinValue()) ? mYAxis.getAxisMinValue() : (minLeft - bottomSpaceLeft));
      mYAxis.mAxisMaximum=0.f;
    }
 else     if (minLeft >= 0.0) {
      mYAxis.mAxisMinimum=0.f;
      mYAxis.mAxisMaximum=Math.max(0.f,!Float.isNaN(mYAxis.getAxisMaxValue()) ? mYAxis.getAxisMaxValue() : (maxLeft + topSpaceLeft));
    }
 else {
      mYAxis.mAxisMinimum=Math.min(0.f,!Float.isNaN(mYAxis.getAxisMinValue()) ? mYAxis.getAxisMinValue() : (minLeft - bottomSpaceLeft));
      mYAxis.mAxisMaximum=Math.max(0.f,!Float.isNaN(mYAxis.getAxisMaxValue()) ? mYAxis.getAxisMaxValue() : (maxLeft + topSpaceLeft));
    }
  }
 else {
    mYAxis.mAxisMinimum=!Float.isNaN(mYAxis.getAxisMinValue()) ? mYAxis.getAxisMinValue() : (minLeft - bottomSpaceLeft);
    mYAxis.mAxisMaximum=!Float.isNaN(mYAxis.getAxisMaxValue()) ? mYAxis.getAxisMaxValue() : (maxLeft + topSpaceLeft);
  }
  mYAxis.mAxisRange=Math.abs(mYAxis.mAxisMaximum - mYAxis.mAxisMinimum);
}
Program: 18370
Project: 18370
Buggy source:
private void setData(int count,float range){
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < count; i++) {
    xVals.add(mMonths[i % 12]);
  }
  ArrayList<BarEntry> yVals1=new ArrayList<BarEntry>();
  for (int i=0; i < count; i++) {
    float mult=(range + 1);
    float val=(float)(Math.random() * mult);
    yVals1.add(new BarEntry(val,i));
  }
  BarDataSet set1=new BarDataSet(yVals1,"String_Node_Str");
  set1.setBarSpacePercent(35f);
  ArrayList<BarDataSet> dataSets=new ArrayList<BarDataSet>();
  dataSets.add(set1);
  BarData data=new BarData(xVals,dataSets);
  data.setValueTextSize(10f);
  data.setValueTypeface(tf);
  mChart.setDrawValueAboveBar(false);
  mChart.setData(data);
}

Fixed version (ground truth):
private void setData(int count,float range){
  ArrayList<BarEntry> yVals1=new ArrayList<BarEntry>();
  ArrayList<String> xVals=new ArrayList<String>();
  for (int i=0; i < count; i++) {
    xVals.add(mMonths[i % 12]);
    yVals1.add(new BarEntry((float)(Math.random() * range),i));
  }
  BarDataSet set1=new BarDataSet(yVals1,"String_Node_Str");
  ArrayList<BarDataSet> dataSets=new ArrayList<BarDataSet>();
  dataSets.add(set1);
  BarData data=new BarData(xVals,dataSets);
  data.setValueTextSize(10f);
  data.setValueTypeface(tf);
  mChart.setData(data);
}
Program: 18373
Project: 18373
Buggy source:
/** 
 * Transforms an List of Entry into a float array containing the x and y values transformed with all matrices for the BARCHART.
 * @param entries
 * @param dataSet the dataset index
 * @return
 */
public float[] generateTransformedValuesBarChart(List<? extends Entry> entries,int dataSet,BarData bd,float phaseY){
  float[] valuePoints=new float[entries.size() * 2];
  int setCount=bd.getDataSetCount();
  float space=bd.getGroupSpace();
  for (int j=0; j < valuePoints.length; j+=2) {
    Entry e=entries.get(j / 2);
    float x=e.getXIndex() + (j / 2 * (setCount - 1)) + dataSet+ space * (j / 2) + space / 2f;
    float y=e.getVal();
    valuePoints[j]=x;
    valuePoints[j + 1]=y * phaseY;
  }
  getValueToPixelMatrix().mapPoints(valuePoints);
  return valuePoints;
}

Fixed version (ground truth):
/** 
 * Transforms an List of Entry into a float array containing the x and y values transformed with all matrices for the BARCHART.
 * @param entries
 * @param dataSet the dataset index
 * @return
 */
public float[] generateTransformedValuesBarChart(List<? extends Entry> entries,int dataSet,BarData bd,float phaseY){
  float[] valuePoints=new float[entries.size() * 2];
  int setCount=bd.getDataSetCount();
  float space=bd.getGroupSpace();
  for (int j=0; j < valuePoints.length; j+=2) {
    Entry e=entries.get(j / 2);
    int i=e.getXIndex();
    float x=e.getXIndex() + i * (setCount - 1) + dataSet + space * i + space / 2f;
    float y=e.getVal();
    valuePoints[j]=x;
    valuePoints[j + 1]=y * phaseY;
  }
  getValueToPixelMatrix().mapPoints(valuePoints);
  return valuePoints;
}
Program: 18374
Project: 18374
Buggy source:
/** 
 * Transforms an List of Entry into a float array containing the x and y values transformed with all matrices for the BARCHART.
 * @param entries
 * @param dataSet the dataset index
 * @return
 */
public float[] generateTransformedValuesHorizontalBarChart(List<? extends Entry> entries,int dataSet,BarData bd,float phaseY){
  float[] valuePoints=new float[entries.size() * 2];
  int setCount=bd.getDataSetCount();
  float space=bd.getGroupSpace();
  for (int j=0; j < valuePoints.length; j+=2) {
    Entry e=entries.get(j / 2);
    float x=e.getXIndex() + (j / 2 * (setCount - 1)) + dataSet+ space * (j / 2) + space / 2f;
    float y=e.getVal();
    valuePoints[j]=y * phaseY;
    valuePoints[j + 1]=x;
  }
  getValueToPixelMatrix().mapPoints(valuePoints);
  return valuePoints;
}

Fixed version (ground truth):
/** 
 * Transforms an List of Entry into a float array containing the x and y values transformed with all matrices for the BARCHART.
 * @param entries
 * @param dataSet the dataset index
 * @return
 */
public float[] generateTransformedValuesHorizontalBarChart(List<? extends Entry> entries,int dataSet,BarData bd,float phaseY){
  float[] valuePoints=new float[entries.size() * 2];
  int setCount=bd.getDataSetCount();
  float space=bd.getGroupSpace();
  for (int j=0; j < valuePoints.length; j+=2) {
    Entry e=entries.get(j / 2);
    int i=e.getXIndex();
    float x=e.getXIndex() + i * (setCount - 1) + dataSet + space * i + space / 2f;
    float y=e.getVal();
    valuePoints[j]=y * phaseY;
    valuePoints[j + 1]=x;
  }
  getValueToPixelMatrix().mapPoints(valuePoints);
  return valuePoints;
}
Program: 18375
Project: 18375
Buggy source:
@Override public void onValueSelected(Entry e,int dataSetIndex,Highlight h){
  BarEntry entry=(BarEntry)e;
  if (entry.isStacked())   Log.i("String_Node_Str","String_Node_Str" + entry.getVals()[h.getStackIndex()]);
 else   Log.i("String_Node_Str","String_Node_Str" + entry.getVal());
}

Fixed version (ground truth):
@Override public void onValueSelected(Entry e,int dataSetIndex,Highlight h){
  BarEntry entry=(BarEntry)e;
  if (entry.getVals() != null)   Log.i("String_Node_Str","String_Node_Str" + entry.getVals()[h.getStackIndex()]);
 else   Log.i("String_Node_Str","String_Node_Str" + entry.getVal());
}
Program: 18378
Project: 18378
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleLineValues:
{
      for (      DataSet<?> set : mChart.getData().getDataSets()) {
        if (set instanceof LineDataSet)         set.setDrawValues(!set.isDrawValuesEnabled());
      }
      mChart.invalidate();
      break;
    }
case R.id.actionToggleBarValues:
{
    for (    DataSet<?> set : mChart.getData().getDataSets()) {
      if (set instanceof BarDataSet)       set.setDrawValues(!set.isDrawValuesEnabled());
    }
    mChart.invalidate();
    break;
  }
}
return true;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.actionToggleLineValues:
{
      for (      DataSet<?> set : mChart.getData().getDataSets()) {
        if (set instanceof LineDataSet)         set.setDrawValues(!set.isDrawValuesEnabled());
      }
      mChart.invalidate();
      break;
    }
case R.id.actionToggleBarValues:
{
    CombinedData data=new CombinedData(mMonths);
    data.setData(generateLineData());
    mChart.setData(data);
    mChart.invalidate();
    break;
  }
}
return true;
}
Program: 18383
Project: 18383
Buggy source:
/** 
 * calc minimum and maximum y value
 */
protected void calcMinMax(int start,int end){
  if (mYVals.size() == 0)   return;
  int endValue;
  if (end == 0)   endValue=mYVals.size() - 1;
 else   endValue=end;
  mLastStart=start;
  mLastEnd=endValue;
  mYMin=Float.MAX_VALUE;
  mYMax=-Float.MIN_VALUE;
  for (int i=start; i <= endValue; i++) {
    Entry e=mYVals.get(i);
    if (e != null && !Float.isNaN(e.getVal())) {
      if (e.getVal() < mYMin)       mYMin=e.getVal();
      if (e.getVal() > mYMax)       mYMax=e.getVal();
    }
  }
  if (mYMin == Float.MAX_VALUE) {
    mYMin=0.f;
    mYMax=0.f;
  }
}

Fixed version (ground truth):
/** 
 * calc minimum and maximum y value
 */
protected void calcMinMax(int start,int end){
  final int yValCount=mYVals.size();
  if (yValCount == 0)   return;
  int endValue;
  if (end == 0 || end >= yValCount)   endValue=yValCount - 1;
 else   endValue=end;
  mLastStart=start;
  mLastEnd=endValue;
  mYMin=Float.MAX_VALUE;
  mYMax=-Float.MAX_VALUE;
  for (int i=start; i <= endValue; i++) {
    Entry e=mYVals.get(i);
    if (e != null && !Float.isNaN(e.getVal())) {
      if (e.getVal() < mYMin)       mYMin=e.getVal();
      if (e.getVal() > mYMax)       mYMax=e.getVal();
    }
  }
  if (mYMin == Float.MAX_VALUE) {
    mYMin=0.f;
    mYMax=0.f;
  }
}
Program: 18386
Project: 18386
Buggy source:
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
protected List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  float[] pts=new float[2];
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet<?> dataSet=mData.getDataSetByIndex(i);
    if (!dataSet.isHighlightEnabled())     continue;
    float yVal=dataSet.getYValForXIndex(xIndex);
    pts[1]=yVal;
    getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts);
    if (!Float.isNaN(pts[1])) {
      vals.add(new SelectionDetail(pts[1],i,dataSet));
    }
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
protected List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  float[] pts=new float[2];
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet<?> dataSet=mData.getDataSetByIndex(i);
    if (!dataSet.isHighlightEnabled())     continue;
    final float yVal=dataSet.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    pts[1]=yVal;
    getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts);
    if (!Float.isNaN(pts[1])) {
      vals.add(new SelectionDetail(pts[1],i,dataSet));
    }
  }
  return vals;
}
Program: 18387
Project: 18387
Buggy source:
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
public List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet<?> dataSet=mData.getDataSetByIndex(i);
    float yVal=dataSet.getYValForXIndex(xIndex);
    if (!Float.isNaN(yVal)) {
      vals.add(new SelectionDetail(yVal,i,dataSet));
    }
  }
  return vals;
}

Fixed version (ground truth):
/** 
 * Returns an array of SelectionDetail objects for the given x-index. The SelectionDetail objects give information about the value at the selected index and the DataSet it belongs to. INFORMATION: This method does calculations at runtime. Do not over-use in performance critical situations.
 * @return
 */
public List<SelectionDetail> getSelectionDetailsAtIndex(int xIndex){
  List<SelectionDetail> vals=new ArrayList<SelectionDetail>();
  for (int i=0; i < mData.getDataSetCount(); i++) {
    DataSet<?> dataSet=mData.getDataSetByIndex(i);
    final float yVal=dataSet.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    vals.add(new SelectionDetail(yVal,i,dataSet));
  }
  return vals;
}
Program: 18388
Project: 18388
Buggy source:
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  for (int i=0; i < indices.length; i++) {
    LineDataSet set=mChart.getLineData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    mHighlightPaint.setColor(set.getHighLightColor());
    int xIndex=indices[i].getXIndex();
    if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())     continue;
    float yValue=set.getYValForXIndex(xIndex);
    if (yValue == Float.NaN)     continue;
    float y=yValue * mAnimator.getPhaseY();
    float[] pts=new float[]{xIndex,mChart.getYChartMax(),xIndex,mChart.getYChartMin(),mChart.getXChartMin(),y,mChart.getXChartMax(),y};
    mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
    c.drawLines(pts,mHighlightPaint);
  }
}

Fixed version (ground truth):
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  for (int i=0; i < indices.length; i++) {
    LineDataSet set=mChart.getLineData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    mHighlightPaint.setColor(set.getHighLightColor());
    int xIndex=indices[i].getXIndex();
    if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())     continue;
    final float yVal=set.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    float y=yVal * mAnimator.getPhaseY();
    float[] pts=new float[]{xIndex,mChart.getYChartMax(),xIndex,mChart.getYChartMin(),mChart.getXChartMin(),y,mChart.getXChartMax(),y};
    mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
    c.drawLines(pts,mHighlightPaint);
  }
}
Program: 18389
Project: 18389
Buggy source:
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  for (int i=0; i < indices.length; i++) {
    ScatterDataSet set=mChart.getScatterData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    mHighlightPaint.setColor(set.getHighLightColor());
    int xIndex=indices[i].getXIndex();
    if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())     continue;
    float yValue=set.getYValForXIndex(xIndex);
    if (yValue == Float.NaN)     continue;
    float y=yValue * mAnimator.getPhaseY();
    float[] pts=new float[]{xIndex,mChart.getYChartMax(),xIndex,mChart.getYChartMin(),0,y,mChart.getXChartMax(),y};
    mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
    c.drawLines(pts,mHighlightPaint);
  }
}

Fixed version (ground truth):
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  for (int i=0; i < indices.length; i++) {
    ScatterDataSet set=mChart.getScatterData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    mHighlightPaint.setColor(set.getHighLightColor());
    int xIndex=indices[i].getXIndex();
    if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())     continue;
    final float yVal=set.getYValForXIndex(xIndex);
    if (yVal == Float.NaN)     continue;
    float y=yVal * mAnimator.getPhaseY();
    float[] pts=new float[]{xIndex,mChart.getYChartMax(),xIndex,mChart.getYChartMin(),0,y,mChart.getXChartMax(),y};
    mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
    c.drawLines(pts,mHighlightPaint);
  }
}
Program: 18391
Project: 18391
Buggy source:
/** 
 * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected.
 * @param set
 * @param xIndex
 * @param dataSetIndex
 * @param yValue
 * @return
 */
protected Highlight getStackedHighlight(BarDataSet set,int xIndex,int dataSetIndex,double yValue){
  BarEntry entry=set.getEntryForXIndex(xIndex);
  if (entry != null) {
    int stackIndex=getClosestStackIndex(entry,(float)yValue);
    Highlight h=new Highlight(xIndex,dataSetIndex,stackIndex);
    return h;
  }
 else   return null;
}

Fixed version (ground truth):
/** 
 * This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected.
 * @param set
 * @param xIndex
 * @param dataSetIndex
 * @param yValue
 * @return
 */
protected Highlight getStackedHighlight(BarDataSet set,int xIndex,int dataSetIndex,double yValue){
  BarEntry entry=set.getEntryForXIndex(xIndex);
  if (entry != null) {
    Range[] ranges=getRanges(entry);
    int stackIndex=getClosestStackIndex(ranges,(float)yValue);
    Highlight h=new Highlight(xIndex,dataSetIndex,stackIndex,ranges[stackIndex]);
    return h;
  }
 else   return null;
}
Program: 18392
Project: 18392
Buggy source:
/** 
 * Returns the index of the closest value inside the values array (for stacked barchart) to the value given as a parameter.
 * @param e
 * @param value
 * @return
 */
protected int getClosestStackIndex(BarEntry e,float value){
  Range[] ranges=getRanges(e);
  int stackIndex=0;
  for (  Range range : ranges) {
    if (range.contains(value))     return stackIndex;
 else     stackIndex++;
  }
  int length=ranges.length - 1;
  return (value > ranges[length].to) ? length : 0;
}

Fixed version (ground truth):
/** 
 * Returns the index of the closest value inside the values array / ranges (stacked barchart) to the value given as a parameter.
 * @param ranges
 * @param value
 * @return
 */
protected int getClosestStackIndex(Range[] ranges,float value){
  int stackIndex=0;
  for (  Range range : ranges) {
    if (range.contains(value))     return stackIndex;
 else     stackIndex++;
  }
  int length=ranges.length - 1;
  return (value > ranges[length].to) ? length : 0;
}
Program: 18393
Project: 18393
Buggy source:
protected Range[] getRanges(BarEntry entry){
  float[] values=entry.getVals();
  float negRemain=-entry.getNegativeSum();
  float posRemain=0f;
  Range[] ranges=new Range[values.length];
  for (int i=0; i < ranges.length; i++) {
    float value=values[i];
    if (value < 0) {
      ranges[i]=new Range(negRemain,negRemain + Math.abs(value));
      negRemain+=Math.abs(value);
    }
 else {
      ranges[i]=new Range(posRemain,posRemain + value);
      posRemain+=value;
    }
  }
  return ranges;
}

Fixed version (ground truth):
/** 
 * Splits up the stack-values of the given bar-entry into Range objects.
 * @param entry
 * @return
 */
protected Range[] getRanges(BarEntry entry){
  float[] values=entry.getVals();
  if (values == null)   return null;
  float negRemain=-entry.getNegativeSum();
  float posRemain=0f;
  Range[] ranges=new Range[values.length];
  for (int i=0; i < ranges.length; i++) {
    float value=values[i];
    if (value < 0) {
      ranges[i]=new Range(negRemain,negRemain + Math.abs(value));
      negRemain+=Math.abs(value);
    }
 else {
      ranges[i]=new Range(posRemain,posRemain + value);
      posRemain+=value;
    }
  }
  return ranges;
}
Program: 18394
Project: 18394
Buggy source:
/** 
 * Constructor, only used for stacked-barchart.
 * @param x the index of the highlighted value on the x-axis
 * @param val the value at the position the user touched
 * @param dataSet the index of the DataSet the highlighted value belongs to
 * @param stackIndex references which value of a stacked-bar entry has beenselected
 */
public Highlight(int x,int dataSet,int stackIndex){
  this(x,dataSet);
  mStackIndex=stackIndex;
}

Fixed version (ground truth):
/** 
 * Constructor, only used for stacked-barchart.
 * @param x the index of the highlighted value on the x-axis
 * @param dataSet the index of the DataSet the highlighted value belongs to
 * @param stackIndex references which value of a stacked-bar entry has beenselected
 * @param range the range the selected stack-value is in
 */
public Highlight(int x,int dataSet,int stackIndex,Range range){
  this(x,dataSet,stackIndex);
  this.mRange=range;
}
Program: 18396
Project: 18396
Buggy source:
public YAxis(AxisDependency position){
  super();
  this.mAxisDependency=position;
}

Fixed version (ground truth):
public YAxis(AxisDependency position){
  super();
  this.mAxisDependency=position;
  this.mYOffset=0f;
}
Program: 18397
Project: 18397
Buggy source:
/** 
 * draws the y-axis labels to the screen
 */
@Override public void renderAxisLabels(Canvas c){
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())   return;
  float[] positions=new float[mYAxis.mEntryCount * 2];
  for (int i=0; i < positions.length; i+=2) {
    positions[i + 1]=mYAxis.mEntries[i / 2];
  }
  mTrans.pointValuesToPixel(positions);
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  float xoffset=mYAxis.getXOffset();
  float yoffset=Utils.calcTextHeight(mAxisLabelPaint,"String_Node_Str") / 2.5f;
  AxisDependency dependency=mYAxis.getAxisDependency();
  YAxisLabelPosition labelPosition=mYAxis.getLabelPosition();
  float xPos=0f;
  if (dependency == AxisDependency.LEFT) {
    if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
      mAxisLabelPaint.setTextAlign(Align.RIGHT);
      xPos=mViewPortHandler.offsetLeft() - xoffset;
    }
 else {
      mAxisLabelPaint.setTextAlign(Align.LEFT);
      xPos=mViewPortHandler.offsetLeft() + xoffset;
    }
  }
 else {
    if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
      mAxisLabelPaint.setTextAlign(Align.LEFT);
      xPos=mViewPortHandler.contentRight() + xoffset;
    }
 else {
      mAxisLabelPaint.setTextAlign(Align.RIGHT);
      xPos=mViewPortHandler.contentRight() - xoffset;
    }
  }
  drawYLabels(c,xPos,positions,yoffset);
}

Fixed version (ground truth):
/** 
 * draws the y-axis labels to the screen
 */
@Override public void renderAxisLabels(Canvas c){
  if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())   return;
  float[] positions=new float[mYAxis.mEntryCount * 2];
  for (int i=0; i < positions.length; i+=2) {
    positions[i + 1]=mYAxis.mEntries[i / 2];
  }
  mTrans.pointValuesToPixel(positions);
  mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
  mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
  mAxisLabelPaint.setColor(mYAxis.getTextColor());
  float xoffset=mYAxis.getXOffset();
  float yoffset=Utils.calcTextHeight(mAxisLabelPaint,"String_Node_Str") / 2.5f + mYAxis.getYOffset();
  AxisDependency dependency=mYAxis.getAxisDependency();
  YAxisLabelPosition labelPosition=mYAxis.getLabelPosition();
  float xPos=0f;
  if (dependency == AxisDependency.LEFT) {
    if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
      mAxisLabelPaint.setTextAlign(Align.RIGHT);
      xPos=mViewPortHandler.offsetLeft() - xoffset;
    }
 else {
      mAxisLabelPaint.setTextAlign(Align.LEFT);
      xPos=mViewPortHandler.offsetLeft() + xoffset;
    }
  }
 else {
    if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
      mAxisLabelPaint.setTextAlign(Align.LEFT);
      xPos=mViewPortHandler.contentRight() + xoffset;
    }
 else {
      mAxisLabelPaint.setTextAlign(Align.RIGHT);
      xPos=mViewPortHandler.contentRight() - xoffset;
    }
  }
  drawYLabels(c,xPos,positions,yoffset);
}
Program: 18398
Project: 18398
Buggy source:
@Override public void renderGridLines(Canvas c){
  if (!mXAxis.isDrawGridLinesEnabled() || !mXAxis.isEnabled())   return;
  float[] position=new float[]{0f,0f};
  mGridPaint.setColor(mXAxis.getGridColor());
  mGridPaint.setStrokeWidth(mXAxis.getGridLineWidth());
  mGridPaint.setPathEffect(mXAxis.getGridDashPathEffect());
  for (int i=mMinX; i <= mMaxX; i+=mXAxis.mAxisLabelModulus) {
    position[0]=i;
    mTrans.pointValuesToPixel(position);
    if (position[0] >= mViewPortHandler.offsetLeft() && position[0] <= mViewPortHandler.getChartWidth()) {
      c.drawLine(position[0],mViewPortHandler.offsetTop(),position[0],mViewPortHandler.contentBottom(),mGridPaint);
    }
  }
}

Fixed version (ground truth):
@Override public void renderGridLines(Canvas c){
  if (!mXAxis.isDrawGridLinesEnabled() || !mXAxis.isEnabled())   return;
  float[] position=new float[]{0f,0f};
  mGridPaint.setColor(mXAxis.getGridColor());
  mGridPaint.setStrokeWidth(mXAxis.getGridLineWidth());
  mGridPaint.setPathEffect(mXAxis.getGridDashPathEffect());
  Path gridLinePath=new Path();
  for (int i=mMinX; i <= mMaxX; i+=mXAxis.mAxisLabelModulus) {
    position[0]=i;
    mTrans.pointValuesToPixel(position);
    if (position[0] >= mViewPortHandler.offsetLeft() && position[0] <= mViewPortHandler.getChartWidth()) {
      gridLinePath.moveTo(position[0],mViewPortHandler.contentBottom());
      gridLinePath.lineTo(position[0],mViewPortHandler.contentTop());
      c.drawPath(gridLinePath,mGridPaint);
    }
    gridLinePath.reset();
  }
}
Program: 18399
Project: 18399
Buggy source:
/** 
 * Prepares a bar for being highlighted.
 * @param x the x-position
 * @param y the y-position
 * @param barspace the space between bars
 * @param from
 * @param trans
 */
protected void prepareBarHighlight(float x,float y,float barspaceHalf,float from,Transformer trans){
  float barWidth=0.5f;
  float left=x - barWidth + barspaceHalf;
  float right=x + barWidth - barspaceHalf;
  float top=y >= from ? y : from;
  float bottom=y <= from ? y : from;
  mBarRect.set(left,top,right,bottom);
  trans.rectValueToPixel(mBarRect,mAnimator.getPhaseY());
}

Fixed version (ground truth):
/** 
 * Prepares a bar for being highlighted.
 * @param x the x-position
 * @param y the y-position
 * @param barspaceHalf the space between bars
 * @param from
 * @param trans
 */
protected void prepareBarHighlight(float x,float y,float barspaceHalf,float from,Transformer trans){
  float barWidth=0.5f;
  float left=x - barWidth + barspaceHalf;
  float right=x + barWidth - barspaceHalf;
  float top=y >= from ? y : from;
  float bottom=y <= from ? y : from;
  mBarRect.set(left,top,right,bottom);
  trans.rectValueToPixel(mBarRect,mAnimator.getPhaseY());
}