我正在为我的应用程序使用MpAndroidChart(UltimateXF)。我成功创建了饼图,但是当用户触摸饼图项之一时,无法创建事件侦听器来获取单击的项。
这是我的UltimateXF库
https://nuget.org/packages/UltimateXF/
这是我的代码。...
public partial class HomePage : ContentPage
{
public HomePage ()
{
InitializeComponent ();
var entries = new List<PieEntry>();
entries.Add(new PieEntry(40, "Life"));
entries.Add(new PieEntry(60, "General"));
var dataSet4 = new PieDataSet(entries, "")
{
Colors = new List<Color>()
{
Color.Accent, Color.Chocolate
},
ValueLineColor = Color.Blue,
SliceSpace = 2f,
ValueFormatter = new CustomPercentDataSetValueFormatter()
};
var data4 = new PieChartData(dataSet4)
{
};
var dataSet5 = new PieDataSet(entries, "")
{
};
pieChart.ChartData = data4;
pieChart.RotateEnabled = false;
}
}
public class CustomPercentDataSetValueFormatter : IDataSetValueFormatter
{
public string GetFormattedValue(float value, int dataSetIndex)
{
return value + "%";
}
}