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


Java PieChartData类代码示例

本文整理汇总了Java中lecho.lib.hellocharts.model.PieChartData的典型用法代码示例。如果您正苦于以下问题:Java PieChartData类的具体用法?Java PieChartData怎么用?Java PieChartData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onChartDataChanged

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
@Override
public void onChartDataChanged() {
    super.onChartDataChanged();
    final PieChartData data = dataProvider.getPieChartData();
    hasLabelsOutside = data.hasLabelsOutside();
    hasLabels = data.hasLabels();
    hasLabelsOnlyForSelected = data.hasLabelsOnlyForSelected();
    valueFormatter = data.getFormatter();
    hasCenterCircle = data.hasCenterCircle();
    centerCircleScale = data.getCenterCircleScale();
    centerCirclePaint.setColor(data.getCenterCircleColor());
    if (null != data.getCenterText1Typeface()) {
        centerCircleText1Paint.setTypeface(data.getCenterText1Typeface());
    }
    centerCircleText1Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText1FontSize()));
    centerCircleText1Paint.setColor(data.getCenterText1Color());
    centerCircleText1Paint.getFontMetricsInt(centerCircleText1FontMetrics);
    if (null != data.getCenterText2Typeface()) {
        centerCircleText2Paint.setTypeface(data.getCenterText2Typeface());
    }
    centerCircleText2Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText2FontSize()));
    centerCircleText2Paint.setColor(data.getCenterText2Color());
    centerCircleText2Paint.getFontMetricsInt(centerCircleText2FontMetrics);

    onChartViewportChanged();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PieChartRenderer.java

示例2: drawCenterCircle

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
/**
 * Draw center circle with text if {@link PieChartData#hasCenterCircle()} is set true.
 */
