Merge pull request #1 from wajdichamakhi/Labels_and_legend_bold
Adding control on text Boldness in XAxis, YAxis, Limit Legends
This commit is contained in:
commit
f324378de3
8 changed files with 39 additions and 1 deletions
|
@ -43,6 +43,11 @@ public abstract class ComponentBase {
|
|||
*/
|
||||
protected int mTextColor = Color.BLACK;
|
||||
|
||||
/**
|
||||
* the text style boldness {Default = false}
|
||||
*/
|
||||
protected boolean mTextBold = false;
|
||||
|
||||
public ComponentBase() {
|
||||
|
||||
}
|
||||
|
@ -130,6 +135,24 @@ public abstract class ComponentBase {
|
|||
return mTextSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the text to be bold
|
||||
*
|
||||
* @param bold
|
||||
*/
|
||||
public void setTextBold(boolean bold) {
|
||||
mTextBold = bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the text boldness
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getTextBold() {
|
||||
return mTextBold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text color to use for the labels. Make sure to use
|
||||
* getResources().getColor(...) when using a color from the resources.
|
||||
|
|
|
@ -167,6 +167,7 @@ public class LegendRenderer extends Renderer {
|
|||
mLegendLabelPaint.setTypeface(tf);
|
||||
|
||||
mLegendLabelPaint.setTextSize(mLegend.getTextSize());
|
||||
mLegendLabelPaint.setFakeBoldText(mLegend.getTextBold());
|
||||
mLegendLabelPaint.setColor(mLegend.getTextColor());
|
||||
|
||||
// calculate all dimensions of the mLegend
|
||||
|
@ -184,6 +185,7 @@ public class LegendRenderer extends Renderer {
|
|||
mLegendLabelPaint.setTypeface(tf);
|
||||
|
||||
mLegendLabelPaint.setTextSize(mLegend.getTextSize());
|
||||
mLegendLabelPaint.setFakeBoldText(mLegend.getTextBold());
|
||||
mLegendLabelPaint.setColor(mLegend.getTextColor());
|
||||
|
||||
float labelLineHeight = Utils.getLineHeight(mLegendLabelPaint);
|
||||
|
|
|
@ -36,6 +36,7 @@ public class XAxisRenderer extends AxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mXAxis.getTextBold());
|
||||
|
||||
StringBuilder widthText = new StringBuilder();
|
||||
|
||||
|
@ -82,6 +83,7 @@ public class XAxisRenderer extends AxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mXAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mXAxis.getTextColor());
|
||||
|
||||
if (mXAxis.getPosition() == XAxisPosition.TOP) {
|
||||
|
@ -293,6 +295,8 @@ public class XAxisRenderer extends AxisRenderer {
|
|||
mLimitLinePaint.setColor(limitLine.getTextColor());
|
||||
mLimitLinePaint.setStrokeWidth(0.5f);
|
||||
mLimitLinePaint.setTextSize(limitLine.getTextSize());
|
||||
mLimitLinePaint.setFakeBoldText(limitLine.getTextBold());
|
||||
|
||||
|
||||
float xOffset = limitLine.getLineWidth() + limitLine.getXOffset();
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class XAxisRendererHorizontalBarChart extends XAxisRendererBarChart {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mXAxis.getTextBold());
|
||||
mXAxis.setValues(xValues);
|
||||
|
||||
String longest = mXAxis.getLongestLabel();
|
||||
|
@ -61,6 +62,7 @@ public class XAxisRendererHorizontalBarChart extends XAxisRendererBarChart {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mXAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mXAxis.getTextColor());
|
||||
|
||||
if (mXAxis.getPosition() == XAxisPosition.TOP) {
|
||||
|
@ -237,6 +239,7 @@ public class XAxisRendererHorizontalBarChart extends XAxisRendererBarChart {
|
|||
mLimitLinePaint.setColor(l.getTextColor());
|
||||
mLimitLinePaint.setStrokeWidth(0.5f);
|
||||
mLimitLinePaint.setTextSize(l.getTextSize());
|
||||
mLimitLinePaint.setFakeBoldText(l.getTextBold());
|
||||
|
||||
final float labelLineHeight = Utils.calcTextHeight(mLimitLinePaint, label);
|
||||
float xOffset = Utils.convertDpToPixel(4f) + l.getXOffset();
|
||||
|
|
|
@ -30,6 +30,7 @@ public class XAxisRendererRadarChart extends XAxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mXAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mXAxis.getTextColor());
|
||||
|
||||
float sliceangle = mChart.getSliceAngle();
|
||||
|
|
|
@ -193,6 +193,7 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mYAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mYAxis.getTextColor());
|
||||
|
||||
float xoffset = mYAxis.getXOffset();
|
||||
|
@ -381,6 +382,7 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
mLimitLinePaint.setTypeface(l.getTypeface());
|
||||
mLimitLinePaint.setStrokeWidth(0.5f);
|
||||
mLimitLinePaint.setTextSize(l.getTextSize());
|
||||
mLimitLinePaint.setFakeBoldText(l.getTextBold());
|
||||
|
||||
final float labelLineHeight = Utils.calcTextHeight(mLimitLinePaint, label);
|
||||
float xOffset = Utils.convertDpToPixel(4f) + l.getXOffset();
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Paint.Align;
|
|||
import android.graphics.Path;
|
||||
|
||||
import com.github.mikephil.charting.components.LimitLine;
|
||||
import com.github.mikephil.charting.components.LimitLine.LimitLabelPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.components.YAxis.AxisDependency;
|
||||
import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition;
|
||||
|
@ -78,6 +77,7 @@ public class YAxisRendererHorizontalBarChart extends YAxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mYAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mYAxis.getTextColor());
|
||||
mAxisLabelPaint.setTextAlign(Align.CENTER);
|
||||
|
||||
|
@ -140,6 +140,7 @@ public class YAxisRendererHorizontalBarChart extends YAxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mYAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mYAxis.getTextColor());
|
||||
|
||||
for (int i = 0; i < mYAxis.mEntryCount; i++) {
|
||||
|
@ -243,6 +244,7 @@ public class YAxisRendererHorizontalBarChart extends YAxisRenderer {
|
|||
mLimitLinePaint.setTypeface(l.getTypeface());
|
||||
mLimitLinePaint.setStrokeWidth(0.5f);
|
||||
mLimitLinePaint.setTextSize(l.getTextSize());
|
||||
mLimitLinePaint.setFakeBoldText(l.getTextBold());
|
||||
|
||||
float xOffset = l.getLineWidth() + l.getXOffset();
|
||||
float yOffset = Utils.convertDpToPixel(2f) + l.getYOffset();
|
||||
|
|
|
@ -137,6 +137,7 @@ public class YAxisRendererRadarChart extends YAxisRenderer {
|
|||
|
||||
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
|
||||
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
|
||||
mAxisLabelPaint.setFakeBoldText(mYAxis.getTextBold());
|
||||
mAxisLabelPaint.setColor(mYAxis.getTextColor());
|
||||
|
||||
PointF center = mChart.getCenterOffsets();
|
||||
|
|
Loading…
Add table
Reference in a new issue