Skip to content

Commit

Permalink
Added possibility to set label textsize, added possibility to set val…
Browse files Browse the repository at this point in the history
…ue textsize. Fixed bug in the getPaint(...) method.
  • Loading branch information
PhilJay committed Aug 11, 2014
1 parent 5e6d84e commit 6c1163d
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 186 deletions.
2 changes: 1 addition & 1 deletion MPChartExample/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
target=android-20
android.library.reference.1=../MPChartLib
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package com.xxmassdeveloper.mpchartexample;

import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
Expand All @@ -12,6 +13,7 @@
import android.widget.Toast;

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.Entry;
Expand Down Expand Up @@ -81,13 +83,15 @@ protected void onCreate(Bundle savedInstanceState) {

XLabels xLabels = mChart.getXLabels();
xLabels.setPosition(XLabelPosition.TOP);

// mChart.setDrawXLabels(false);

mChart.setDrawGridBackground(false);
mChart.setDrawHorizontalGrid(true);
mChart.setDrawVerticalGrid(false);
// mChart.setDrawYLabels(false);

// sets the text size of the values inside the chart
mChart.setValueTextSize(10f);

mChart.setDrawBorder(false);
// mChart.setBorderPositions(new BorderPosition[] {BorderPosition.LEFT,
Expand Down
2 changes: 1 addition & 1 deletion MPChartLib/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
target=android-20
android.library=true
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ public void setPaint(Paint p, int which) {

@Override
public Paint getPaint(int which) {
super.getPaint(which);
Paint p = super.getPaint(which);
if(p != null) return p;

switch (which) {
case PAINT_HIGHLIGHT_BAR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ protected void drawXLabels() {
float yoffset = Utils.convertDpToPixel(3.5f);

mXLabelPaint.setTypeface(mXLabels.getTypeface());
mXLabelPaint.setTextSize(mXLabels.getTextSize());

if (mXLabels.getPosition() == XLabelPosition.TOP) {

Expand Down Expand Up @@ -686,6 +687,7 @@ protected void drawYLabels() {
float xoffset = Utils.convertDpToPixel(5f);

mYLabelPaint.setTypeface(mYLabels.getTypeface());
mYLabelPaint.setTextSize(mYLabels.getTextSize());

// determine position and draw adequately
if (mYLabels.getPosition() == YLabelPosition.LEFT) {
Expand Down Expand Up @@ -1281,35 +1283,6 @@ public void setMaxVisibleValueCount(int count) {
this.mMaxVisibleCount = count;
}

/**
* sets the size of the y-label text in pixels min = 7f, max = 14f
*
* @param size
*/
public void setYLabelTextSize(float size) {

if (size > 14f)
size = 14f;
if (size < 7f)
size = 7f;
mYLabelPaint.setTextSize(Utils.convertDpToPixel(size));
}

/**
* sets the size of the x-label text in pixels min = 7f, max = 14f
*
* @param size
*/
public void setXLabelTextSize(float size) {

if (size > 14f)
size = 14f;
if (size < 7f)
size = 7f;

mXLabelPaint.setTextSize(Utils.convertDpToPixel(size));
}

/**
* If set to true, the highlight indicators (cross of two lines for
* LineChart and ScatterChart, dark bar overlay for BarChart) that give
Expand Down Expand Up @@ -1846,7 +1819,8 @@ public void setPaint(Paint p, int which) {

@Override
public Paint getPaint(int which) {
super.getPaint(which);
Paint p = super.getPaint(which);
if(p != null) return p;

switch (which) {
case PAINT_GRID:
Expand Down
Loading

0 comments on commit 6c1163d

Please sign in to comment.