當前位置: 首頁>>代碼示例>>Java>>正文


Java BarEntry.getVal方法代碼示例

本文整理匯總了Java中com.github.mikephil.charting.data.BarEntry.getVal方法的典型用法代碼示例。如果您正苦於以下問題:Java BarEntry.getVal方法的具體用法?Java BarEntry.getVal怎麽用?Java BarEntry.getVal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mikephil.charting.data.BarEntry的用法示例。


在下文中一共展示了BarEntry.getVal方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
/**
 * Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
 * found in the charts data.
 * 
 * @param e
 * @return
 */
public RectF getBarBounds(BarEntry e) {

	IBarDataSet set = mData.getDataSetForEntry(e);

	if (set == null)
		return null;

	float barspace = set.getBarSpace();
	float y = e.getVal();
	float x = e.getXIndex();

	float barWidth = 0.5f;

	float spaceHalf = barspace / 2f;
	float left = x - barWidth + spaceHalf;
	float right = x + barWidth - spaceHalf;
	float top = y >= 0 ? y : 0;
	float bottom = y <= 0 ? y : 0;

	RectF bounds = new RectF(left, top, right, bottom);

	getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

	return bounds;
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:33,代碼來源:BarChart.java

示例2: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
/**
 * Returns the bounding box of the specified Entry in the specified DataSet. Returns null if the Entry could not be
 * found in the charts data.
 * 
 * @param e
 * @return
 */
public RectF getBarBounds(BarEntry e) {

	BarDataSet set = mData.getDataSetForEntry(e);

	if (set == null)
		return null;

	float barspace = set.getBarSpace();
	float y = e.getVal();
	float x = e.getXIndex();

	float barWidth = 0.5f;

	float spaceHalf = barspace / 2f;
	float left = x - barWidth + spaceHalf;
	float right = x + barWidth - spaceHalf;
	float top = y >= 0 ? y : 0;
	float bottom = y <= 0 ? y : 0;

	RectF bounds = new RectF(left, top, right, bottom);

	getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

	return bounds;
}
 
開發者ID:xinpengfei520,項目名稱:P2P,代碼行數:33,代碼來源:BarChart.java

示例3: getStackedHighlight

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的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;
}
 
開發者ID:pencil-box,項目名稱:NetKnight,代碼行數:43,代碼來源:BarHighlighter.java

示例4: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
@Override
public RectF getBarBounds(BarEntry e) {

	IBarDataSet set = mData.getDataSetForEntry(e);

	if (set == null)
		return null;

	float barspace = set.getBarSpace();
	float y = e.getVal();
	float x = e.getXIndex();

	float spaceHalf = barspace / 2f;

	float top = x - 0.5f + spaceHalf;
	float bottom = x + 0.5f - spaceHalf;
	float left = y >= 0 ? y : 0;
	float right = y <= 0 ? y : 0;

	RectF bounds = new RectF(left, top, right, bottom);

	getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

	return bounds;
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:26,代碼來源:HorizontalBarChart.java

示例5: calcMinMax

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
@Override
public void calcMinMax(int start, int end) {

    if (mValues == null)
        return;

    final int yValCount = mValues.size();

    if (yValCount == 0)
        return;

    int endValue;

    if (end == 0 || end >= yValCount)
        endValue = yValCount - 1;
    else
        endValue = end;

    mYMin = Float.MAX_VALUE;
    mYMax = -Float.MAX_VALUE;

    for (int i = start; i <= endValue; i++) {

        BarEntry e = mValues.get(i);

        if (e != null && !Float.isNaN(e.getVal())) {

            if (e.getVals() == null) {

                if (e.getVal() < mYMin)
                    mYMin = e.getVal();

                if (e.getVal() > mYMax)
                    mYMax = e.getVal();
            } else {

                if (-e.getNegativeSum() < mYMin)
                    mYMin = -e.getNegativeSum();

                if (e.getPositiveSum() > mYMax)
                    mYMax = e.getPositiveSum();
            }
        }
    }

    if (mYMin == Float.MAX_VALUE) {
        mYMin = 0.f;
        mYMax = 0.f;
    }
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:51,代碼來源:RealmBarDataSet.java

示例6: drawHighlighted

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的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);
            }
        }
    }
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:82,代碼來源:BarChartRenderer.java

示例7: getBarBounds

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的package包/類
@Override
public RectF getBarBounds(BarEntry e) {

	BarDataSet set = mData.getDataSetForEntry(e);

	if (set == null)
		return null;

	float barspace = set.getBarSpace();
	float y = e.getVal();
	float x = e.getXIndex();

	float spaceHalf = barspace / 2f;

	float top = x - 0.5f + spaceHalf;
	float bottom = x + 0.5f - spaceHalf;
	float left = y >= 0 ? y : 0;
	float right = y <= 0 ? y : 0;

	RectF bounds = new RectF(left, top, right, bottom);

	getTransformer(set.getAxisDependency()).rectValueToPixel(bounds);

	return bounds;
}
 
開發者ID:xinpengfei520,項目名稱:P2P,代碼行數:26,代碼來源:HorizontalBarChart.java

示例8: drawHighlighted

import com.github.mikephil.charting.data.BarEntry; //導入方法依賴的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();
        BarDataSet 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);
            }
        }
    }
}
 
開發者ID:xinpengfei520,項目名稱:P2P,代碼行數:82,代碼來源:BarChartRenderer.java


注:本文中的com.github.mikephil.charting.data.BarEntry.getVal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。