Search in sources :

Example 6 with IDataSet

use of com.github.mikephil.charting.interfaces.datasets.IDataSet in project MPAndroidChart by PhilJay.

the class ChartData method addEntry.

/**
     * Adds an Entry to the DataSet at the specified index.
     * Entries are added to the end of the list.
     *
     * @param e
     * @param dataSetIndex
     */
public void addEntry(Entry e, int dataSetIndex) {
    if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {
        IDataSet set = mDataSets.get(dataSetIndex);
        // add the entry to the dataset
        if (!set.addEntry(e))
            return;
        calcMinMax(e, set.getAxisDependency());
    } else {
        Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low.");
    }
}
Also used : IDataSet(com.github.mikephil.charting.interfaces.datasets.IDataSet)

Example 7 with IDataSet

use of com.github.mikephil.charting.interfaces.datasets.IDataSet in project MPAndroidChart by PhilJay.

the class ChartHighlighter method getHighlightsAtXValue.

/**
     * Returns a list of Highlight objects representing the entries closest to the given xVal.
     * The returned list contains two objects per DataSet (closest rounding up, closest rounding down).
     *
     * @param xVal the transformed x-value of the x-touch position
     * @param x    touch position
     * @param y    touch position
     * @return
     */
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
    mHighlightBuffer.clear();
    BarLineScatterCandleBubbleData data = getData();
    if (data == null)
        return mHighlightBuffer;
    for (int i = 0, dataSetCount = data.getDataSetCount(); i < dataSetCount; i++) {
        IDataSet dataSet = data.getDataSetByIndex(i);
        // don't include DataSets that cannot be highlighted
        if (!dataSet.isHighlightEnabled())
            continue;
        mHighlightBuffer.addAll(buildHighlights(dataSet, i, xVal, DataSet.Rounding.CLOSEST));
    }
    return mHighlightBuffer;
}
Also used : BarLineScatterCandleBubbleData(com.github.mikephil.charting.data.BarLineScatterCandleBubbleData) IDataSet(com.github.mikephil.charting.interfaces.datasets.IDataSet)

Example 8 with IDataSet

use of com.github.mikephil.charting.interfaces.datasets.IDataSet in project MPAndroidChart by PhilJay.

the class CombinedHighlighter method getHighlightsAtXValue.

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
    mHighlightBuffer.clear();
    List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
    for (int i = 0; i < dataObjects.size(); i++) {
        ChartData dataObject = dataObjects.get(i);
        // in case of BarData, let the BarHighlighter take over
        if (barHighlighter != null && dataObject instanceof BarData) {
            Highlight high = barHighlighter.getHighlight(x, y);
            if (high != null) {
                high.setDataIndex(i);
                mHighlightBuffer.add(high);
            }
        } else {
            for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
                IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
                // don't include datasets that cannot be highlighted
                if (!dataSet.isHighlightEnabled())
                    continue;
                List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
                for (Highlight high : highs) {
                    high.setDataIndex(i);
                    mHighlightBuffer.add(high);
                }
            }
        }
    }
    return mHighlightBuffer;
}
Also used : ChartData(com.github.mikephil.charting.data.ChartData) BarData(com.github.mikephil.charting.data.BarData) BarLineScatterCandleBubbleData(com.github.mikephil.charting.data.BarLineScatterCandleBubbleData) IDataSet(com.github.mikephil.charting.interfaces.datasets.IDataSet)

Aggregations

IDataSet (com.github.mikephil.charting.interfaces.datasets.IDataSet)8 Paint (android.graphics.Paint)2 BarLineScatterCandleBubbleData (com.github.mikephil.charting.data.BarLineScatterCandleBubbleData)2 SuppressLint (android.annotation.SuppressLint)1 Typeface (android.graphics.Typeface)1 LegendEntry (com.github.mikephil.charting.components.LegendEntry)1 BarData (com.github.mikephil.charting.data.BarData)1 ChartData (com.github.mikephil.charting.data.ChartData)1 Entry (com.github.mikephil.charting.data.Entry)1 Highlight (com.github.mikephil.charting.highlight.Highlight)1 IBarDataSet (com.github.mikephil.charting.interfaces.datasets.IBarDataSet)1 ICandleDataSet (com.github.mikephil.charting.interfaces.datasets.ICandleDataSet)1 IPieDataSet (com.github.mikephil.charting.interfaces.datasets.IPieDataSet)1