public class YAxis extends AxisBase
| Modifier and Type | Class and Description |
|---|---|
static class |
YAxis.AxisDependency
Enum that specifies the axis a DataSet should be plotted against, either LEFT or RIGHT.
|
static class |
YAxis.YAxisLabelPosition
enum for the position of the y-labels relative to the chart
|
| Modifier and Type | Field and Description |
|---|---|
int |
mDecimals
the number of decimal digits to use
|
protected boolean |
mDrawZeroLine
flag that indicates if the zero-line should be drawn regardless of other grid lines
|
float[] |
mEntries
the actual array of entries
|
int |
mEntryCount
the number of entries the legend contains
|
protected boolean |
mForceLabels
if true, the set number of y-labels will be forced
|
protected float |
mGranularity
the minimum interval between axis values
|
protected boolean |
mGranularityEnabled
When true, axis labels are controlled by the `granularity` property.
|
protected boolean |
mInverted
flag that indicates if the axis is inverted or not
|
protected float |
mMaxWidth
the maximum width that the axis can take (in dp).
|
protected float |
mMinWidth
the minimum width that the axis should take (in dp).
|
protected boolean |
mShowOnlyMinMax
if true, the y-labels show only the minimum and maximum value
|
protected float |
mSpacePercentBottom
axis space from the smallest value to the bottom in percent of the total axis range
|
protected float |
mSpacePercentTop
axis space from the largest value to the top in percent of the total axis range
|
protected YAxisValueFormatter |
mYAxisValueFormatter
custom formatter that is used instead of the auto-formatter if set
|
protected int |
mZeroLineColor
Color of the zero line
|
protected float |
mZeroLineWidth
Width of the zero line in pixels
|
mAxisMaximum, mAxisMinimum, mAxisRange, mCustomAxisMax, mCustomAxisMin, mDrawAxisLine, mDrawGridLines, mDrawLabels, mDrawLimitLineBehindData, mLimitLinesmEnabled, mTextColor, mTextSize, mTypeface, mXOffset, mYOffset| Constructor and Description |
|---|
YAxis() |
YAxis(YAxis.AxisDependency position) |
| Modifier and Type | Method and Description |
|---|---|
void |
calculate(float dataMin,
float dataMax)
Calculates the minimum, maximum, granularity and range values of the YAxis with the given
minimum and maximum values from the chart data.
|
YAxis.AxisDependency |
getAxisDependency() |
java.lang.String |
getFormattedLabel(int index)
Returns the formatted y-label at the specified index.
|
float |
getGranularity() |
int |
getLabelCount()
Returns the number of label entries the y-axis should have
|
YAxis.YAxisLabelPosition |
getLabelPosition()
returns the position of the y-labels
|
java.lang.String |
getLongestLabel()
Returns the longest formatted label (in terms of characters), this axis
contains.
|
float |
getMaxWidth() |
float |
getMinWidth() |
float |
getRequiredHeightSpace(android.graphics.Paint p)
This is for HorizontalBarChart vertical spacing.
|
float |
getRequiredWidthSpace(android.graphics.Paint p)
This is for normal (not horizontal) charts horizontal spacing.
|
float |
getSpaceBottom()
Returns the bottom axis space in percent of the full range.
|
float |
getSpaceTop()
Returns the top axis space in percent of the full range.
|
YAxisValueFormatter |
getValueFormatter()
Returns the formatter used for formatting the axis labels.
|
int |
getZeroLineColor() |
float |
getZeroLineWidth() |
boolean |
isDrawTopYLabelEntryEnabled()
returns true if drawing the top y-axis label entry is enabled
|
boolean |
isDrawZeroLineEnabled() |
boolean |
isForceLabelsEnabled()
Returns true if focing the y-label count is enabled.
|
boolean |
isGranularityEnabled() |
boolean |
isInverted()
If this returns true, the y-axis is inverted.
|
boolean |
isShowOnlyMinMaxEnabled()
Returns true if showing only min and max value is enabled.
|
boolean |
needsDefaultFormatter()
If this component has no YAxisValueFormatter or is only equipped with the default one (no
custom set), return true.
|
boolean |
needsOffset()
Returns true if this axis needs horizontal offset, false if no offset is needed.
|
void |
setDrawTopYLabelEntry(boolean enabled)
set this to true to enable drawing the top y-label entry.
|
void |
setDrawZeroLine(boolean mDrawZeroLine)
Set this to true to draw the zero-line regardless of weather other
grid-lines are enabled or not.
|
void |
setGranularity(float granularity)
Set a minimum interval for the axis when zooming in.
|
void |
setGranularityEnabled(boolean enabled)
Enabled/disable granularity control on axis value intervals.
|
void |
setInverted(boolean enabled)
If this is set to true, the y-axis is inverted which means that low values are on top of
the chart, high values
on bottom.
|
void |
setLabelCount(int count,
boolean force)
sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be aware
that this number is not
fixed (if force == false) and can only be approximated.
|
void |
setMaxWidth(float maxWidth)
Sets the maximum width that the axis can take (in dp).
|
void |
setMinWidth(float minWidth)
Sets the minimum width that the axis should take (in dp).
|
void |
setPosition(YAxis.YAxisLabelPosition pos)
sets the position of the y-labels
|
void |
setShowOnlyMinMax(boolean enabled)
If enabled, the YLabels will only show the minimum and maximum value of the chart.
|
void |
setSpaceBottom(float percent)
Sets the bottom axis space in percent of the full range.
|
void |
setSpaceTop(float percent)
Sets the top axis space in percent of the full range.
|
void |
setStartAtZero(boolean startAtZero)
Deprecated.
|
void |
setValueFormatter(YAxisValueFormatter f)
Sets the formatter to be used for formatting the axis labels.
|
void |
setZeroLineColor(int color)
Sets the color of the zero line
|
void |
setZeroLineWidth(float width)
Sets the width of the zero line in dp
|
addLimitLine, disableGridDashedLine, enableGridDashedLine, getAxisLineColor, getAxisLineWidth, getAxisMaximum, getAxisMinimum, getGridColor, getGridDashPathEffect, getGridLineWidth, getLimitLines, isAxisMaxCustom, isAxisMinCustom, isDrawAxisLineEnabled, isDrawGridLinesEnabled, isDrawLabelsEnabled, isDrawLimitLinesBehindDataEnabled, isGridDashedLineEnabled, removeAllLimitLines, removeLimitLine, resetAxisMaxValue, resetAxisMinValue, setAxisLineColor, setAxisLineWidth, setAxisMaxValue, setAxisMinValue, setDrawAxisLine, setDrawGridLines, setDrawLabels, setDrawLimitLinesBehindData, setGridColor, setGridLineWidthgetTextColor, getTextSize, getTypeface, getXOffset, getYOffset, isEnabled, setEnabled, setTextColor, setTextSize, setTypeface, setXOffset, setYOffsetprotected YAxisValueFormatter mYAxisValueFormatter
public float[] mEntries
public int mEntryCount
public int mDecimals
protected boolean mShowOnlyMinMax
protected boolean mInverted
protected boolean mForceLabels
protected boolean mDrawZeroLine
protected int mZeroLineColor
protected float mZeroLineWidth
protected float mSpacePercentTop
protected float mSpacePercentBottom
protected float mMinWidth
protected float mMaxWidth
protected boolean mGranularityEnabled
protected float mGranularity
public YAxis()
public YAxis(YAxis.AxisDependency position)
public YAxis.AxisDependency getAxisDependency()
public float getMinWidth()
public void setMinWidth(float minWidth)
minWidth - public float getMaxWidth()
public void setMaxWidth(float maxWidth)
maxWidth - public boolean isGranularityEnabled()
public void setGranularityEnabled(boolean enabled)
enabled - public float getGranularity()
public void setGranularity(float granularity)
granularity - public YAxis.YAxisLabelPosition getLabelPosition()
public void setPosition(YAxis.YAxisLabelPosition pos)
pos - public boolean isDrawTopYLabelEntryEnabled()
public void setDrawTopYLabelEntry(boolean enabled)
enabled - public void setLabelCount(int count,
boolean force)
count - the number of y-axis labels that sould be displayedforce - if enabled, the set label count will be forced, meaning that the exact
specified count of labels will
be drawn and evenly distributed alongside the axis - this might cause labels
to have uneven valuespublic int getLabelCount()
public boolean isForceLabelsEnabled()
public void setShowOnlyMinMax(boolean enabled)
enabled - public boolean isShowOnlyMinMaxEnabled()
public void setInverted(boolean enabled)
enabled - public boolean isInverted()
@Deprecated public void setStartAtZero(boolean startAtZero)
startAtZero - public void setSpaceTop(float percent)
percent - public float getSpaceTop()
public void setSpaceBottom(float percent)
percent - public float getSpaceBottom()
public boolean isDrawZeroLineEnabled()
public void setDrawZeroLine(boolean mDrawZeroLine)
mDrawZeroLine - public int getZeroLineColor()
public void setZeroLineColor(int color)
color - public float getZeroLineWidth()
public void setZeroLineWidth(float width)
width - public float getRequiredWidthSpace(android.graphics.Paint p)
p - public float getRequiredHeightSpace(android.graphics.Paint p)
p - public java.lang.String getLongestLabel()
AxisBasegetLongestLabel in class AxisBasepublic java.lang.String getFormattedLabel(int index)
index - public void setValueFormatter(YAxisValueFormatter f)
f - public YAxisValueFormatter getValueFormatter()
public boolean needsDefaultFormatter()
public boolean needsOffset()
public void calculate(float dataMin,
float dataMax)
dataMin - the y-min value according to chart datadataMax - the y-max value according to chart data