【问题标题】:Show image instead of text in MPAndroidChart pie chart在 MPAndroidChart 饼图中显示图像而不是文本
【发布时间】:2015-06-21 08:27:46
【问题描述】:

我的 android 应用程序中有一个饼图,我用 MPAndroidChart 绘制。

 <com.github.mikephil.charting.charts.PieChart
        android:id="@+id/chart"
        android:layout_width="400dp"
        android:layout_height="400dp"
        android:layout_centerInParent="true"
        />

 PieDataSet pieDataSet = new PieDataSet(entries, "expenses");
        pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
        pieDataSet.setDrawValues(false);

        PieData data = new PieData(xValues, pieDataSet);

        chart.setData(data);
        chart.getLegend().setEnabled(false);
        chart.setDescription("");
        chart.animateY(800, Easing.EasingOption.EaseInBounce);
        chart.setDrawHoleEnabled(false);
        chart.setTouchEnabled(true);
        chart.setDrawCenterText(false);
        chart.setDrawSliceText(true);
        chart.setOnChartValueSelectedListener(this);
        chart.invalidate(); // refresh

绘制饼图,x 值显示为文本。

我想根据 x 值替换每个饼图切片中的文本以显示一个小图像。

我检查了文档并没有找到任何东西,是否可以使用这个图表库来做到这一点?

【问题讨论】:

    标签: android charts mpandroidchart


    【解决方案1】:

    不,这是默认情况下不可能。但是,以支持该功能的方式自定义库应该不会太难。

    只需将Bitmap 添加到PieChart 中的每个条目,然后将其绘制在标签通常所在的位置即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多