本文整理了Java中com.github.mikephil.charting.highlight.Highlight.getX()
方法的一些代码示例,展示了Highlight.getX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Highlight.getX()
方法的具体详情如下:
包路径:com.github.mikephil.charting.highlight.Highlight
类名称:Highlight
方法名:getX
[英]returns the x-value of the highlighted value
[中]返回高亮显示值的x值
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Checks if the given index is set to be highlighted.
*
* @param index
* @return
*/
public boolean needsHighlight(int index) {
// no highlight
if (!valuesToHighlight())
return false;
for (int i = 0; i < mIndicesToHighlight.length; i++)
// check if the xvalue for the given dataset needs highlight
if ((int) mIndicesToHighlight[i].getX() == index)
return true;
return false;
}
代码示例来源: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
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
Log.i("VAL SELECTED",
"Value: " + e.getY() + ", index: " + h.getX()
+ ", DataSet index: " + h.getDataSetIndex());
}
代码示例来源: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
@Override
public Entry getEntryForHighlight(Highlight highlight) {
return getDataSet().getEntryForIndex((int) highlight.getX());
}
代码示例来源: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
@Override
public Entry getEntryForHighlight(Highlight highlight) {
return getDataSetByIndex(highlight.getDataSetIndex()).getEntryForIndex((int) highlight.getX());
}
}
代码示例来源:origin: PhilJay/MPAndroidChart
@Override
protected float[] getMarkerPosition(Highlight highlight) {
MPPointF center = getCenterCircleBox();
float r = getRadius();
float off = r / 10f * 3.6f;
if (isDrawHoleEnabled()) {
off = (r - (r / 100f * getHoleRadius())) / 2f;
}
r -= off; // offset to keep things inside the chart
float rotationAngle = getRotationAngle();
int entryIndex = (int) highlight.getX();
// offset needed to center the drawn text in the slice
float offset = mDrawAngles[entryIndex] / 2;
// calculate the text position
float x = (float) (r
* Math.cos(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
* mAnimator.getPhaseY())) + center.x);
float y = (float) (r
* Math.sin(Math.toRadians((rotationAngle + mAbsoluteAngles[entryIndex] - offset)
* mAnimator.getPhaseY())) + center.y);
MPPointF.recycleInstance(center);
return new float[]{x, y};
}
代码示例来源:origin: PhilJay/MPAndroidChart
int index = (int) indices[i].getX();
代码示例来源: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());
代码示例来源:origin: PhilJay/MPAndroidChart
continue;
BarEntry e = set.getEntryForXValue(high.getX(), high.getY());
代码示例来源:origin: PhilJay/MPAndroidChart
continue;
RadarEntry e = set.getEntryForIndex((int) high.getX());
sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
pOut);
代码示例来源: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
int stackIndex = getClosestStackIndex(ranges, yVal);
MPPointD pixels = mChart.getTransformer(set.getAxisDependency()).getPixelForValues(high.getX(), ranges[stackIndex].to);
代码示例来源: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: zhuanghongji/mp-android-chart
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
Log.i("VAL SELECTED",
"Value: " + e.getY() + ", index: " + h.getX()
+ ", DataSet index: " + h.getDataSetIndex());
}
代码示例来源:origin: com.github.PhilJay/MPAndroidChart
@Override
public Entry getEntryForHighlight(Highlight highlight) {
return getDataSetByIndex(highlight.getDataSetIndex()).getEntryForIndex((int) highlight.getX());
}
}
代码示例来源:origin: WallaceXiao/StockChart-MPAndroidChart
@Override
public void onValueSelected(Entry e, Highlight h) {
lineChart.highlightValue(h);
barChart.highlightValue(new Highlight(h.getX(), h.getDataSetIndex(), -1));
if (mHighlightValueSelectedListener != null) {
mHighlightValueSelectedListener.onDayHighlightValueListener(mData, e.getXIndex(), true);
}
}
内容来源于网络,如有侵权,请联系作者删除!