Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to get the clicked item from MpAndroidChart(UltimateXF) in Xamarin forms

$
0
0

I'm using MpAndroidChart(UltimateXF) for my app. I created the piechart successfully but I am unable to create a event listener to get the clicked item when user touched one of piechart item.

This is my UltimateXF library....
https://nuget.org/packages/UltimateXF/

This is my code....

    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 + "%";
        }
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles