Search in sources :

Example 1 with BarLineScatterCandleBubbleData

use of com.github.mikephil.charting.data.BarLineScatterCandleBubbleData 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 2 with BarLineScatterCandleBubbleData

use of com.github.mikephil.charting.data.BarLineScatterCandleBubbleData 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

BarLineScatterCandleBubbleData (com.github.mikephil.charting.data.BarLineScatterCandleBubbleData)2 IDataSet (com.github.mikephil.charting.interfaces.datasets.IDataSet)2 BarData (com.github.mikephil.charting.data.BarData)1 ChartData (com.github.mikephil.charting.data.ChartData)1