Package 

Class ChartData

  • All Implemented Interfaces:
    java.io.Serializable

    
    public abstract class ChartData<T extends IDataSet<out Entry>>
     implements Serializable
                        

    Class that holds all relevant data that represents the chart. That involves at least one (or more) DataSets, and an array of x-values.

    • Constructor Summary

      Constructors 
      Constructor Description
      ChartData() Default constructor.
      ChartData(Array<T> dataSets) Constructor taking single or multiple DataSet objects.
      ChartData(List<T> sets) constructor for chart data
    • Method Summary

      Modifier and Type Method Description
      void notifyDataChanged() Call this method to let the ChartData know that the underlying data haschanged.
      void calcMinMaxY(float fromX, float toX) Calc minimum and maximum y-values over all DataSets.Tell DataSets to recalculate their min and max y-values, this is only needed for autoScaleMinMax.
      int getDataSetCount() returns the number of LineDataSets this object contains
      float getYMin() Returns the smallest y-value the data object contains.
      float getYMin(YAxis.AxisDependency axis) Returns the minimum y-value for the specified axis.
      float getYMax() Returns the greatest y-value the data object contains.
      float getYMax(YAxis.AxisDependency axis) Returns the maximum y-value for the specified axis.
      float getXMin() Returns the minimum x-value this data object contains.
      float getXMax() Returns the maximum x-value this data object contains.
      List<T> getDataSets() Returns all DataSet objects this ChartData object holds.
      Array<String> getDataSetLabels() Returns the labels of all DataSets as a string array.
      Entry getEntryForHighlight(Highlight highlight) Get the Entry for a corresponding highlight object
      T getDataSetByLabel(String label, boolean ignorecase) Returns the DataSet object with the given label.
      T getDataSetByIndex(int index)
      void addDataSet(T d) Adds a DataSet dynamically.
      boolean removeDataSet(T d) Removes the given DataSet from this data object.
      boolean removeDataSet(int index) Removes the DataSet at the given index in the DataSet array from the dataobject.
      void addEntry(Entry e, int dataSetIndex) Adds an Entry to the DataSet at the specified index.Entries are added to the end of the list.
      boolean removeEntry(Entry e, int dataSetIndex) Removes the given Entry object from the DataSet at the specified index.
      boolean removeEntry(float xValue, int dataSetIndex) Removes the Entry object closest to the given DataSet at thespecified index.
      T getDataSetForEntry(Entry e) Returns the DataSet that contains the provided Entry, or null, if noDataSet contains this Entry.
      Array<int> getColors() Returns all colors used across all DataSet objects this objectrepresents.
      int getIndexOfDataSet(T dataSet) Returns the index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist.
      T getFirstRight(List<T> sets) Returns the first DataSet from the datasets-array that has it's dependency on the right axis.Returns null if no DataSet with right dependency could be found.
      void setValueFormatter(IValueFormatter f) Sets a custom IValueFormatter for all DataSets this data object contains.
      void setValueTextColor(int color) Sets the color of the value-text (color in which the value-labels aredrawn) for all DataSets this data object contains.
      void setValueTextColors(List<Integer> colors) Sets the same list of value-colors for all DataSets thisdata object contains.
      void setValueTypeface(Typeface tf) Sets the Typeface for all value-labels for all DataSets this data objectcontains.
      void setValueTextSize(float size) Sets the size (in dp) of the value-text for all DataSets this data objectcontains.
      void setDrawValues(boolean enabled) Enables / disables drawing values (value-text) for all DataSets this dataobject contains.
      void setHighlightEnabled(boolean enabled) Enables / disables highlighting values for all DataSets this data objectcontains.
      boolean isHighlightEnabled() Returns true if highlighting of all underlying values is enabled, falseif not.
      void clearValues() Clears this data object from all DataSets and removes all Entries.
      boolean contains(T dataSet) Checks if this data object contains the specified DataSet.
      int getEntryCount() Returns the total entry count across all DataSet objects this data object contains.
      T getMaxEntryCountSet() Returns the DataSet object with the maximum number of entries or null if there are no DataSets.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChartData

        ChartData()
        Default constructor.
      • ChartData

        ChartData(Array<T> dataSets)
        Constructor taking single or multiple DataSet objects.
      • ChartData

        ChartData(List<T> sets)
        constructor for chart data
        Parameters:
        sets - the dataset array
    • Method Detail

      • notifyDataChanged

         void notifyDataChanged()

        Call this method to let the ChartData know that the underlying data haschanged. Calling this performs all necessary recalculations needed whenthe contained data has changed.

      • calcMinMaxY

         void calcMinMaxY(float fromX, float toX)

        Calc minimum and maximum y-values over all DataSets.Tell DataSets to recalculate their min and max y-values, this is only needed for autoScaleMinMax.

        Parameters:
        fromX - the x-value to start the calculation from
        toX - the x-value to which the calculation should be performed
      • getDataSetCount

         int getDataSetCount()

        returns the number of LineDataSets this object contains

      • getYMin

         float getYMin()

        Returns the smallest y-value the data object contains.

      • getYMax

         float getYMax()

        Returns the greatest y-value the data object contains.

      • getXMin

         float getXMin()

        Returns the minimum x-value this data object contains.

      • getXMax

         float getXMax()

        Returns the maximum x-value this data object contains.

      • getDataSets

         List<T> getDataSets()

        Returns all DataSet objects this ChartData object holds.

      • getDataSetByLabel

         T getDataSetByLabel(String label, boolean ignorecase)

        Returns the DataSet object with the given label. Search can be casesensitive or not. IMPORTANT: This method does calculations at runtime.Use with care in performance critical situations.

      • addDataSet

         void addDataSet(T d)

        Adds a DataSet dynamically.

      • removeDataSet

         boolean removeDataSet(T d)

        Removes the given DataSet from this data object. Also recalculates allminimum and maximum values. Returns true if a DataSet was removed, falseif no DataSet could be removed.

      • removeDataSet

         boolean removeDataSet(int index)

        Removes the DataSet at the given index in the DataSet array from the dataobject. Also recalculates all minimum and maximum values. Returns true ifa DataSet was removed, false if no DataSet could be removed.

      • addEntry

         void addEntry(Entry e, int dataSetIndex)

        Adds an Entry to the DataSet at the specified index.Entries are added to the end of the list.

      • removeEntry

         boolean removeEntry(Entry e, int dataSetIndex)

        Removes the given Entry object from the DataSet at the specified index.

      • removeEntry

         boolean removeEntry(float xValue, int dataSetIndex)

        Removes the Entry object closest to the given DataSet at thespecified index. Returns true if an Entry was removed, false if no Entrywas found that meets the specified requirements.

      • getDataSetForEntry

         T getDataSetForEntry(Entry e)

        Returns the DataSet that contains the provided Entry, or null, if noDataSet contains this Entry.

      • getColors

         Array<int> getColors()

        Returns all colors used across all DataSet objects this objectrepresents.

      • getIndexOfDataSet

         int getIndexOfDataSet(T dataSet)

        Returns the index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist.

      • getFirstRight

         T getFirstRight(List<T> sets)

        Returns the first DataSet from the datasets-array that has it's dependency on the right axis.Returns null if no DataSet with right dependency could be found.

      • setValueTextColor

         void setValueTextColor(int color)

        Sets the color of the value-text (color in which the value-labels aredrawn) for all DataSets this data object contains.

      • setValueTextColors

         void setValueTextColors(List<Integer> colors)

        Sets the same list of value-colors for all DataSets thisdata object contains.

      • setValueTypeface

         void setValueTypeface(Typeface tf)

        Sets the Typeface for all value-labels for all DataSets this data objectcontains.

      • setValueTextSize

         void setValueTextSize(float size)

        Sets the size (in dp) of the value-text for all DataSets this data objectcontains.

      • setDrawValues

         void setDrawValues(boolean enabled)

        Enables / disables drawing values (value-text) for all DataSets this dataobject contains.

      • setHighlightEnabled

         void setHighlightEnabled(boolean enabled)

        Enables / disables highlighting values for all DataSets this data objectcontains. If set to true, this means that values canbe highlighted programmatically or by touch gesture.

      • isHighlightEnabled

         boolean isHighlightEnabled()

        Returns true if highlighting of all underlying values is enabled, falseif not.

      • clearValues

         void clearValues()

        Clears this data object from all DataSets and removes all Entries. Don'tforget to invalidate the chart after this.

      • contains

         boolean contains(T dataSet)

        Checks if this data object contains the specified DataSet. Returns trueif so, false if not.

      • getEntryCount

         int getEntryCount()

        Returns the total entry count across all DataSet objects this data object contains.

      • getMaxEntryCountSet

         T getMaxEntryCountSet()

        Returns the DataSet object with the maximum number of entries or null if there are no DataSets.