private void drawCenterCircle(Canvas canvas) {
    final PieChartData data = dataProvider.getPieChartData();
    final float circleRadius = originCircleOval.width() / 2f;
    final float centerRadius = circleRadius * data.getCenterCircleScale();
    final float centerX = originCircleOval.centerX();
    final float centerY = originCircleOval.centerY();

    canvas.drawCircle(centerX, centerY, centerRadius, centerCirclePaint);

    // Draw center text1 and text2 if not empty.
    if (!TextUtils.isEmpty(data.getCenterText1())) {

        final int text1Height = Math.abs(centerCircleText1FontMetrics.ascent);

        if (!TextUtils.isEmpty(data.getCenterText2())) {
            // Draw text 2 only if text 1 is not empty.
            final int text2Height = Math.abs(centerCircleText2FontMetrics.ascent);
            canvas.drawText(data.getCenterText1(), centerX, centerY - text1Height * 0.2f, centerCircleText1Paint);
            canvas.drawText(data.getCenterText2(), centerX, centerY + text2Height, centerCircleText2Paint);
        } else {
            canvas.drawText(data.getCenterText1(), centerX, centerY + text1Height / 4, centerCircleText1Paint);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:PieChartRenderer.java

示例3: drawSlices

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
/**
 * Draw all slices for this PieChart, if mode == {@link #MODE_HIGHLIGHT} currently selected slices will be redrawn
 * and
 * highlighted.
 *
 * @param canvas
 */
private void drawSlices(Canvas canvas) {
    final PieChartData data = dataProvider.getPieChartData();
    final float sliceScale = 360f / maxSum;
    float lastAngle = rotation;
    int sliceIndex = 0;
    for (SliceValue sliceValue : data.getValues()) {
        final float angle = Math.abs(sliceValue.getValue()) * sliceScale;
        if (isTouched() && selectedValue.getFirstIndex() == sliceIndex) {
            drawSlice(canvas, sliceValue, lastAngle, angle, MODE_HIGHLIGHT);
        } else {
            drawSlice(canvas, sliceValue, lastAngle, angle, MODE_DRAW);
        }
        lastAngle += angle;
        ++sliceIndex;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:PieChartRenderer.java

示例4: drawLabels

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
public void drawLabels(Canvas canvas) {
    final PieChartData data = dataProvider.getPieChartData();
    final float sliceScale = 360f / maxSum;
    float lastAngle = rotation;
    int sliceIndex = 0;
    for (SliceValue sliceValue : data.getValues()) {
        final float angle = Math.abs(sliceValue.getValue()) * sliceScale;
        if (isTouched()) {
            if (hasLabels) {
                drawLabel(canvas, sliceValue, lastAngle, angle);
            } else if (hasLabelsOnlyForSelected && selectedValue.getFirstIndex() == sliceIndex) {
                drawLabel(canvas, sliceValue, lastAngle, angle);
            }
        } else {
            if (hasLabels) {
                drawLabel(canvas, sliceValue, lastAngle, angle);
            }
        }
        lastAngle += angle;
        ++sliceIndex;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PieChartRenderer.java

示例5: getValueForAngle

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
/**
 * Returns SliceValue that is under given angle, selectedValue (if not null) will be hold slice index.
 */
public SliceValue getValueForAngle(int angle, SelectedValue selectedValue) {
    final PieChartData data = dataProvider.getPieChartData();
    final float touchAngle = (angle - rotation + 360f) % 360f;
    final float sliceScale = 360f / maxSum;
    float lastAngle = 0f;
    int sliceIndex = 0;
    for (SliceValue sliceValue : data.getValues()) {
        final float tempAngle = Math.abs(sliceValue.getValue()) * sliceScale;
        if (touchAngle >= lastAngle) {
            if (null != selectedValue) {
                selectedValue.set(sliceIndex, sliceIndex, SelectedValueType.NONE);
            }
            return sliceValue;
        }
        lastAngle += tempAngle;
        ++sliceIndex;
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PieChartRenderer.java

示例6: onChartDataChanged

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
public void onChartDataChanged() {
    super.onChartDataChanged();
    PieChartData data = this.dataProvider.getPieChartData();
    this.hasLabelsOutside = data.hasLabelsOutside();
    this.hasLabels = data.hasLabels();
    this.hasLabelsOnlyForSelected = data.hasLabelsOnlyForSelected();
    this.valueFormatter = data.getFormatter();
    this.hasCenterCircle = data.hasCenterCircle();
    this.centerCircleScale = data.getCenterCircleScale();
    this.centerCirclePaint.setColor(data.getCenterCircleColor());
    if (data.getCenterText1Typeface() != null) {
        this.centerCircleText1Paint.setTypeface(data.getCenterText1Typeface());
    }
    this.centerCircleText1Paint.setTextSize((float) ChartUtils.sp2px(this.scaledDensity, data.getCenterText1FontSize()));
    this.centerCircleText1Paint.setColor(data.getCenterText1Color());
    this.centerCircleText1Paint.getFontMetricsInt(this.centerCircleText1FontMetrics);
    if (data.getCenterText2Typeface() != null) {
        this.centerCircleText2Paint.setTypeface(data.getCenterText2Typeface());
    }
    this.centerCircleText2Paint.setTextSize((float) ChartUtils.sp2px(this.scaledDensity, data.getCenterText2FontSize()));
    this.centerCircleText2Paint.setColor(data.getCenterText2Color());
    this.centerCircleText2Paint.getFontMetricsInt(this.centerCircleText2FontMetrics);
    onChartViewportChanged();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:PieChartRenderer.java

示例7: drawCenterCircle

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void drawCenterCircle(Canvas canvas) {
    PieChartData data = this.dataProvider.getPieChartData();
    float centerRadius = (this.originCircleOval.width() / 2.0f) * data.getCenterCircleScale();
    float centerX = this.originCircleOval.centerX();
    float centerY = this.originCircleOval.centerY();
    canvas.drawCircle(centerX, centerY, centerRadius, this.centerCirclePaint);
    if (!TextUtils.isEmpty(data.getCenterText1())) {
        int text1Height = Math.abs(this.centerCircleText1FontMetrics.ascent);
        if (TextUtils.isEmpty(data.getCenterText2())) {
            canvas.drawText(data.getCenterText1(), centerX, ((float) (text1Height / 4)) + centerY, this.centerCircleText1Paint);
            return;
        }
        int text2Height = Math.abs(this.centerCircleText2FontMetrics.ascent);
        canvas.drawText(data.getCenterText1(), centerX, centerY - (((float) text1Height) * 0.2f), this.centerCircleText1Paint);
        canvas.drawText(data.getCenterText2(), centerX, ((float) text2Height) + centerY, this.centerCircleText2Paint);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:PieChartRenderer.java

示例8: drawSeparationLines

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void drawSeparationLines(Canvas canvas) {
    PieChartData data = this.dataProvider.getPieChartData();
    if (data.getValues().size() >= 2) {
        int sliceSpacing = ChartUtils.dp2px(this.density, data.getSlicesSpacing());
        if (sliceSpacing >= 1) {
            float sliceScale = 360.0f / this.maxSum;
            float lastAngle = (float) this.rotation;
            float circleRadius = this.originCircleOval.width() / 2.0f;
            this.separationLinesPaint.setStrokeWidth((float) sliceSpacing);
            for (SliceValue sliceValue : data.getValues()) {
                float angle = Math.abs(sliceValue.getValue()) * sliceScale;
                this.sliceVector.set((float) Math.cos(Math.toRadians((double) lastAngle)), (float) Math.sin(Math.toRadians((double) lastAngle)));
                normalizeVector(this.sliceVector);
                Canvas canvas2 = canvas;
                canvas2.drawLine(this.originCircleOval.centerX(), this.originCircleOval.centerY(), (this.sliceVector.x * (((float) this.touchAdditional) + circleRadius)) + this.originCircleOval.centerX(), (this.sliceVector.y * (((float) this.touchAdditional) + circleRadius)) + this.originCircleOval.centerY(), this.separationLinesPaint);
                lastAngle += angle;
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:PieChartRenderer.java

示例9: initMealsPie

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
public static void initMealsPie(PieChartView pieChartView, TodayDiets todayDiets) {
    List<SliceValue> values = new ArrayList();
    if (todayDiets.breakfast != null && todayDiets.breakfast.percentage > 0.0f) {
        values.add(new SliceValue(todayDiets.breakfast.percentage, MEALS_COLORS[0]).setLabel(
                ((int) (todayDiets.breakfast.percentage * 100.0f)) + "%早餐"));
    }
    if (todayDiets.lunch != null && todayDiets.lunch.percentage > 0.0f) {
        values.add(new SliceValue(todayDiets.lunch.percentage, MEALS_COLORS[1]).setLabel((
                (int) (todayDiets.lunch.percentage * 100.0f)) + "%午餐"));
    }
    if (todayDiets.dinner != null && todayDiets.dinner.percentage > 0.0f) {
        values.add(new SliceValue(todayDiets.dinner.percentage, MEALS_COLORS[2]).setLabel((
                (int) (todayDiets.dinner.percentage * 100.0f)) + "%晚餐"));
    }
    PieChartData data = new PieChartData(values);
    data.setHasLabels(true);
    data.setHasLabelsOnlyForSelected(false);
    data.setHasLabelsOutside(false);
    data.setHasCenterCircle(false);
    data.setSlicesSpacing(3);
    data.setValueLabelBackgroundColor(0);
    data.setValueLabelBackgroundEnabled(true);
    pieChartView.setValueSelectionEnabled(true);
    pieChartView.setPieChartData(data);
    pieChartView.startDataAnimation();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:ChartAnalysisHelper.java

示例10: calculatePercent

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private float calculatePercent(int data) {
    float percent;
    data *= 5;
    float[] gap = new float[]{0.0f, 0.0f, 25.0f, 300.0f, 600.0f, 1000.0f};
    if (data == 0) {
        percent = 0.2f;
    } else if (((float) data) > gap[1] && ((float) data) <= gap[2]) {
        percent = 0.2f + (((((float) data) - gap[1]) / (gap[2] - gap[1])) * 0.2f);
    } else if (((float) data) > gap[2] && ((float) data) <= gap[3]) {
        percent = 0.4f + (((((float) data) - gap[2]) / (gap[3] - gap[2])) * 0.2f);
    } else if (((float) data) <= gap[3] || ((float) data) > gap[4]) {
        percent = 0.8f + (((((float) data) - gap[4]) / (gap[5] - gap[4])) * 0.2f);
    } else {
        percent = PieChartData.DEFAULT_CENTER_CIRCLE_SCALE + (((((float) data) - gap[3]) /
                (gap[4] - gap[3])) * 0.2f);
    }
    if (percent > 1.0f) {
        return 1.0f;
    }
    return percent;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:RadarLayout.java

示例11: setGraph

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void setGraph(PieChartView graph, PieChartData data,int color){
    ArrayList<SliceValue> sliceValues = new ArrayList<>();
    SliceValue sliceValue2 = new SliceValue(1);
    SliceValue sliceValue = new SliceValue(0);

    sliceValues.add(sliceValue);
    sliceValues.add(sliceValue2);

    sliceValue.setColor(color);
    sliceValue2.setColor(getResources().getColor(R.color.dark_custom_gray));
    data.setHasCenterCircle(true);
    data.setCenterCircleColor(Color.BLACK);
    data.setValues(sliceValues);
    data.setCenterText1FontSize(12);
    data.setCenterText1Typeface(Typeface.DEFAULT_BOLD);
    data.setCenterText1Color(Color.WHITE);
    graph.setPieChartData(data);
    graph.setChartRotationEnabled(false);
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:20,代码来源:ReviewActivity.java

示例12: generateData

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void generateData() {
    List<SliceValue> values = new ArrayList<SliceValue>();

    String s1 = String.format("%.2f", ((double) yes / all) * 100);
    SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
    sliceValue1.setLabel("已报到" + s1 + "%");
    values.add(sliceValue1);

    String s2 = String.format("%.2f", ((double) no / all) * 100);
    SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
    sliceValue2.setLabel("未报到" + s2 + "%");
    values.add(sliceValue2);

    data = new PieChartData(values);
    data.setHasLabels(true);
    data.setHasLabelsOnlyForSelected(false);
    data.setHasLabelsOutside(false);
    chart.setValueSelectionEnabled(true);
    chart.setCircleFillRatio(1.0f);

    chart.setPieChartData(data);
}
 
开发者ID:chenshuais,项目名称:Cloud-Hicc,代码行数:23,代码来源:OnlineReportActivity.java

示例13: generateData

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void generateData() {

            List<SliceValue> values = new ArrayList<SliceValue>();

            String s1 = String.format("%.2f", ((double) yes / all) * 100);
            SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
            sliceValue1.setLabel("已报到" + s1 + "%");
            values.add(sliceValue1);

            String s2 = String.format("%.2f", ((double) no / all) * 100);
            SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
            sliceValue2.setLabel("未报到" + s2 + "%");
            values.add(sliceValue2);

            data = new PieChartData(values);
            data.setHasLabels(true);
            data.setHasLabelsOnlyForSelected(false);
            data.setHasLabelsOutside(false);
            chart.setValueSelectionEnabled(true);
            chart.setCircleFillRatio(1.0f);
            chart.setPieChartData(data);
        }
 
开发者ID:chenshuais,项目名称:Cloud-Hicc,代码行数:23,代码来源:ClassComparedActivity.java

示例14: generateData

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
private void generateData() {
    List<SliceValue> values = new ArrayList<SliceValue>();

    String s1 = String.format("%.2f", ((double) yes / all) * 100);
    SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
    sliceValue1.setLabel("已报到"+s1+"%");
    values.add(sliceValue1);

    String s2 = String.format("%.2f", ((double) no / all) * 100);
    SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
    sliceValue2.setLabel("未报到"+s2+"%");
    values.add(sliceValue2);

    data = new PieChartData(values);
    data.setHasLabels(true);
    data.setHasLabelsOnlyForSelected(false);
    data.setHasLabelsOutside(false);
    chart.setValueSelectionEnabled(true);
    chart.setCircleFillRatio(1.0f);

    chart.setPieChartData(data);
}
 
开发者ID:chenshuais,项目名称:Cloud-Hicc,代码行数:23,代码来源:LiveReportsActivity.java

示例15: PieChartView

import lecho.lib.hellocharts.model.PieChartData; //导入依赖的package包/类
public PieChartView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    pieChartRenderer = new PieChartRenderer(context, this, this);
    touchHandler = new PieChartTouchHandler(context, this);
    setChartRenderer(pieChartRenderer);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        this.rotationAnimator = new PieChartRotationAnimatorV8(this);
    } else {
        this.rotationAnimator = new PieChartRotationAnimatorV14(this);
    }
    setPieChartData(PieChartData.generateDummyData());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:PieChartView.java


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