drawBarShadowEnabled
is working again
This commit is contained in:
parent
0c00b09bdb
commit
1096719e8f
2 changed files with 76 additions and 25 deletions
|
@ -80,11 +80,12 @@ public class BarChartRenderer extends BarLineScatterCandleBubbleRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private RectF mBarShadowRectBuffer = new RectF();
|
||||
|
||||
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {
|
||||
|
||||
Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());
|
||||
|
||||
mShadowPaint.setColor(dataSet.getBarShadowColor());
|
||||
mBarBorderPaint.setColor(dataSet.getBarBorderColor());
|
||||
mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth()));
|
||||
|
||||
|
@ -93,6 +94,42 @@ public class BarChartRenderer extends BarLineScatterCandleBubbleRenderer {
|
|||
float phaseX = mAnimator.getPhaseX();
|
||||
float phaseY = mAnimator.getPhaseY();
|
||||
|
||||
// draw the bar shadow before the values
|
||||
if (mChart.isDrawBarShadowEnabled()) {
|
||||
mShadowPaint.setColor(dataSet.getBarShadowColor());
|
||||
|
||||
BarData barData = mChart.getBarData();
|
||||
|
||||
final float barWidth = barData.getBarWidth();
|
||||
final float barWidthHalf = barWidth / 2.0f;
|
||||
float x;
|
||||
|
||||
for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount());
|
||||
i < count;
|
||||
i++) {
|
||||
|
||||
BarEntry e = dataSet.getEntryForIndex(i);
|
||||
|
||||
x = e.getX();
|
||||
|
||||
mBarShadowRectBuffer.left = x - barWidthHalf;
|
||||
mBarShadowRectBuffer.right = x + barWidthHalf;
|
||||
|
||||
trans.rectValueToPixel(mBarShadowRectBuffer);
|
||||
|
||||
if (!mViewPortHandler.isInBoundsLeft(mBarShadowRectBuffer.right))
|
||||
continue;
|
||||
|
||||
if (!mViewPortHandler.isInBoundsRight(mBarShadowRectBuffer.left))
|
||||
break;
|
||||
|
||||
mBarShadowRectBuffer.top = mViewPortHandler.contentTop();
|
||||
mBarShadowRectBuffer.bottom = mViewPortHandler.contentBottom();
|
||||
|
||||
c.drawRect(mBarShadowRectBuffer, mShadowPaint);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize the buffer
|
||||
BarBuffer buffer = mBarBuffers[index];
|
||||
buffer.setPhases(phaseX, phaseY);
|
||||
|
@ -104,23 +141,6 @@ public class BarChartRenderer extends BarLineScatterCandleBubbleRenderer {
|
|||
|
||||
trans.pointValuesToPixel(buffer.buffer);
|
||||
|
||||
// draw the bar shadow before the values
|
||||
if (mChart.isDrawBarShadowEnabled()) {
|
||||
|
||||
for (int j = 0; j < buffer.size(); j += 4) {
|
||||
|
||||
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]))
|
||||
continue;
|
||||
|
||||
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j]))
|
||||
break;
|
||||
|
||||
c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(),
|
||||
buffer.buffer[j + 2],
|
||||
mViewPortHandler.contentBottom(), mShadowPaint);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isSingleColor = dataSet.getColors().size() == 1;
|
||||
|
||||
if (isSingleColor) {
|
||||
|
|
|
@ -48,12 +48,13 @@ public class HorizontalBarChartRenderer extends BarChartRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private RectF mBarShadowRectBuffer = new RectF();
|
||||
|
||||
@Override
|
||||
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) {
|
||||
|
||||
Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());
|
||||
|
||||
mShadowPaint.setColor(dataSet.getBarShadowColor());
|
||||
mBarBorderPaint.setColor(dataSet.getBarBorderColor());
|
||||
mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth()));
|
||||
|
||||
|
@ -62,6 +63,42 @@ public class HorizontalBarChartRenderer extends BarChartRenderer {
|
|||
float phaseX = mAnimator.getPhaseX();
|
||||
float phaseY = mAnimator.getPhaseY();
|
||||
|
||||
// draw the bar shadow before the values
|
||||
if (mChart.isDrawBarShadowEnabled()) {
|
||||
mShadowPaint.setColor(dataSet.getBarShadowColor());
|
||||
|
||||
BarData barData = mChart.getBarData();
|
||||
|
||||
final float barWidth = barData.getBarWidth();
|
||||
final float barWidthHalf = barWidth / 2.0f;
|
||||
float x;
|
||||
|
||||
for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount());
|
||||
i < count;
|
||||
i++) {
|
||||
|
||||
BarEntry e = dataSet.getEntryForIndex(i);
|
||||
|
||||
x = e.getX();
|
||||
|
||||
mBarShadowRectBuffer.top = x - barWidthHalf;
|
||||
mBarShadowRectBuffer.bottom = x + barWidthHalf;
|
||||
|
||||
trans.rectValueToPixel(mBarShadowRectBuffer);
|
||||
|
||||
if (!mViewPortHandler.isInBoundsTop(mBarShadowRectBuffer.bottom))
|
||||
continue;
|
||||
|
||||
if (!mViewPortHandler.isInBoundsBottom(mBarShadowRectBuffer.top))
|
||||
break;
|
||||
|
||||
mBarShadowRectBuffer.left = mViewPortHandler.contentLeft();
|
||||
mBarShadowRectBuffer.right = mViewPortHandler.contentRight();
|
||||
|
||||
c.drawRect(mBarShadowRectBuffer, mShadowPaint);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize the buffer
|
||||
BarBuffer buffer = mBarBuffers[index];
|
||||
buffer.setPhases(phaseX, phaseY);
|
||||
|
@ -87,12 +124,6 @@ public class HorizontalBarChartRenderer extends BarChartRenderer {
|
|||
if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1]))
|
||||
continue;
|
||||
|
||||
if (mChart.isDrawBarShadowEnabled()) {
|
||||
c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1],
|
||||
mViewPortHandler.contentRight(),
|
||||
buffer.buffer[j + 3], mShadowPaint);
|
||||
}
|
||||
|
||||
if (!isSingleColor) {
|
||||
// Set the color for the currently drawn value. If the index
|
||||
// is out of bounds, reuse colors.
|
||||
|
|
Loading…
Add table
Reference in a new issue