本文整理匯總了Java中com.github.mikephil.charting.highlight.Highlight.getDataSetIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java Highlight.getDataSetIndex方法的具體用法?Java Highlight.getDataSetIndex怎麽用?Java Highlight.getDataSetIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.highlight.Highlight
的用法示例。
在下文中一共展示了Highlight.getDataSetIndex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHighlightByTouchPoint
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* 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());
}
}
示例2: getHighlightByTouchPoint
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* 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());
}
}
示例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
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
// The value of the highlighted entry could be NaN -
// if we are not interested in highlighting a specific value.
List<?> entries = mDataSets.get(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: 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
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
}
示例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())
.getEntriesForXValue(highlight.getX());
for (Entry entry : entries)
if (entry.getY() == highlight.getY() ||
Float.isNaN(highlight.getY()))
return entry;
return null;
}
}
示例6: 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
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXIndex(
highlight.getXIndex());
}
示例7: 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;
}
}
示例8: 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
*/
public Entry getEntryForHighlight(Highlight highlight) {
if (highlight.getDataSetIndex() >= mDataSets.size())
return null;
else {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXPos(highlight.getX());
}
}
示例9: 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;
}
}
示例10: drawMarkers
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* draws all MarkerViews on the highlighted positions
*/
protected void drawMarkers(Canvas canvas) {
// if there is no marker view or drawing marker is disabled
if (mMarkerView == null || !mDrawMarkerViews || !valuesToHighlight())
return;
for (int i = 0; i < mIndicesToHighlight.length; i++) {
Highlight highlight = mIndicesToHighlight[i];
int xIndex = highlight.getXIndex();
int dataSetIndex = highlight.getDataSetIndex();
if (xIndex <= mDeltaX && xIndex <= mDeltaX * mAnimator.getPhaseX()) {
Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
// make sure entry not null
if (e == null || e.getXIndex() != mIndicesToHighlight[i].getXIndex())
continue;
float[] pos = getMarkerPosition(e, highlight);
// check bounds
if (!mViewPortHandler.isInBounds(pos[0], pos[1]))
continue;
// callbacks to update the content
mMarkerView.refreshContent(e, highlight);
// mMarkerView.measure(MeasureSpec.makeMeasureSpec(0,
// MeasureSpec.UNSPECIFIED),
// MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
// mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(),
// mMarkerView.getMeasuredHeight());
// mMarkerView.draw(mDrawCanvas, pos[0], pos[1]);
mMarkerView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(),
mMarkerView.getMeasuredHeight());
if (pos[1] - mMarkerView.getHeight() <= 0) {
float y = mMarkerView.getHeight() - pos[1];
mMarkerView.draw(canvas, pos[0], pos[1] + y);
} else {
mMarkerView.draw(canvas, pos[0], pos[1]);
}
}
}
}
示例11: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
int setCount = mChart.getBarData().getDataSetCount();
for (int i = 0; i < indices.length; i++) {
Highlight h = indices[i];
int index = h.getXIndex();
int dataSetIndex = h.getDataSetIndex();
IBarDataSet set = mChart.getBarData().getDataSetByIndex(dataSetIndex);
if (set == null || !set.isHighlightEnabled())
continue;
float barspaceHalf = set.getBarSpace() / 2f;
Transformer trans = mChart.getTransformer(set.getAxisDependency());
mHighlightPaint.setColor(set.getHighLightColor());
mHighlightPaint.setAlpha(set.getHighLightAlpha());
// check outofbounds
if (index >= 0
&& index < (mChart.getXChartMax() * mAnimator.getPhaseX()) / setCount) {
BarEntry e = set.getEntryForXIndex(index);
if (e == null || e.getXIndex() != index)
continue;
float groupspace = mChart.getBarData().getGroupSpace();
boolean isStack = h.getStackIndex() < 0 ? false : true;
// calculate the correct x-position
float x = index * setCount + dataSetIndex + groupspace / 2f
+ groupspace * index;
final float y1;
final float y2;
if (isStack) {
y1 = h.getRange().from;
y2 = h.getRange().to;
} else {
y1 = e.getVal();
y2 = 0.f;
}
prepareBarHighlight(x, y1, y2, barspaceHalf, trans);
c.drawRect(mBarRect, mHighlightPaint);
if (mChart.isDrawHighlightArrowEnabled()) {
mHighlightPaint.setAlpha(255);
// distance between highlight arrow and bar
float offsetY = mAnimator.getPhaseY() * 0.07f;
float[] values = new float[9];
trans.getPixelToValueMatrix().getValues(values);
final float xToYRel = Math.abs(values[Matrix.MSCALE_Y] / values[Matrix.MSCALE_X]);
final float arrowWidth = set.getBarSpace() / 2.f;
final float arrowHeight = arrowWidth * xToYRel;
final float yArrow = (y1 > -y2 ? y1 : y1) * mAnimator.getPhaseY();
Path arrow = new Path();
arrow.moveTo(x + 0.4f, yArrow + offsetY);
arrow.lineTo(x + 0.4f + arrowWidth, yArrow + offsetY - arrowHeight);
arrow.lineTo(x + 0.4f + arrowWidth, yArrow + offsetY + arrowHeight);
trans.pathValueToPixel(arrow);
c.drawPath(arrow, mHighlightPaint);
}
}
}
}
示例12: drawMarkers
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
/**
* draws all MarkerViews on the highlighted positions
*/
protected void drawMarkers(Canvas canvas) {
// if there is no marker view or drawing marker is disabled
if (mMarkerView == null || !mDrawMarkerViews || !valuesToHighlight())
return;
for (int i = 0; i < mIndicesToHighlight.length; i++) {
Highlight highlight = mIndicesToHighlight[i];
int xIndex = highlight.getXIndex();
int dataSetIndex = highlight.getDataSetIndex();
float deltaX = mXAxis != null
? mXAxis.mAxisRange
: ((mData == null ? 0.f : mData.getXValCount()) - 1.f);
if (xIndex <= deltaX && xIndex <= deltaX * mAnimator.getPhaseX()) {
Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]);
// make sure entry not null
if (e == null || e.getXIndex() != mIndicesToHighlight[i].getXIndex())
continue;
float[] pos = getMarkerPosition(e, highlight);
// check bounds
if (!mViewPortHandler.isInBounds(pos[0], pos[1]))
continue;
// callbacks to update the content
mMarkerView.refreshContent(e, highlight);
// mMarkerView.measure(MeasureSpec.makeMeasureSpec(0,
// MeasureSpec.UNSPECIFIED),
// MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
// mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(),
// mMarkerView.getMeasuredHeight());
// mMarkerView.draw(mDrawCanvas, pos[0], pos[1]);
mMarkerView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(),
mMarkerView.getMeasuredHeight());
if (pos[1] - mMarkerView.getHeight() <= 0) {
float y = mMarkerView.getHeight() - pos[1];
mMarkerView.draw(canvas, pos[0], pos[1] + y);
} else {
mMarkerView.draw(canvas, pos[0], pos[1]);
}
}
}
}
示例13: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
LineData lineData = mChart.getLineData();
for (Highlight high : indices) {
final int minDataSetIndex = high.getDataSetIndex() == -1
? 0
: high.getDataSetIndex();
final int maxDataSetIndex = high.getDataSetIndex() == -1
? lineData.getDataSetCount()
: (high.getDataSetIndex() + 1);
if (maxDataSetIndex - minDataSetIndex < 1) continue;
for (int dataSetIndex = minDataSetIndex;
dataSetIndex < maxDataSetIndex;
dataSetIndex++) {
ILineDataSet set = lineData.getDataSetByIndex(dataSetIndex);
if (set == null || !set.isHighlightEnabled())
continue;
int xIndex = high.getXIndex(); // get the
// x-position
if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())
continue;
final float yVal = set.getYValForXIndex(xIndex);
if (Float.isNaN(yVal))
continue;
float y = yVal * mAnimator.getPhaseY(); // get
// the
// y-position
float[] pts = new float[]{
xIndex, y
};
mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
// draw the lines
drawHighlightLines(c, pts, set);
}
}
}
示例14: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
CandleData candleData = mChart.getCandleData();
for (Highlight high : indices) {
final int minDataSetIndex = high.getDataSetIndex() == -1
? 0
: high.getDataSetIndex();
final int maxDataSetIndex = high.getDataSetIndex() == -1
? candleData.getDataSetCount()
: (high.getDataSetIndex() + 1);
if (maxDataSetIndex - minDataSetIndex < 1) continue;
for (int dataSetIndex = minDataSetIndex;
dataSetIndex < maxDataSetIndex;
dataSetIndex++) {
int xIndex = high.getXIndex(); // get the
// x-position
ICandleDataSet set = mChart.getCandleData().getDataSetByIndex(dataSetIndex);
if (set == null || !set.isHighlightEnabled())
continue;
CandleEntry e = set.getEntryForXIndex(xIndex);
if (e == null || e.getXIndex() != xIndex)
continue;
float lowValue = e.getLow() * mAnimator.getPhaseY();
float highValue = e.getHigh() * mAnimator.getPhaseY();
float y = (lowValue + highValue) / 2f;
float[] pts = new float[]{
xIndex, y
};
mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
// draw the lines
drawHighlightLines(c, pts, set);
}
}
}
示例15: drawHighlighted
import com.github.mikephil.charting.highlight.Highlight; //導入方法依賴的package包/類
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
ScatterData scatterData = mChart.getScatterData();
for (Highlight high : indices) {
final int minDataSetIndex = high.getDataSetIndex() == -1
? 0
: high.getDataSetIndex();
final int maxDataSetIndex = high.getDataSetIndex() == -1
? scatterData.getDataSetCount()
: (high.getDataSetIndex() + 1);
if (maxDataSetIndex - minDataSetIndex < 1) continue;
for (int dataSetIndex = minDataSetIndex;
dataSetIndex < maxDataSetIndex;
dataSetIndex++) {
IScatterDataSet set = scatterData.getDataSetByIndex(dataSetIndex);
if (set == null || !set.isHighlightEnabled())
continue;
int xIndex = high.getXIndex(); // get the
// x-position
if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())
continue;
final float yVal = set.getYValForXIndex(xIndex);
if (Float.isNaN(yVal))
continue;
float y = yVal * mAnimator.getPhaseY();
float[] pts = new float[]{
xIndex, y
};
mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
// draw the lines
drawHighlightLines(c, pts, set);
}
}
}