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


Java PieDataSet.getYVals方法代码示例

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


在下文中一共展示了PieDataSet.getYVals方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawDataSet

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
protected void drawDataSet(Canvas c, PieDataSet dataSet) {

        float angle = mChart.getRotationAngle();

        List<Entry> entries = dataSet.getYVals();
        float[] drawAngles = mChart.getDrawAngles();

        for (int j = 0; j < entries.size(); j++) {

            float newangle = drawAngles[j];
            float sliceSpace = dataSet.getSliceSpace();

            Entry e = entries.get(j);

            // draw only if the value is greater than zero
            if ((Math.abs(e.getVal()) > 0.000001)) {

                if (!mChart.needsHighlight(e.getXIndex(),
                        mChart.getData().getIndexOfDataSet(dataSet))) {

                    mRenderPaint.setColor(dataSet.getColor(j));
                    mBitmapCanvas.drawArc(mChart.getCircleBox(),
                            (angle + sliceSpace / 2f) * mAnimator.getPhaseY(),
                            (newangle - sliceSpace / 2f) * mAnimator.getPhaseY(),
                            true, mRenderPaint);
                }
            }

            angle += newangle * mAnimator.getPhaseX();
        }
    }
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:32,代码来源:PieChartRenderer.java

示例2: drawRoundedSlices

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * This gives all pie-slices a rounded edge.
 * 
 * @param c
 */
protected void drawRoundedSlices(Canvas c) {

    if (!mChart.isDrawRoundedSlicesEnabled())
        return;

    PieDataSet dataSet = mChart.getData().getDataSet();

    if (!dataSet.isVisible())
        return;
    
    PointF center = mChart.getCenterCircleBox();
    float r = mChart.getRadius();

    // calculate the radius of the "slice-circle"
    float circleRadius = (r - (r * mChart.getHoleRadius() / 100f)) / 2f;

    List<Entry> entries = dataSet.getYVals();
    float[] drawAngles = mChart.getDrawAngles();
    float angle = mChart.getRotationAngle();

    for (int j = 0; j < entries.size(); j++) {

        float newangle = drawAngles[j];

        Entry e = entries.get(j);

        // draw only if the value is greater than zero
        if ((Math.abs(e.getVal()) > 0.000001)) {

            float x = (float) ((r - circleRadius)
                    * Math.cos(Math.toRadians((angle + newangle)
                            * mAnimator.getPhaseY())) + center.x);
            float y = (float) ((r - circleRadius)
                    * Math.sin(Math.toRadians((angle + newangle)
                            * mAnimator.getPhaseY())) + center.y);

            mRenderPaint.setColor(dataSet.getColor(j));
            mBitmapCanvas.drawCircle(x, y, circleRadius, mRenderPaint);
        }

        angle += newangle * mAnimator.getPhaseX();
    }
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:49,代码来源:PieChartRenderer.java

示例3: drawData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
protected void drawData() {

    float angle = mRotationAngle;

    ArrayList<PieDataSet> dataSets = mData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mData.getDataSetCount(); i++) {

        PieDataSet dataSet = dataSets.get(i);
        ArrayList<Entry> entries = dataSet.getYVals();

        for (int j = 0; j < entries.size(); j++) {

            float newangle = mDrawAngles[cnt];
            float sliceSpace = dataSet.getSliceSpace();

            Entry e = entries.get(j);

            // draw only if the value is greater than zero
            if ((Math.abs(e.getVal()) > 0.000001)) {

                if (!needsHighlight(e.getXIndex(), i)) {

                    mRenderPaint.setColor(dataSet.getColor(j));
                    mDrawCanvas.drawArc(mCircleBox, angle + sliceSpace / 2f, newangle * mPhaseY
                            - sliceSpace / 2f, true, mRenderPaint);
                }

                // if(sliceSpace > 0f) {
                //
                // PointF outer = getPosition(c, radius, angle);
                // PointF inner = getPosition(c, radius * mHoleRadiusPercent
                // / 100f, angle);
                // }
            }

            angle += newangle * mPhaseX;
            cnt++;
        }
    }
}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:45,代码来源:PieChart.java

