android - 如何在 MPAndroidChart 的 PieChart 中设置颜色
问题描述
我尝试在 MPAndroidChart 的 PieChart 中设置颜色。但它没有设置它。我想在我的分区中添加自定义颜色。这是我的代码:-
fun setupPieChartView() {
mPie = findViewById(R.id.piechart)
mPie?.setUsePercentValues(true)
val desc: Description = Description()
desc.text = "PieChart"
mPie?.description = desc
val legend: Legend? = mPie?.legend
legend?.horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT
val value = Arrays.asList(trueAns.toFloat(), wrongAns.toFloat(), noAns.toFloat())
val label = Arrays.asList("True", "false", "Not")
val entry = ArrayList<PieEntry>()
for (i in value.indices) {
entry.add(PieEntry(value.get(i), label.get(i)))
}
val dataSet = PieDataSet(entry, "Result")
dataSet.setDrawValues(true)
val pieData = PieData(dataSet)
pieData.setValueFormatter(PercentFormatter())
pieData.setValueTextSize(10f)
pieData.setValueTextColor(Color.WHITE)
mPie?.data = pieData
}
解决方案
推荐阅读
- dart - 如何访问同一库中但在不同文件中的私有(下划线)标识符
- elixir - Elixir:如何将地图推入数组/列表?
- django - 如何调用具有多个参数的视图
- vb.net - 如何在中间为2个字符串和变量添加引号
- php - PHP - 无法使用 API 密钥创建新的 Google 日历事件
- java - Java 13 DocumentBuilder 在解析 DTD 文件以验证 HTML 时中断
- html - 如何强制浏览器清除缓存以显示我网站上的更改?
- r - zip_internal 错误(zipfile,文件,递归,compression_level,append = FALSE,:某些文件不存在
- python - 如何搜索列表中的数字是否存在于另一个列表中?
- c++ - 端口转发错误:端口转发未转发到服务器