|
5 | 5 | import android.graphics.Color; |
6 | 6 | import android.graphics.Paint; |
7 | 7 | import android.graphics.Path; |
| 8 | +import android.graphics.drawable.Drawable; |
8 | 9 |
|
9 | 10 | import com.github.mikephil.charting.animation.ChartAnimator; |
10 | 11 | import com.github.mikephil.charting.buffer.CircleBuffer; |
@@ -85,7 +86,7 @@ public void drawData(Canvas c) { |
85 | 86 |
|
86 | 87 | if (width > 0 && height > 0) { |
87 | 88 |
|
88 | | - mDrawBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444); |
| 89 | + mDrawBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
89 | 90 | mBitmapCanvas = new Canvas(mDrawBitmap); |
90 | 91 | } else |
91 | 92 | return; |
@@ -125,6 +126,22 @@ protected void drawDataSet(Canvas c, ILineDataSet dataSet) { |
125 | 126 | mRenderPaint.setPathEffect(null); |
126 | 127 | } |
127 | 128 |
|
| 129 | + /** |
| 130 | + * Draws the provided path in filled mode with the provided drawable. |
| 131 | + */ |
| 132 | + protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) { |
| 133 | + c.save(); |
| 134 | + c.clipPath(filledPath); |
| 135 | + |
| 136 | + drawable.setBounds((int) mViewPortHandler.contentLeft(), |
| 137 | + (int) mViewPortHandler.contentTop(), |
| 138 | + (int) mViewPortHandler.contentRight(), |
| 139 | + (int) mViewPortHandler.contentBottom()); |
| 140 | + drawable.draw(c); |
| 141 | + |
| 142 | + c.restore(); |
| 143 | + } |
| 144 | + |
128 | 145 | /** |
129 | 146 | * Draws a cubic line. |
130 | 147 | * |
@@ -252,6 +269,11 @@ protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transf |
252 | 269 |
|
253 | 270 | trans.pathValueToPixel(spline); |
254 | 271 |
|
| 272 | + final Drawable drawable = dataSet.getFillDrawable(); |
| 273 | + if (dataSet.getFillDrawable() != null) { |
| 274 | + drawFilledPath(c, spline, drawable); |
| 275 | + return; |
| 276 | + } |
255 | 277 | drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); |
256 | 278 | } |
257 | 279 |
|
@@ -349,6 +371,12 @@ protected void drawLinearFill(Canvas c, ILineDataSet dataSet, int minx, |
349 | 371 |
|
350 | 372 | trans.pathValueToPixel(filled); |
351 | 373 |
|
| 374 | + final Drawable drawable = dataSet.getFillDrawable(); |
| 375 | + if (drawable != null) { |
| 376 | + drawFilledPath(c, filled, drawable); |
| 377 | + return; |
| 378 | + } |
| 379 | + |
352 | 380 | drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha()); |
353 | 381 | } |
354 | 382 |
|
|
0 commit comments