示例4: drawValues

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
protected void drawValues() {

    // if neither xvals nor yvals are drawn, return
    if (!mDrawXVals && !mDrawYValues)
        return;

    PointF center = getCenterCircleBox();

    // get whole the radius
    float r = getRadius();

    float off = r / 2f;

    if (mDrawHole) {
        off = (r - (r / 100f * mHoleRadiusPercent)) / 2f;
    }

    r -= off; // offset to keep things inside the chart

    ArrayList<PieDataSet> dataSets = mData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mData.getDataSetCount(); i++) {

        PieDataSet dataSet = dataSets.get(i);
        ArrayList<Entry> entries = dataSet.getYVals();

        for (int j = 0; j < entries.size() * mPhaseX; j++) {

            // offset needed to center the drawn text in the slice
            float offset = mDrawAngles[cnt] / 2;

            // calculate the text position
            float x = (float) (r
                    * Math.cos(Math.toRadians((mRotationAngle + mAbsoluteAngles[cnt] - offset)
                            * mPhaseY)) + center.x);
            float y = (float) (r
                    * Math.sin(Math.toRadians((mRotationAngle + mAbsoluteAngles[cnt] - offset)
                            * mPhaseY)) + center.y);

            String val = "";
            float value = entries.get(j).getVal();

            if (mUsePercentValues)
                val = mValueFormatter.getFormattedValue(Math.abs(getPercentOfTotal(value)))
                        + " %";
            else
                val = mValueFormatter.getFormattedValue(value);

            if (mDrawUnitInChart)
                val = val + mUnit;

            // draw everything, depending on settings
            if (mDrawXVals && mDrawYValues) {

                // use ascent and descent to calculate the new line
                // position,
                // 1.6f is the line spacing
                float lineHeight = (mValuePaint.ascent() + mValuePaint.descent()) * 1.6f;
                y -= lineHeight / 2;

                mDrawCanvas.drawText(val, x, y, mValuePaint);
                if (j < mData.getXValCount())
                    mDrawCanvas.drawText(mData.getXVals().get(j), x, y + lineHeight,
                            mValuePaint);

            } else if (mDrawXVals && !mDrawYValues) {
                if (j < mData.getXValCount())
                    mDrawCanvas.drawText(mData.getXVals().get(j), x, y, mValuePaint);
            } else if (!mDrawXVals && mDrawYValues) {

                mDrawCanvas.drawText(val, x, y, mValuePaint);
            }

            cnt++;
        }
    }
}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:81,代码来源:PieChart.java

示例5: drawData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
protected void drawData() {

    float angle = mRotationAngle;

    ArrayList<PieDataSet> dataSets = mCurrentData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mCurrentData.getDataSetCount(); i++) {

        PieDataSet dataSet = dataSets.get(i);
        ArrayList<Entry> entries = dataSet.getYVals();

        for (int j = 0; j < entries.size(); j++) {

            float newangle = mDrawAngles[cnt];
            float sliceSpace = dataSet.getSliceSpace();

            Entry e = entries.get(j);

            // draw only if the value is greater than zero
            if ((Math.abs(e.getVal()) > 0.000001)) {

                if (!needsHighlight(e.getXIndex(), i)) {

                    mRenderPaint.setColor(dataSet.getColor(j));
                    mDrawCanvas.drawArc(mCircleBox, angle + sliceSpace / 2f, newangle * mPhaseY
                            - sliceSpace / 2f, true, mRenderPaint);
                }

                // if(sliceSpace > 0f) {
                //
                // PointF outer = getPosition(c, radius, angle);
                // PointF inner = getPosition(c, radius * mHoleRadiusPercent
                // / 100f, angle);
                // }
            }

            angle += newangle * mPhaseX;
            cnt++;
        }
    }
}
 
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:45,代码来源:PieChart.java

