本文整理了Java中com.github.mikephil.charting.highlight.Highlight.getY()
方法的一些代码示例,展示了Highlight.getY()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Highlight.getY()
方法的具体详情如下:
包路径:com.github.mikephil.charting.highlight.Highlight
类名称:Highlight
方法名:getY
[英]returns the y-value of the highlighted value
[中]返回高亮显示值的y值
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {
List<Highlight> highlights = getHighlightsAtIndex(index);
float distanceToCenter = mChart.distanceToCenter(x, y) / mChart.getFactor();
Highlight closest = null;
float distance = Float.MAX_VALUE;
for (int i = 0; i < highlights.size(); i++) {
Highlight high = highlights.get(i);
float cdistance = Math.abs(high.getY() - distanceToCenter);
if (cdistance < distance) {
closest = high;
distance = cdistance;
}
}
return closest;
}
/**
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
* point
* inside the CombinedChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
} else {
Highlight h = getHighlighter().getHighlight(x, y);
if (h == null || !isHighlightFullBarEnabled()) return h;
// For isHighlightFullBarEnabled, remove stackIndex
return new Highlight(h.getX(), h.getY(),
h.getXPx(), h.getYPx(),
h.getDataSetIndex(), -1, h.getAxis());
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Returns the Highlight object (contains x-index and DataSet index) of the selected value at the given touch
* point
* inside the BarChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
} else {
Highlight h = getHighlighter().getHighlight(x, y);
if (h == null || !isHighlightFullBarEnabled()) return h;
// For isHighlightFullBarEnabled, remove stackIndex
return new Highlight(h.getX(), h.getY(),
h.getXPx(), h.getYPx(),
h.getDataSetIndex(), -1, h.getAxis());
}
}
代码示例来源: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: PhilJay/MPAndroidChart
continue;
final BubbleEntry entry = set.getEntryForXValue(high.getX(), high.getY());
if (entry.getY() != high.getY())
continue;
代码示例来源:origin: PhilJay/MPAndroidChart
continue;
BarEntry e = set.getEntryForXValue(high.getX(), high.getY());
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
LineData lineData = mChart.getLineData();
for (Highlight high : indices) {
ILineDataSet set = lineData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
ScatterData scatterData = mChart.getScatterData();
for (Highlight high : indices) {
IScatterDataSet set = scatterData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
final Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
CandleData candleData = mChart.getCandleData();
for (Highlight high : indices) {
ICandleDataSet set = candleData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
CandleEntry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
float lowValue = e.getLow() * mAnimator.getPhaseY();
float highValue = e.getHigh() * mAnimator.getPhaseY();
float y = (lowValue + highValue) / 2f;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), y);
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {
List<Highlight> highlights = getHighlightsAtIndex(index);
float distanceToCenter = mChart.distanceToCenter(x, y) / mChart.getFactor();
Highlight closest = null;
float distance = Float.MAX_VALUE;
for (int i = 0; i < highlights.size(); i++) {
Highlight high = highlights.get(i);
float cdistance = Math.abs(high.getY() - distanceToCenter);
if (cdistance < distance) {
closest = high;
distance = cdistance;
}
}
return closest;
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {
List<Highlight> highlights = getHighlightsAtIndex(index);
float distanceToCenter = mChart.distanceToCenter(x, y) / mChart.getFactor();
Highlight closest = null;
float distance = Float.MAX_VALUE;
for (int i = 0; i < highlights.size(); i++) {
Highlight high = highlights.get(i);
float cdistance = Math.abs(high.getY() - distanceToCenter);
if (cdistance < distance) {
closest = high;
distance = cdistance;
}
}
return closest;
}
/**
代码示例来源:origin: xiaolongonly/Ticket-Analysis
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {
List<Highlight> highlights = getHighlightsAtIndex(index);
float distanceToCenter = mChart.distanceToCenter(x, y) / mChart.getFactor();
Highlight closest = null;
float distance = Float.MAX_VALUE;
for (int i = 0; i < highlights.size(); i++) {
Highlight high = highlights.get(i);
float cdistance = Math.abs(high.getY() - distanceToCenter);
if (cdistance < distance) {
closest = high;
distance = cdistance;
}
}
return closest;
}
/**
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
代码示例来源:origin: WenWangAndroid/ChartManager
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size()) {
return null;
} else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
代码示例来源:origin: xiaolongonly/Ticket-Analysis
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
LineData lineData = mChart.getLineData();
for (Highlight high : indices) {
ILineDataSet set = lineData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
ScatterData scatterData = mChart.getScatterData();
for (Highlight high : indices) {
IScatterDataSet set = scatterData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
final Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
}
代码示例来源:origin: WenWangAndroid/ChartManager
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
LineData lineData = mChart.getLineData();
for (Highlight high : indices) {
ILineDataSet set = lineData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
Entry e = set.getEntryForXValue(high.getX(), high.getY());
if (!isInBoundsX(e, set))
continue;
MPPointD pix = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY() * mAnimator
.getPhaseY());
high.setDraw((float) pix.x, (float) pix.y);
// draw the lines
drawHighlightLines(c, (float) pix.x, (float) pix.y, set);
}
}
内容来源于网络,如有侵权,请联系作者删除!