public abstract class ChartData<T extends DataSet<? extends Entry>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<T> |
mDataSets
array that holds all DataSets the ChartData object represents
|
protected int |
mLastEnd
the last end value used for calcMinMax
|
protected int |
mLastStart
the last start value used for calcMinMax
|
protected float |
mLeftAxisMax |
protected float |
mLeftAxisMin |
protected float |
mRightAxisMax |
protected float |
mRightAxisMin |
protected java.util.List<java.lang.String> |
mXVals
holds all x-values the chart represents
|
protected float |
mYMax
maximum y-value in the y-value array across all axes
|
protected float |
mYMin
the minimum y-value in the y-value array across all axes
|
| Constructor and Description |
|---|
ChartData() |
ChartData(java.util.List<java.lang.String> xVals)
Constructor for only x-values.
|
ChartData(java.util.List<java.lang.String> xVals,
java.util.List<T> sets)
constructor for chart data
|
ChartData(java.lang.String[] xVals)
Constructor for only x-values.
|
ChartData(java.lang.String[] xVals,
java.util.List<T> sets)
constructor that takes string array instead of List string
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataSet(T d)
Adds a DataSet dynamically.
|
void |
addEntry(Entry e,
int dataSetIndex)
Adds an Entry to the DataSet at the specified index.
|
void |
addXValue(java.lang.String xVal)
Adds a new x-value to the chart data.
|
void |
calcMinMax(int start,
int end)
calc minimum and maximum y value over all datasets
|
protected void |
calcYValueCount()
Calculates the total number of y-values across all DataSets the ChartData
represents.
|
protected void |
calcYValueSum()
calculates the sum of all y-values in all datasets
|
void |
clearValues()
Clears this data object from all DataSets and removes all Entries.
|
boolean |
contains(Entry e)
Checks if this data object contains the specified Entry.
|
boolean |
contains(T dataSet)
Checks if this data object contains the specified DataSet.
|
static java.util.List<java.lang.String> |
generateXVals(int from,
int to)
Generates an x-values array filled with numbers in range specified by the
parameters.
|
float |
getAverage()
Returns the average value across all entries in this Data object
(all entries from the DataSets this data object holds)
|
int[] |
getColors()
Returns all colors used across all DataSet objects this object
represents.
|
T |
getDataSetByIndex(int index)
Returns the DataSet object at the given index.
|
T |
getDataSetByLabel(java.lang.String label,
boolean ignorecase)
Returns the DataSet object with the given label.
|
int |
getDataSetCount()
returns the number of LineDataSets this object contains
|
T |
getDataSetForEntry(Entry e)
Returns the DataSet that contains the provided Entry, or null, if no
DataSet contains this Entry.
|
protected int |
getDataSetIndexByLabel(java.util.List<T> dataSets,
java.lang.String label,
boolean ignorecase)
Retrieve the index of a DataSet with a specific label from the ChartData.
|
protected java.lang.String[] |
getDataSetLabels()
Returns the labels of all DataSets as a string array.
|
java.util.List<T> |
getDataSets()
Returns an the array of DataSets this object holds.
|
Entry |
getEntryForHighlight(Highlight highlight)
Get the Entry for a corresponding highlight object
|
T |
getFirstLeft()
Returns the first DataSet from the datasets-array that has it's dependency on the left axis.
|
T |
getFirstRight()
Returns the first DataSet from the datasets-array that has it's dependency on the right axis.
|
int |
getIndexOfDataSet(T dataSet)
Returns the index of the provided DataSet inside the DataSets array of
this data object.
|
float |
getXValAverageLength()
returns the average length (in characters) across all values in the
x-vals array
|
int |
getXValCount()
returns the total number of x-values this ChartData object represents
(the size of the x-values array)
|
java.util.List<java.lang.String> |
getXVals()
returns the x-values the chart represents
|
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 |
getYMin()
Returns the smallest y-value the data object contains.
|
float |
getYMin(YAxis.AxisDependency axis)
Returns the minimum y-value for the specified axis.
|
int |
getYValCount()
Returns the total number of y-values across all DataSet objects the this
object represents.
|
float |
getYValueSum()
Returns the total y-value sum across all DataSet objects the this object
represents.
|
protected void |
init()
performs all kinds of initialization calculations, such as min-max and
value count and sum
|
boolean |
isHighlightEnabled()
Returns true if highlighting of all underlying values is enabled, false
if not.
|
void |
notifyDataChanged()
Call this method to let the CartData know that the underlying data has
changed.
|
boolean |
removeDataSet(int index)
Removes the DataSet at the given index in the DataSet array from the data
object.
|
boolean |
removeDataSet(T d)
Removes the given DataSet from this data object.
|
boolean |
removeEntry(Entry e,
int dataSetIndex)
Removes the given Entry object from the DataSet at the specified index.
|
boolean |
removeEntry(int xIndex,
int dataSetIndex)
Removes the Entry object at the given xIndex from the DataSet at the
specified index.
|
void |
removeXValue(int index)
Removes the x-value at the specified index.
|
void |
setDrawValues(boolean enabled)
Enables / disables drawing values (value-text) for all DataSets this data
object contains.
|
void |
setHighlightEnabled(boolean enabled)
Enables / disables highlighting values for all DataSets this data object
contains.
|
void |
setValueFormatter(ValueFormatter f)
Sets a custom ValueFormatter for all DataSets this data object contains.
|
void |
setValueTextColor(int color)
Sets the color of the value-text (color in which the value-labels are
drawn) for all DataSets this data object contains.
|
void |
setValueTextSize(float size)
Sets the size (in dp) of the value-text for all DataSets this data object
contains.
|
void |
setValueTypeface(android.graphics.Typeface tf)
Sets the Typeface for all value-labels for all DataSets this data object
contains.
|
protected float mYMax
protected float mYMin
protected float mLeftAxisMax
protected float mLeftAxisMin
protected float mRightAxisMax
protected float mRightAxisMin
protected int mLastStart
protected int mLastEnd
protected java.util.List<java.lang.String> mXVals
public ChartData()
public ChartData(java.util.List<java.lang.String> xVals)
xVals - public ChartData(java.lang.String[] xVals)
xVals - public ChartData(java.util.List<java.lang.String> xVals,
java.util.List<T> sets)
xVals - The values describing the x-axis. Must be at least as long
as the highest xIndex in the Entry objects across all
DataSets.sets - the dataset arraypublic ChartData(java.lang.String[] xVals,
java.util.List<T> sets)
xVals - The values describing the x-axis. Must be at least as long
as the highest xIndex in the Entry objects across all
DataSets.sets - the dataset arrayprotected void init()
public void notifyDataChanged()
public void calcMinMax(int start,
int end)
protected void calcYValueSum()
protected void calcYValueCount()
public int getDataSetCount()
public float getAverage()
public float getYMin()
public float getYMin(YAxis.AxisDependency axis)
axis - public float getYMax()
public float getYMax(YAxis.AxisDependency axis)
axis - public float getXValAverageLength()
public float getYValueSum()
public int getYValCount()
public java.util.List<java.lang.String> getXVals()
public void addXValue(java.lang.String xVal)
xVal - public void removeXValue(int index)
index - public java.util.List<T> getDataSets()
protected int getDataSetIndexByLabel(java.util.List<T> dataSets, java.lang.String label, boolean ignorecase)
dataSets - the DataSet array to searchlabel - ignorecase - if true, the search is not case-sensitivepublic int getXValCount()
protected java.lang.String[] getDataSetLabels()
public Entry getEntryForHighlight(Highlight highlight)
highlight - public T getDataSetByLabel(java.lang.String label, boolean ignorecase)
label - ignorecase - public T getDataSetByIndex(int index)
index - public void addDataSet(T d)
d - public boolean removeDataSet(T d)
d - public boolean removeDataSet(int index)
index - public void addEntry(Entry e, int dataSetIndex)
e - dataSetIndex - public boolean removeEntry(Entry e, int dataSetIndex)
e - dataSetIndex - public boolean removeEntry(int xIndex,
int dataSetIndex)
xIndex - dataSetIndex - public T getDataSetForEntry(Entry e)
e - public int[] getColors()
public int getIndexOfDataSet(T dataSet)
dataSet - public T getFirstLeft()
public T getFirstRight()
public static java.util.List<java.lang.String> generateXVals(int from,
int to)
public void setValueFormatter(ValueFormatter f)
f - public void setValueTextColor(int color)
color - public void setValueTypeface(android.graphics.Typeface tf)
tf - public void setValueTextSize(float size)
size - public void setDrawValues(boolean enabled)
enabled - public void setHighlightEnabled(boolean enabled)
public boolean isHighlightEnabled()
public void clearValues()
public boolean contains(Entry e)
e - public boolean contains(T dataSet)
dataSet -