Skip to content

Commit

Permalink
Merge pull request PhilJay#1104 from danielgindi/minoffset_accessors
Browse files Browse the repository at this point in the history
Allow getting/settings minOffset of the charts
  • Loading branch information
PhilJay committed Oct 13, 2015
2 parents 62ca243 + 77692da commit 909ab1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,16 @@ public void setBorderColor(int color) {
mBorderPaint.setColor(color);
}

/** Gets the minimum offset (padding) around the chart, defaults to 10.f */
public float getMinOffset() {
return mMinOffset;
}

/** Sets the minimum offset (padding) around the chart, defaults to 10.f */
public void setMinOffset(float minOffset) {
mMinOffset = minOffset;
}

/**
* Returns the Highlight object (contains x-index and DataSet index) of the
* selected value at the given touch point inside the Line-, Scatter-, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public abstract class PieRadarChartBase<T extends ChartData<? extends DataSet<?
/** flag that indicates if rotation is enabled or not */
protected boolean mRotateEnabled = true;

/** Sets the minimum offset (padding) around the chart, defaults to 0.f */
protected float mMinOffset = 0.f;

public PieRadarChartBase(Context context) {
super(context);
}
Expand Down Expand Up @@ -209,13 +212,13 @@ public void calculateOffsets() {
legendTop += getRequiredBaseOffset();
}

float minOffset = 0f;
float minOffset = Utils.convertDpToPixel(mMinOffset);

if (this instanceof RadarChart) {
XAxis x = ((RadarChart) this).getXAxis();

if (x.isEnabled() && x.isDrawLabelsEnabled()) {
minOffset = x.mLabelWidth;
minOffset = Math.max(minOffset, x.mLabelWidth);
}
}

Expand Down Expand Up @@ -380,6 +383,16 @@ public boolean isRotationEnabled() {
return mRotateEnabled;
}

/** Gets the minimum offset (padding) around the chart, defaults to 0.f */
public float getMinOffset() {
return mMinOffset;
}

/** Sets the minimum offset (padding) around the chart, defaults to 0.f */
public void setMinOffset(float minOffset) {
mMinOffset = minOffset;
}

/**
* returns the diameter of the pie- or radar-chart
*
Expand Down

0 comments on commit 909ab1a

Please sign in to comment.