Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow getting/settings minOffset of the charts #1104

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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