示例6: drawValues

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
protected void drawValues() {

    // if neither xvals nor yvals are drawn, return
    if (!mDrawXVals && !mDrawYValues)
        return;

    PointF center = getCenterCircleBox();

    // get whole the radius
    float r = getRadius();

    float off = r / 2f;

    if (mDrawHole) {
        off = (r - (r / 100f * mHoleRadiusPercent)) / 2f;
    }

    r -= off; // offset to keep things inside the chart

    ArrayList<PieDataSet> dataSets = mCurrentData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mCurrentData.getDataSetCount(); i++) {

        PieDataSet dataSet = dataSets.get(i);
        ArrayList<Entry> entries = dataSet.getYVals();

        for (int j = 0; j < entries.size() * mPhaseX; j++) {

            // offset needed to center the drawn text in the slice
            float offset = mDrawAngles[cnt] / 2;

            // calculate the text position
            float x = (float) (r
                    * Math.cos(Math.toRadians((mRotationAngle + mAbsoluteAngles[cnt] - offset)
                            * mPhaseY)) + center.x);
            float y = (float) (r
                    * Math.sin(Math.toRadians((mRotationAngle + mAbsoluteAngles[cnt] - offset)
                            * mPhaseY)) + center.y);

            String val = "";
            float value = entries.get(j).getVal();

            if (mUsePercentValues)
                val = mValueFormatter.getFormattedValue(Math.abs(getPercentOfTotal(value)))
                        + " %";
            else
                val = mValueFormatter.getFormattedValue(value);

            if (mDrawUnitInChart)
                val = val + mUnit;

            // draw everything, depending on settings
            if (mDrawXVals && mDrawYValues) {

                // use ascent and descent to calculate the new line
                // position,
                // 1.6f is the line spacing
                float lineHeight = (mValuePaint.ascent() + mValuePaint.descent()) * 1.6f;
                y -= lineHeight / 2;

                mDrawCanvas.drawText(val, x, y, mValuePaint);
                if (j < mCurrentData.getXValCount())
                    mDrawCanvas.drawText(mCurrentData.getXVals().get(j), x, y + lineHeight,
                            mValuePaint);

            } else if (mDrawXVals && !mDrawYValues) {
                if (j < mCurrentData.getXValCount())
                    mDrawCanvas.drawText(mCurrentData.getXVals().get(j), x, y, mValuePaint);
            } else if (!mDrawXVals && mDrawYValues) {

                mDrawCanvas.drawText(val, x, y, mValuePaint);
            }

            cnt++;
        }
    }
}
 
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:81,代码来源:PieChart.java

示例7: calcAngles

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * calculates the needed angles for the chart slices
 */
private void calcAngles() {

    mDrawAngles = new float[mData.getYValCount()];
    mAbsoluteAngles = new float[mData.getYValCount()];

    List<PieDataSet> dataSets = mData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mData.getDataSetCount(); i++) {

        PieDataSet set = dataSets.get(i);
        List<Entry> entries = set.getYVals();

        for (int j = 0; j < entries.size(); j++) {

            mDrawAngles[cnt] = calcAngle(Math.abs(entries.get(j).getVal()));

            if (cnt == 0) {
                mAbsoluteAngles[cnt] = mDrawAngles[cnt];
            } else {
                mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
            }

            cnt++;
        }
    }

}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:33,代码来源:PieChart.java

示例8: calcAngles

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * calculates the needed angles for the chart slices
 */
private void calcAngles() {

    mDrawAngles = new float[mData.getYValCount()];
    mAbsoluteAngles = new float[mData.getYValCount()];

    ArrayList<PieDataSet> dataSets = mData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mData.getDataSetCount(); i++) {

        PieDataSet set = dataSets.get(i);
        ArrayList<Entry> entries = set.getYVals();

        for (int j = 0; j < entries.size(); j++) {

            mDrawAngles[cnt] = calcAngle(Math.abs(entries.get(j).getVal()));

            if (cnt == 0) {
                mAbsoluteAngles[cnt] = mDrawAngles[cnt];
            } else {
                mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
            }

            cnt++;
        }
    }

}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:33,代码来源:PieChart.java

示例9: calcAngles

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * calculates the needed angles for the chart slices
 */
private void calcAngles() {

    mDrawAngles = new float[mCurrentData.getYValCount()];
    mAbsoluteAngles = new float[mCurrentData.getYValCount()];

    ArrayList<PieDataSet> dataSets = mCurrentData.getDataSets();

    int cnt = 0;

    for (int i = 0; i < mCurrentData.getDataSetCount(); i++) {

        PieDataSet set = dataSets.get(i);
        ArrayList<Entry> entries = set.getYVals();

        for (int j = 0; j < entries.size(); j++) {

            mDrawAngles[cnt] = calcAngle(Math.abs(entries.get(j).getVal()));

            if (cnt == 0) {
                mAbsoluteAngles[cnt] = mDrawAngles[cnt];
            } else {
                mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
            }

            cnt++;
        }
    }

}
 
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:33,代码来源:PieChart.java


注:本文中的com.github.mikephil.charting.data.PieDataSet.getYVals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。