Skip to content

Commit dc526bc

Browse files
committed
Add change text color for BarLineChart
1 parent 74a3e38 commit dc526bc

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,4 +1686,16 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
16861686
mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(), this, true);
16871687
}
16881688
}
1689+
1690+
/**
1691+
* Sets the text color to use for the labels. Make sure to use
1692+
* getResources().getColor(...) when using a color from the resources.
1693+
*
1694+
* @param color
1695+
*/
1696+
public void setTextColor(int color) {
1697+
mAxisRendererLeft.setTextColor(color);
1698+
mAxisRendererRight.setTextColor(color);
1699+
mXAxisRenderer.setTextColor(color);
1700+
}
16891701
}

MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,4 +846,14 @@ public float[] getSpecificPositions()
846846
{
847847
return specificPositions;
848848
}
849+
850+
/**
851+
* Sets the text color to use for the labels. Make sure to use
852+
* getResources().getColor(...) when using a color from the resources.
853+
*
854+
* @param color
855+
*/
856+
public void setTextColor(int color) {
857+
mTextColor = color;
858+
}
849859
}

MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ protected void copy(BaseDataSet baseDataSet) {
499499
baseDataSet.mIconsOffset = mIconsOffset;
500500
baseDataSet.mValueColors = mValueColors;
501501
baseDataSet.mValueFormatter = mValueFormatter;
502-
baseDataSet.mValueColors = mValueColors;
503502
baseDataSet.mValueTextSize = mValueTextSize;
504503
baseDataSet.mVisible = mVisible;
505504
}

MPChartLib/src/main/java/com/github/mikephil/charting/renderer/AxisRenderer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,14 @@ else if (last == first && n == 0) {
290290
* @param c
291291
*/
292292
public abstract void renderLimitLines(Canvas c);
293+
294+
/**
295+
* Sets the text color to use for the labels. Make sure to use
296+
* getResources().getColor(...) when using a color from the resources.
297+
*
298+
* @param color
299+
*/
300+
public void setTextColor(int color) {
301+
mAxis.setTextColor(color);
302+
}
293303
}

MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,12 @@ protected void drawRoundedSlices(Canvas c) {
10381038
// draw only if the value is greater than zero
10391039
if ((Math.abs(e.getY()) > Utils.FLOAT_EPSILON)) {
10401040

1041+
double v = Math.toRadians((angle + sliceAngle)
1042+
* phaseY);
10411043
float x = (float) ((r - circleRadius)
1042-
* Math.cos(Math.toRadians((angle + sliceAngle)
1043-
* phaseY)) + center.x);
1044+
* Math.cos(v) + center.x);
10441045
float y = (float) ((r - circleRadius)
1045-
* Math.sin(Math.toRadians((angle + sliceAngle)
1046-
* phaseY)) + center.y);
1046+
* Math.sin(v) + center.y);
10471047

10481048
mRenderPaint.setColor(dataSet.getColor(j));
10491049
mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint);

0 commit comments

Comments
 (0)