本文整理匯總了Java中com.github.mikephil.charting.highlight.Highlight.getDataIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java Highlight.getDataIndex方法的具體用法?Java Highlight.getDataIndex怎麽用?Java Highlight.getDataIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.highlight.Highlight
的用法示例。
在下文中一共展示了Highlight.getDataIndex方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEntryForHighlight
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
List<BarLineScatterCandleBubbleData> dataObjects = getAllData();
if (highlight.getDataIndex() >= dataObjects.size())
return null;
ChartData data = dataObjects.get(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
else {
// The value of the highlighted entry could be NaN -
// if we are not interested in highlighting a specific value.
List<Entry> entries = data.getDataSetByIndex(highlight.getDataSetIndex())
.getEntriesForXValue(highlight.getX());
for (Entry entry : entries)
if (entry.getY() == highlight.getY() ||
Float.isNaN(highlight.getY()))
return entry;
return null;
}
}
示例2: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
Chart chart = mChart.get();
if (chart == null) return;
for (DataRenderer renderer : mRenderers) {
ChartData data = null;
if (renderer instanceof BarChartRenderer)
data = ((BarChartRenderer)renderer).mChart.getBarData();
else if (renderer instanceof LineChartRenderer)
data = ((LineChartRenderer)renderer).mChart.getLineData();
else if (renderer instanceof CandleStickChartRenderer)
data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
else if (renderer instanceof ScatterChartRenderer)
data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
else if (renderer instanceof BubbleChartRenderer)
data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();
int dataIndex = data == null ? -1
: ((CombinedData)chart.getData()).getAllData().indexOf(data);
mHighlightBuffer.clear();
for (Highlight h : indices) {
if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
mHighlightBuffer.add(h);
}
renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
}
}
示例3: getEntryForHighlight
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
List<ChartData> dataObjects = getAllData();
if (highlight.getDataIndex() >= dataObjects.size())
return null;
ChartData data = dataObjects.get(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
else {
// The value of the highlighted entry could be NaN -
// if we are not interested in highlighting a specific value.
List<?> entries = data.getDataSetByIndex(highlight.getDataSetIndex())
.getEntriesForXIndex(highlight.getXIndex());
for (Object entry : entries)
if (((Entry)entry).getVal() == highlight.getValue() ||
Float.isNaN(highlight.getValue()))
return (Entry)entry;
return null;
}
}
示例4: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
Chart chart = mChart.get();
if (chart == null) return;
for (DataRenderer renderer : mRenderers) {
ChartData data = null;
if (renderer instanceof BarChartRenderer)
data = ((BarChartRenderer)renderer).mChart.getBarData();
else if (renderer instanceof LineChartRenderer)
data = ((LineChartRenderer)renderer).mChart.getLineData();
else if (renderer instanceof CandleStickChartRenderer)
data = ((CandleStickChartRenderer)renderer).mChart.getCandleData();
else if (renderer instanceof ScatterChartRenderer)
data = ((ScatterChartRenderer)renderer).mChart.getScatterData();
else if (renderer instanceof BubbleChartRenderer)
data = ((BubbleChartRenderer)renderer).mChart.getBubbleData();
int dataIndex = data == null
? -1
: ((CombinedData)chart.getData()).getAllData().indexOf(data);
ArrayList<Highlight> dataIndices = new ArrayList<>();
for (Highlight h : indices) {
if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
dataIndices.add(h);
}
renderer.drawHighlighted(c, dataIndices.toArray(new Highlight[dataIndices.size()]));
}
}
示例5: getEntryForHighlight
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
List<BarLineScatterCandleBubbleData> dataObjects = getAllData();
if (highlight.getDataIndex() >= dataObjects.size())
return null;
ChartData data = dataObjects.get(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
else {
// The value of the highlighted entry could be NaN -
// if we are not interested in highlighting a specific value.
List<Entry> entries = data.getDataSetByIndex(highlight.getDataSetIndex())
.getEntriesForXPos(highlight.getX());
for (Entry entry : entries)
if (entry.getY() == highlight.getY() ||
Float.isNaN(highlight.getY()))
return entry;
return null;
}
}