Package 

Class DataSet

  • All Implemented Interfaces:
    com.github.mikephil.charting.interfaces.datasets.IDataSet , java.io.Serializable

    
    public abstract class DataSet<T extends Entry>
    extends BaseDataSet<T> implements Serializable
                        

    The DataSet class represents one group or type of entries (Entry) in the Chart that belong together. It is designed to logically separate different groups of values inside the Chart (e.g. the values for a specific line in the LineChart, or the values of a specific group of bars in the BarChart).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public enum DataSet.Rounding

      Determines how to round DataSet index values for getEntryIndex DataSet.getEntryIndex()}when an exact x-index is not found.

    • Constructor Summary

      Constructors 
      Constructor Description
      DataSet(List<T> entries, String label) Creates a new DataSet object with the given values (entries) it represents.
    • Method Summary

      Modifier and Type Method Description
      void calcMinMax() Calculates the minimum and maximum x and y values (mXMin, mXMax, mYMin, mYMax).
      void calcMinMaxY(float fromX, float toX) Calculates the min and max y-values from the Entry closest to the given fromX to the Entry closest to the given toX value.This is only needed for the autoScaleMinMax feature.
      int getEntryCount() Returns the number of y-values this DataSet represents -> the size of the y-values array-> yvals.
      List<T> getValues() This method is deprecated.Use getEntries() instead.
      List<T> getEntries() Returns the array of entries that this DataSet represents.
      void setValues(List<T> values) This method is deprecated.Use setEntries(...) instead.
      void setEntries(List<T> entries) Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
      abstract DataSet<T> copy() Provides an exact copy of the DataSet this method is used on.
      String toString()
      String toSimpleString() Returns a simple string representation of the DataSet with the type andthe number of Entries.
      float getYMin() returns the minimum y-value this DataSet holds
      float getYMax() returns the maximum y-value this DataSet holds
      float getXMin() returns the minimum x-value this DataSet holds
      float getXMax() returns the maximum x-value this DataSet holds
      void addEntryOrdered(T e) Adds an Entry to the DataSet dynamically.Entries are added to their appropriate index in the values array respective to their x-position.This will also recalculate the current minimum and maximumvalues of the DataSet and the value-sum.
      void clear() Removes all values from this DataSet and does all necessary recalculations.
      boolean addEntry(T e) Adds an Entry to the DataSet dynamically.Entries are added to the end of the list.This will also recalculate the current minimum and maximumvalues of the DataSet and the value-sum.
      boolean removeEntry(T e) Removes an Entry from the DataSets entries array.
      int getEntryIndex(Entry e) Returns the position of the provided entry in the DataSets Entry array.Returns -1 if doesn't exist.
      T getEntryForXValue(float xValue, float closestToY, DataSet.Rounding rounding) Returns the first Entry object found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value according to the rounding.INFORMATION: This method does calculations at runtime.
      T getEntryForXValue(float xValue, float closestToY) Returns the first Entry object found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value.INFORMATION: This method does calculations at runtime.
      T getEntryForIndex(int index) Returns the Entry object found at the given index (NOT xIndex) in the values array.
      int getEntryIndex(float xValue, float closestToY, DataSet.Rounding rounding) Returns the first Entry index found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value according to the rounding.INFORMATION: This method does calculations at runtime.
      List<T> getEntriesForXValue(float xValue) Returns all Entry objects found at the given x-value with binarysearch.
      • Methods inherited from class com.github.mikephil.charting.data.BaseDataSet

        addColor, contains, getAxisDependency, getColor, getColors, getForm, getFormLineDashEffect, getFormLineWidth, getFormSize, getIconsOffset, getIndexInEntries, getLabel, getValueColors, getValueFormatter, getValueTextColor, getValueTextSize, getValueTypeface, isDrawIconsEnabled, isDrawValuesEnabled, isHighlightEnabled, isVisible, needsFormatter, notifyDataSetChanged, removeEntry, removeEntryByXValue, removeFirst, removeLast, resetColors, setAxisDependency, setColor, setColors, setDrawIcons, setDrawValues, setForm, setFormLineDashEffect, setFormLineWidth, setFormSize, setHighlightEnabled, setIconsOffset, setLabel, setValueFormatter, setValueTextColor, setValueTextColors, setValueTextSize, setValueTypeface, setVisible
      • Methods inherited from class com.github.mikephil.charting.interfaces.datasets.IDataSet

        contains, getAxisDependency, getColor, getColor, getColors, getEntryForXValue, getEntryIndex, getEntryIndex, getForm, getFormLineDashEffect, getFormLineWidth, getFormSize, getIconsOffset, getIndexInEntries, getLabel, getValueFormatter, getValueTextColor, getValueTextColor, getValueTextSize, getValueTypeface, isDrawIconsEnabled, isDrawValuesEnabled, isHighlightEnabled, isVisible, needsFormatter, removeEntry, removeEntryByXValue, removeFirst, removeLast, setAxisDependency, setDrawIcons, setDrawValues, setHighlightEnabled, setIconsOffset, setLabel, setValueFormatter, setValueTextColor, setValueTextColors, setValueTextSize, setValueTypeface, setVisible
      • Methods inherited from class java.lang.Object

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

      • DataSet

        DataSet(List<T> entries, String label)
        Creates a new DataSet object with the given values (entries) it represents.
    • Method Detail

      • calcMinMax

         void calcMinMax()

        Calculates the minimum and maximum x and y values (mXMin, mXMax, mYMin, mYMax).

      • calcMinMaxY

         void calcMinMaxY(float fromX, float toX)

        Calculates the min and max y-values from the Entry closest to the given fromX to the Entry closest to the given toX value.This is only needed for the autoScaleMinMax feature.

      • getEntryCount

         int getEntryCount()

        Returns the number of y-values this DataSet represents -> the size of the y-values array-> yvals.size()

      • getEntries

         List<T> getEntries()

        Returns the array of entries that this DataSet represents.

      • setEntries

         void setEntries(List<T> entries)

        Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()

      • copy

         abstract DataSet<T> copy()

        Provides an exact copy of the DataSet this method is used on.

      • toSimpleString

         String toSimpleString()

        Returns a simple string representation of the DataSet with the type andthe number of Entries.

      • getYMin

         float getYMin()

        returns the minimum y-value this DataSet holds

      • getYMax

         float getYMax()

        returns the maximum y-value this DataSet holds

      • getXMin

         float getXMin()

        returns the minimum x-value this DataSet holds

      • getXMax

         float getXMax()

        returns the maximum x-value this DataSet holds

      • addEntryOrdered

         void addEntryOrdered(T e)

        Adds an Entry to the DataSet dynamically.Entries are added to their appropriate index in the values array respective to their x-position.This will also recalculate the current minimum and maximumvalues of the DataSet and the value-sum.

      • clear

         void clear()

        Removes all values from this DataSet and does all necessary recalculations.

      • addEntry

         boolean addEntry(T e)

        Adds an Entry to the DataSet dynamically.Entries are added to the end of the list.This will also recalculate the current minimum and maximumvalues of the DataSet and the value-sum.

      • removeEntry

         boolean removeEntry(T e)

        Removes an Entry from the DataSets entries array. This will alsorecalculate the current minimum and maximum values of the DataSet and thevalue-sum. Returns true if an Entry was removed, false if no Entry couldbe removed.

      • getEntryIndex

         int getEntryIndex(Entry e)

        Returns the position of the provided entry in the DataSets Entry array.Returns -1 if doesn't exist.

      • getEntryForXValue

         T getEntryForXValue(float xValue, float closestToY, DataSet.Rounding rounding)

        Returns the first Entry object found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value according to the rounding.INFORMATION: This method does calculations at runtime. Donot over-use in performance critical situations.

        Parameters:
        xValue - the x-value
        closestToY - If there are multiple y-values for the specified x-value,
        rounding - determine whether to round up/down/closestif there is no Entry matching the provided x-value
      • getEntryForXValue

         T getEntryForXValue(float xValue, float closestToY)

        Returns the first Entry object found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value.INFORMATION: This method does calculations at runtime. Donot over-use in performance critical situations.

        Parameters:
        xValue - the x-value
        closestToY - If there are multiple y-values for the specified x-value,
      • getEntryForIndex

         T getEntryForIndex(int index)

        Returns the Entry object found at the given index (NOT xIndex) in the values array.

      • getEntryIndex

         int getEntryIndex(float xValue, float closestToY, DataSet.Rounding rounding)

        Returns the first Entry index found at the given x-value with binarysearch.If the no Entry at the specified x-value is found, this methodreturns the Entry at the closest x-value according to the rounding.INFORMATION: This method does calculations at runtime. Donot over-use in performance critical situations.

        Parameters:
        xValue - the x-value
        closestToY - If there are multiple y-values for the specified x-value,
        rounding - determine whether to round up/down/closestif there is no Entry matching the provided x-value
      • getEntriesForXValue

         List<T> getEntriesForXValue(float xValue)

        Returns all Entry objects found at the given x-value with binarysearch. An empty array if no Entry object at that x-value.INFORMATION: This method does calculations at runtime. Donot over-use in performance critical situations.