Package 

Class AxisBase


  • 
    public abstract class AxisBase
    extends ComponentBase
                        

    Base-class of all axes (previously called labels).

    • Constructor Detail

      • AxisBase

        AxisBase()
        default constructor
    • 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

      • 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.

      • 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 displayed
        force - 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

      • 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

      • 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.

      • setDrawLimitLinesBehindData

         void setDrawLimitLinesBehindData(boolean enabled)

        If this is set to true, the LimitLines are drawn behind the actual data,otherwise on top. Default: false

      • 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

      • 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.

      • 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.

      • 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 pieces
        spaceLength - the length of space in between the pieces
        phase - 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
      • isGridDashedLineEnabled

         boolean isGridDashedLineEnabled()

        Returns true if the grid dashed-line effect is enabled, false if not.

      • 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 pieces
        spaceLength - the length of space in between the pieces
        phase - 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
      • isAxisLineDashedLineEnabled

         boolean isAxisLineDashedLineEnabled()

        Returns true if the axis dashed-line effect is enabled, false if not.

      • getAxisMaximum

         float getAxisMaximum()

        ###### BELOW CODE RELATED TO CUSTOM AXIS VALUES ######

      • 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.

      • 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.

      • 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 data
        dataMax - 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`

      • 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.