本文整理汇总了Java中com.github.mikephil.charting.interfaces.datasets.IBarDataSet.getEntryForXIndex方法的典型用法代码示例。如果您正苦于以下问题:Java IBarDataSet.getEntryForXIndex方法的具体用法?Java IBarDataSet.getEntryForXIndex怎么用?Java IBarDataSet.getEntryForXIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.interfaces.datasets.IBarDataSet
的用法示例。
在下文中一共展示了IBarDataSet.getEntryForXIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStackedHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
* This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected.
*
* @param old
* the old highlight object before looking for stacked values
* @param set
* @param xIndex
* @param dataSetIndex
* @param yValue
* @return
*/
protected Highlight getStackedHighlight(Highlight old, IBarDataSet set, int xIndex, int dataSetIndex, double yValue) {
BarEntry entry = set.getEntryForXIndex(xIndex);
if (entry == null || entry.getVals() == null)
return old;
Range[] ranges = getRanges(entry);
int stackIndex = getClosestStackIndex(ranges, (float) yValue);
if(ranges.length > 0)
return new Highlight(xIndex, dataSetIndex, stackIndex, ranges[stackIndex]);
else
return null;
}
示例2: getStackedHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
* This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected.
*
* @param old
* the old highlight object before looking for stacked values
* @param set
* @param xIndex
* @param dataSetIndex
* @param yValue
* @return
*/
protected Highlight getStackedHighlight(Highlight old, IBarDataSet set, int xIndex, int dataSetIndex, double yValue) {
BarEntry entry = set.getEntryForXIndex(xIndex);
if (entry == null || entry.getVals() == null)
return old;
Range[] ranges = getRanges(entry);
int stackIndex = getClosestStackIndex(ranges, (float) yValue);
Highlight h = new Highlight(xIndex, dataSetIndex, stackIndex, ranges[stackIndex]);
return h;
}
示例3: getStackedHighlight
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的package包/类
/**
* This method creates the Highlight object that also indicates which value of a stacked BarEntry has been selected.
*
* @param selectionDetail the selection detail to work with looking for stacked values
* @param set
* @param xIndex
* @param yValue
* @return
*/
protected Highlight getStackedHighlight(
SelectionDetail selectionDetail,
IBarDataSet set,
int xIndex,
double yValue) {
BarEntry entry = set.getEntryForXIndex(xIndex);
if (entry == null)
return null;
if (entry.getVals() == null) {
return new Highlight(xIndex,
entry.getVal(),
selectionDetail.dataIndex,
selectionDetail.dataSetIndex);
}
Range[] ranges = getRanges(entry);
if (ranges.length > 0) {
int stackIndex = getClosestStackIndex(ranges, (float)yValue);
return new Highlight(
xIndex,
entry.getPositiveSum() - entry.getNegativeSum(),
selectionDetail.dataIndex,
selectionDetail.dataSetIndex,
stackIndex,
ranges[stackIndex]
);
}
return null;
}
示例4: drawHighlighted
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet; //导入方法依赖的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);
}
}
}
}