-
- 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.
-
-
Method Summary
Modifier and Type Method Description voidnotifyDataChanged()Call this method to let the ChartData know that the underlying data haschanged. voidcalcMinMaxY(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. intgetDataSetCount()returns the number of LineDataSets this object contains floatgetYMin()Returns the smallest y-value the data object contains. floatgetYMin(YAxis.AxisDependency axis)Returns the minimum y-value for the specified axis. floatgetYMax()Returns the greatest y-value the data object contains. floatgetYMax(YAxis.AxisDependency axis)Returns the maximum y-value for the specified axis. floatgetXMin()Returns the minimum x-value this data object contains. floatgetXMax()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. EntrygetEntryForHighlight(Highlight highlight)Get the Entry for a corresponding highlight object TgetDataSetByLabel(String label, boolean ignorecase)Returns the DataSet object with the given label. TgetDataSetByIndex(int index)voidaddDataSet(T d)Adds a DataSet dynamically. booleanremoveDataSet(T d)Removes the given DataSet from this data object. booleanremoveDataSet(int index)Removes the DataSet at the given index in the DataSet array from the dataobject. voidaddEntry(Entry e, int dataSetIndex)Adds an Entry to the DataSet at the specified index.Entries are added to the end of the list. booleanremoveEntry(Entry e, int dataSetIndex)Removes the given Entry object from the DataSet at the specified index. booleanremoveEntry(float xValue, int dataSetIndex)Removes the Entry object closest to the given DataSet at thespecified index. TgetDataSetForEntry(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. intgetIndexOfDataSet(T dataSet)Returns the index of the provided DataSet in the DataSet array of this data object, or -1 if it does not exist. TgetFirstRight(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. voidsetValueFormatter(IValueFormatter f)Sets a custom IValueFormatter for all DataSets this data object contains. voidsetValueTextColor(int color)Sets the color of the value-text (color in which the value-labels aredrawn) for all DataSets this data object contains. voidsetValueTextColors(List<Integer> colors)Sets the same list of value-colors for all DataSets thisdata object contains. voidsetValueTypeface(Typeface tf)Sets the Typeface for all value-labels for all DataSets this data objectcontains. voidsetValueTextSize(float size)Sets the size (in dp) of the value-text for all DataSets this data objectcontains. voidsetDrawValues(boolean enabled)Enables / disables drawing values (value-text) for all DataSets this dataobject contains. voidsetHighlightEnabled(boolean enabled)Enables / disables highlighting values for all DataSets this data objectcontains. booleanisHighlightEnabled()Returns true if highlighting of all underlying values is enabled, falseif not. voidclearValues()Clears this data object from all DataSets and removes all Entries. booleancontains(T dataSet)Checks if this data object contains the specified DataSet. intgetEntryCount()Returns the total entry count across all DataSet objects this data object contains. TgetMaxEntryCountSet()Returns the DataSet object with the maximum number of entries or null if there are no DataSets. -
-
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 fromtoX- 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.
-
getYMin
float getYMin(YAxis.AxisDependency axis)
Returns the minimum y-value for the specified axis.
-
getYMax
float getYMax()
Returns the greatest y-value the data object contains.
-
getYMax
float getYMax(YAxis.AxisDependency axis)
Returns the maximum y-value for the specified axis.
-
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.
-
getDataSetLabels
Array<String> getDataSetLabels()
Returns the labels of all DataSets as a string array.
-
getEntryForHighlight
Entry getEntryForHighlight(Highlight highlight)
Get the Entry for a corresponding highlight object
-
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.
-
getDataSetByIndex
T getDataSetByIndex(int index)
-
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.
-
setValueFormatter
void setValueFormatter(IValueFormatter f)
Sets a custom IValueFormatter for all DataSets this data object contains.
-
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.
-
-
-
-