-
public abstract class AxisBase extends ComponentBase
Base-class of all axes (previously called labels).
-
-
Field Summary
Fields Modifier and Type Field Description public Array<float>mEntriespublic Array<float>mCenteredEntriespublic intmEntryCountpublic intmDecimalspublic floatmAxisMaximumpublic floatmAxisMinimumpublic floatmAxisRangeprivate booleanshowSpecificPositionsprivate Array<float>specificPositions
-
Constructor Summary
Constructors Constructor Description AxisBase()default constructor
-
Method Summary
Modifier and Type Method Description voidsetShowSpecificPositions(boolean showSpecificPositions)if set to true, labels and lines will be displayed at the specific positions passed in via setSpecificPositions Array<float>getSpecificPositions()voidsetSpecificPositions(Array<float> specificPositions)intgetAxisMinLabels()The minumum number of labels on the axis voidsetAxisMinLabels(int labels)The minumum number of labels on the axis intgetAxisMaxLabels()The maximum number of labels on the axis voidsetAxisMaxLabels(int labels)The maximum number of labels on the axis voidsetDrawGridLines(boolean enabled)Set this to true to enable drawing the grid lines for this axis. booleanisDrawGridLinesEnabled()Returns true if drawing grid lines is enabled for this axis. voidsetDrawAxisLine(boolean enabled)Set this to true if the line alongside the axis should be drawn or not. booleanisDrawAxisLineEnabled()Returns true if the line alongside the axis should be drawn. voidsetCenterAxisLabels(boolean enabled)Centers the axis labels instead of drawing them at their original position.This is useful especially for grouped BarChart. booleanisCenterAxisLabelsEnabled()voidsetGridColor(int color)Sets the color of the grid lines for this axis (the horizontal linescoming from each label). intgetGridColor()Returns the color of the grid lines for this axis (the horizontal linescoming from each label). voidsetAxisLineWidth(float width)Sets the width of the border surrounding the chart in dp. floatgetAxisLineWidth()Returns the width of the axis line (line alongside the axis). voidsetGridLineWidth(float width)Sets the width of the grid lines that are drawn away from each axislabel. floatgetGridLineWidth()Returns the width of the grid lines that are drawn away from each axislabel. voidsetAxisLineColor(int color)Sets the color of the border surrounding the chart. intgetAxisLineColor()Returns the color of the axis line (line alongside the axis). voidsetDrawLabels(boolean enabled)Set this to true to enable drawing the labels of this axis (this will notaffect drawing the grid lines or axis lines). booleanisDrawLabelsEnabled()Returns true if drawing the labels is enabled for this axis. voidsetLabelCount(int count)Sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be awarethat this number is not fixed. voidsetLabelCount(int count, boolean force)sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be awarethat this number is notfixed (if force == false) and can only be approximated. booleanisForceLabelsEnabled()Returns true if focing the y-label count is enabled. intgetLabelCount()Returns the number of label entries the y-axis should have booleanisGranularityEnabled()voidsetGranularityEnabled(boolean enabled)Enabled/disable granularity control on axis value intervals. floatgetGranularity()voidsetGranularity(float granularity)Set a minimum interval for the axis when zooming in. voidaddLimitLine(LimitLine l)Adds a new LimitLine to this axis. voidaddLimitRange(LimitRange l)Adds a new LimitLine to this axis. voidremoveLimitLine(LimitLine l)Removes the specified LimitLine from the axis. voidremoveAllLimitLines()Removes all LimitLines from the axis. voidremoveLimitRange(LimitRange l)Removes the specified LimitRange from the axis. voidremoveAllLimitRanges()Removes all LimitLines from the axis. List<LimitLine>getLimitLines()Returns the LimitLines of this axis. List<LimitRange>getLimitRanges()Returns the LimitRanges of this axis. voidsetDrawLimitLinesBehindData(boolean enabled)If this is set to true, the LimitLines are drawn behind the actual data,otherwise on top. booleanisDrawLimitLinesBehindDataEnabled()voidsetDrawGridLinesBehindData(boolean enabled)If this is set to false, the grid lines are draw on top of the actual data,otherwise behind. booleanisDrawGridLinesBehindDataEnabled()StringgetLongestLabel()Returns the longest formatted label (in terms of characters), this axiscontains. StringgetLongestLabel(Paint p)Returns the longest formatted label (in terms of px), this axiscontains.If paint is null, then returns the longest formatted label (in terms of characters), this axis contains. StringgetFormattedLabel(int index)voidsetValueFormatter(IAxisValueFormatter f)Sets the formatter to be used for formatting the axis labels. IAxisValueFormattergetValueFormatter()Returns the formatter used for formatting the axis labels. voidenableGridDashedLine(float lineLength, float spaceLength, float phase)Enables the grid line to be drawn in dashed mode, e.g. voidsetGridDashedLine(DashPathEffect effect)Enables the grid line to be drawn in dashed mode, e.g. voiddisableGridDashedLine()Disables the grid line to be drawn in dashed mode. booleanisGridDashedLineEnabled()Returns true if the grid dashed-line effect is enabled, false if not. DashPathEffectgetGridDashPathEffect()returns the DashPathEffect that is set for grid line voidenableAxisLineDashedLine(float lineLength, float spaceLength, float phase)Enables the axis line to be drawn in dashed mode, e.g. voidsetAxisLineDashedLine(DashPathEffect effect)Enables the axis line to be drawn in dashed mode, e.g. voiddisableAxisLineDashedLine()Disables the axis line to be drawn in dashed mode. booleanisAxisLineDashedLineEnabled()Returns true if the axis dashed-line effect is enabled, false if not. DashPathEffectgetAxisLineDashPathEffect()returns the DashPathEffect that is set for axis line floatgetAxisMaximum()###### BELOW CODE RELATED TO CUSTOM AXIS VALUES ###### floatgetAxisMinimum()voidresetAxisMaximum()By calling this method, any custom maximum value that has been previously set is reseted,and the calculation isdone automatically. booleanisAxisMaxCustom()Returns true if the axis max value has been customized (and is not calculated automatically) voidresetAxisMinimum()By calling this method, any custom minimum value that has been previously set is reseted,and the calculation isdone automatically. booleanisAxisMinCustom()Returns true if the axis min value has been customized (and is not calculated automatically) voidsetAxisMinimum(float min)Set a custom minimum value for this axis. voidsetAxisMinValue(float min)Use setAxisMinimum(...) instead. voidsetAxisMaximum(float max)Set a custom maximum value for this axis. voidsetAxisMaxValue(float max)Use setAxisMaximum(...) instead. voidcalculate(float dataMin, float dataMax)Calculates the minimum / maximum and range values of the axis with the givenminimum and maximum values from the chart data. floatgetSpaceMin()Gets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum` voidsetSpaceMin(float mSpaceMin)Sets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum` floatgetSpaceMax()Gets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum` voidsetSpaceMax(float mSpaceMax)Sets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum` booleanisShowSpecificPositions()voidsetTextColor(int color)Sets the text color to use for the labels. -
Methods inherited from class com.github.mikephil.charting.components.ComponentBase
getTextColor, getTextSize, getTypeface, getXOffset, getYOffset, isEnabled, setEnabled, setTextColor, setTextSize, setTypeface, setXOffset, setYOffset -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
setShowSpecificPositions
void setShowSpecificPositions(boolean showSpecificPositions)
if set to true, labels and lines will be displayed at the specific positions passed in via setSpecificPositions
-
getSpecificPositions
Array<float> getSpecificPositions()
-
setSpecificPositions
void setSpecificPositions(Array<float> specificPositions)
-
getAxisMinLabels
int getAxisMinLabels()
The minumum number of labels on the axis
-
setAxisMinLabels
void setAxisMinLabels(int labels)
The minumum number of labels on the axis
-
getAxisMaxLabels
int getAxisMaxLabels()
The maximum number of labels on the axis
-
setAxisMaxLabels
void setAxisMaxLabels(int labels)
The maximum number of labels on the axis
-
setDrawGridLines
void setDrawGridLines(boolean enabled)
Set this to true to enable drawing the grid lines for this axis.
-
isDrawGridLinesEnabled
boolean isDrawGridLinesEnabled()
Returns true if drawing grid lines is enabled for this axis.
-
setDrawAxisLine
void setDrawAxisLine(boolean enabled)
Set this to true if the line alongside the axis should be drawn or not.
-
isDrawAxisLineEnabled
boolean isDrawAxisLineEnabled()
Returns true if the line alongside the axis should be drawn.
-
setCenterAxisLabels
void setCenterAxisLabels(boolean enabled)
Centers the axis labels instead of drawing them at their original position.This is useful especially for grouped BarChart.
-
isCenterAxisLabelsEnabled
boolean isCenterAxisLabelsEnabled()
-
setGridColor
void setGridColor(int color)
Sets the color of the grid lines for this axis (the horizontal linescoming from each label).
-
getGridColor
int getGridColor()
Returns the color of the grid lines for this axis (the horizontal linescoming from each label).
-
setAxisLineWidth
void setAxisLineWidth(float width)
Sets the width of the border surrounding the chart in dp.
-
getAxisLineWidth
float getAxisLineWidth()
Returns the width of the axis line (line alongside the axis).
-
setGridLineWidth
void setGridLineWidth(float width)
Sets the width of the grid lines that are drawn away from each axislabel.
-
getGridLineWidth
float getGridLineWidth()
Returns the width of the grid lines that are drawn away from each axislabel.
-
setAxisLineColor
void setAxisLineColor(int color)
Sets the color of the border surrounding the chart.
-
getAxisLineColor
int getAxisLineColor()
Returns the color of the axis line (line alongside the axis).
-
setDrawLabels
void setDrawLabels(boolean enabled)
Set this to true to enable drawing the labels of this axis (this will notaffect drawing the grid lines or axis lines).
-
isDrawLabelsEnabled
boolean isDrawLabelsEnabled()
Returns true if drawing the labels is enabled for this axis.
-
setLabelCount
void setLabelCount(int count)
Sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be awarethat this number is not fixed.
- Parameters:
count- the number of y-axis labels that should be displayed
-
setLabelCount
void setLabelCount(int count, boolean force)
sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be awarethat this number is notfixed (if force == false) and can only be approximated.
- Parameters:
count- the number of y-axis labels that should be displayedforce- if enabled, the set label count will be forced, meaning that the exactspecified count of labels willbe drawn and evenly distributed alongside the axis - this might cause labelsto have uneven values
-
isForceLabelsEnabled
boolean isForceLabelsEnabled()
Returns true if focing the y-label count is enabled. Default: false
-
getLabelCount
int getLabelCount()
Returns the number of label entries the y-axis should have
-
isGranularityEnabled
boolean isGranularityEnabled()
-
setGranularityEnabled
void setGranularityEnabled(boolean enabled)
Enabled/disable granularity control on axis value intervals. If enabled, the axisinterval is not allowed to go below a certain granularity. Default: false
-
getGranularity
float getGranularity()
-
setGranularity
void setGranularity(float granularity)
Set a minimum interval for the axis when zooming in. The axis is not allowed to go belowthat limit. This can be used to avoid label duplicating when zooming in.
-
addLimitLine
void addLimitLine(LimitLine l)
Adds a new LimitLine to this axis.
-
addLimitRange
void addLimitRange(LimitRange l)
Adds a new LimitLine to this axis.
-
removeLimitLine
void removeLimitLine(LimitLine l)
Removes the specified LimitLine from the axis.
-
removeAllLimitLines
void removeAllLimitLines()
Removes all LimitLines from the axis.
-
removeLimitRange
void removeLimitRange(LimitRange l)
Removes the specified LimitRange from the axis.
-
removeAllLimitRanges
void removeAllLimitRanges()
Removes all LimitLines from the axis.
-
getLimitLines
List<LimitLine> getLimitLines()
Returns the LimitLines of this axis.
-
getLimitRanges
List<LimitRange> getLimitRanges()
Returns the LimitRanges of this axis.
-
setDrawLimitLinesBehindData
void setDrawLimitLinesBehindData(boolean enabled)
If this is set to true, the LimitLines are drawn behind the actual data,otherwise on top. Default: false
-
isDrawLimitLinesBehindDataEnabled
boolean isDrawLimitLinesBehindDataEnabled()
-
setDrawGridLinesBehindData
void setDrawGridLinesBehindData(boolean enabled)
If this is set to false, the grid lines are draw on top of the actual data,otherwise behind. Default: true
-
isDrawGridLinesBehindDataEnabled
boolean isDrawGridLinesBehindDataEnabled()
-
getLongestLabel
String getLongestLabel()
Returns the longest formatted label (in terms of characters), this axiscontains.
-
getLongestLabel
String getLongestLabel(Paint p)
Returns the longest formatted label (in terms of px), this axiscontains.If paint is null, then returns the longest formatted label (in terms of characters), this axis contains.
-
getFormattedLabel
String getFormattedLabel(int index)
-
setValueFormatter
void setValueFormatter(IAxisValueFormatter f)
Sets the formatter to be used for formatting the axis labels. If no formatter is set, thechart willautomatically determine a reasonable formatting (concerning decimals) for all the valuesthat are drawn insidethe chart. Use chart.getDefaultValueFormatter() to use the formatter calculated by the chart.
-
getValueFormatter
IAxisValueFormatter getValueFormatter()
Returns the formatter used for formatting the axis labels.
-
enableGridDashedLine
void enableGridDashedLine(float lineLength, float spaceLength, float phase)
Enables the grid line to be drawn in dashed mode, e.g. like this"- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.Keep in mind that hardware acceleration boosts performance.
- Parameters:
lineLength- the length of the line piecesspaceLength- the length of space in between the piecesphase- offset, in degrees (normally, use 0)
-
setGridDashedLine
void setGridDashedLine(DashPathEffect effect)
Enables the grid line to be drawn in dashed mode, e.g. like this"- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.Keep in mind that hardware acceleration boosts performance.
- Parameters:
effect- the DashPathEffect
-
disableGridDashedLine
void disableGridDashedLine()
Disables the grid line to be drawn in dashed mode.
-
isGridDashedLineEnabled
boolean isGridDashedLineEnabled()
Returns true if the grid dashed-line effect is enabled, false if not.
-
getGridDashPathEffect
DashPathEffect getGridDashPathEffect()
returns the DashPathEffect that is set for grid line
-
enableAxisLineDashedLine
void enableAxisLineDashedLine(float lineLength, float spaceLength, float phase)
Enables the axis line to be drawn in dashed mode, e.g. like this"- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.Keep in mind that hardware acceleration boosts performance.
- Parameters:
lineLength- the length of the line piecesspaceLength- the length of space in between the piecesphase- offset, in degrees (normally, use 0)
-
setAxisLineDashedLine
void setAxisLineDashedLine(DashPathEffect effect)
Enables the axis line to be drawn in dashed mode, e.g. like this"- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.Keep in mind that hardware acceleration boosts performance.
- Parameters:
effect- the DashPathEffect
-
disableAxisLineDashedLine
void disableAxisLineDashedLine()
Disables the axis line to be drawn in dashed mode.
-
isAxisLineDashedLineEnabled
boolean isAxisLineDashedLineEnabled()
Returns true if the axis dashed-line effect is enabled, false if not.
-
getAxisLineDashPathEffect
DashPathEffect getAxisLineDashPathEffect()
returns the DashPathEffect that is set for axis line
-
getAxisMaximum
float getAxisMaximum()
###### BELOW CODE RELATED TO CUSTOM AXIS VALUES ######
-
getAxisMinimum
float getAxisMinimum()
-
resetAxisMaximum
void resetAxisMaximum()
By calling this method, any custom maximum value that has been previously set is reseted,and the calculation isdone automatically.
-
isAxisMaxCustom
boolean isAxisMaxCustom()
Returns true if the axis max value has been customized (and is not calculated automatically)
-
resetAxisMinimum
void resetAxisMinimum()
By calling this method, any custom minimum value that has been previously set is reseted,and the calculation isdone automatically.
-
isAxisMinCustom
boolean isAxisMinCustom()
Returns true if the axis min value has been customized (and is not calculated automatically)
-
setAxisMinimum
void setAxisMinimum(float min)
Set a custom minimum value for this axis. If set, this value will not be calculatedautomatically depending onthe provided data. Use resetAxisMinValue() to undo this. Do not forget to callsetStartAtZero(false) if you usethis method. Otherwise, the axis-minimum value will still be forced to 0.
-
setAxisMinValue
@Deprecated() void setAxisMinValue(float min)
Use setAxisMinimum(...) instead.
-
setAxisMaximum
void setAxisMaximum(float max)
Set a custom maximum value for this axis. If set, this value will not be calculatedautomatically depending onthe provided data. Use resetAxisMaxValue() to undo this.
-
setAxisMaxValue
@Deprecated() void setAxisMaxValue(float max)
Use setAxisMaximum(...) instead.
-
calculate
void calculate(float dataMin, float dataMax)
Calculates the minimum / maximum and range values of the axis with the givenminimum and maximum values from the chart data.
- Parameters:
dataMin- the min value according to chart datadataMax- the max value according to chart data
-
getSpaceMin
float getSpaceMin()
Gets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
-
setSpaceMin
void setSpaceMin(float mSpaceMin)
Sets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
-
getSpaceMax
float getSpaceMax()
Gets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum`
-
setSpaceMax
void setSpaceMax(float mSpaceMax)
Sets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum`
-
isShowSpecificPositions
boolean isShowSpecificPositions()
-
setTextColor
void setTextColor(int color)
Sets the text color to use for the labels. Make sure to usegetResources().getColor(...) when using a color from the resources.
-
-
-
-