当前位置: 首页>>代码示例>>Java>>正文


Java BarEntry.getXIndex方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.BarEntry.getXIndex方法的典型用法代码示例。如果您正苦于以下问题:Java BarEntry.getXIndex方法的具体用法?Java BarEntry.getXIndex怎么用?Java BarEntry.getXIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.data.BarEntry的用法示例。


在下文中一共展示了BarEntry.getXIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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

示例5: 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

示例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();
        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.getXIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。