本文整理了Java中com.github.mikephil.charting.highlight.Highlight.getDataIndex()
方法的一些代码示例,展示了Highlight.getDataIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Highlight.getDataIndex()
方法的具体详情如下:
包路径:com.github.mikephil.charting.highlight.Highlight
类名称:Highlight
方法名:getDataIndex
[英]the index of the data object - in case it refers to more than one
[中]数据对象的索引-如果它引用多个
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Get dataset for highlight
*
* @param highlight current highlight
* @return dataset related to highlight
*/
public IBarLineScatterCandleBubbleDataSet<? extends Entry> getDataSetByHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
BarLineScatterCandleBubbleData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
return (IBarLineScatterCandleBubbleDataSet<? extends Entry>)
data.getDataSets().get(highlight.getDataSetIndex());
}
代码示例来源:origin: PhilJay/MPAndroidChart
@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()]));
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
ChartData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
// 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;
}
代码示例来源:origin: WenWangAndroid/ChartManager
/**
* Get dataset for highlight
*
* @param highlight current highlight
* @return dataset related to highlight
*/
public IBarLineScatterCandleBubbleDataSet<? extends Entry> getDataSetByHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
BarLineScatterCandleBubbleData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
return (IBarLineScatterCandleBubbleDataSet<? extends Entry>)
data.getDataSets().get(highlight.getDataSetIndex());
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
/**
* Get dataset for highlight
*
* @param highlight current highlight
* @return dataset related to highlight
*/
public IBarLineScatterCandleBubbleDataSet<? extends Entry> getDataSetByHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
BarLineScatterCandleBubbleData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
return (IBarLineScatterCandleBubbleDataSet<? extends Entry>)
data.getDataSets().get(highlight.getDataSetIndex());
}
代码示例来源:origin: xiaolongonly/Ticket-Analysis
/**
* Get dataset for highlight
*
* @param highlight current highlight
* @return dataset related to highlight
*/
public IBarLineScatterCandleBubbleDataSet<? extends Entry> getDataSetByHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
BarLineScatterCandleBubbleData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
return (IBarLineScatterCandleBubbleDataSet<? extends Entry>)
data.getDataSets().get(highlight.getDataSetIndex());
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
@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()]));
}
}
代码示例来源:origin: xiaolongonly/Ticket-Analysis
@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()]));
}
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
@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()]));
}
}
代码示例来源:origin: WenWangAndroid/ChartManager
@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()]));
}
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
if (highlight.getDataIndex() >= dataObjects.size()) {
return null;
if (highlight.getDataIndex() < 0) {
return null;
ChartData data = dataObjects.get(highlight.getDataIndex());
代码示例来源:origin: WenWangAndroid/ChartManager
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
ChartData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
// 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;
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
ChartData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
// 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;
}
代码示例来源:origin: xiaolongonly/Ticket-Analysis
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
@Override
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataIndex() >= getAllData().size())
return null;
ChartData data = getDataByIndex(highlight.getDataIndex());
if (highlight.getDataSetIndex() >= data.getDataSetCount())
return null;
// 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;
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
@Override
public void onValueSelected(Entry e, Highlight h) {
candleChart.highlightValue(h);
if (barChart.getData().getBarData().getDataSets().size() != 0) {
Highlight highlight = new Highlight(h.getX(), h.getDataSetIndex(), h.getStackIndex());
highlight.setDataIndex(h.getDataIndex());
barChart.highlightValues(new Highlight[]{highlight});
} else {
Highlight highlight = new Highlight(h.getX(), 2, h.getStackIndex());
highlight.setDataIndex(0);
barChart.highlightValues(new Highlight[]{highlight});
}
updateText(e.getXIndex(), true);
}
内容来源于网络,如有侵权,请联系作者删除!