androidscichart

Pie Or Donut chart click listener


How to attach a click listener/ GestureListener to a pie/donut chart in the Android app using sci chart (When a slice is clicked)? I couldn't such a similar method in sci chart

This is how it's done with MPChart.

mChart.setOnChartGestureListener(new OnChartGestureListener() {

        @Override
        public void onChartTranslate(MotionEvent me, float dX, float dY) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onChartSingleTapped(MotionEvent me) {
            // TODO Auto-generated method stub


        }

        @Override
        public void onChartScale(MotionEvent me, float scaleX, float scaleY) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onChartLongPressed(MotionEvent me) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onChartFling(MotionEvent me1, MotionEvent me2,
                float velocityX, float velocityY) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onChartDoubleTapped(MotionEvent me) {
            // TODO Auto-generated method stub

        }
    });

Thanks for reading. :)


Solution

  • To get notifications when slice becomes selected/unselected just add listener for PieSegment by calling addIsSelectedChangeListener()

        final PieSegment pieSegment = sciChartBuilder.newPieSegment().build();
        pieSegment.addIsSelectedChangeListener(new PieSegmentChangeListener() {
            @Override
            public void onPieSegmentChanged(IPieSegment segment) {
                //do something here
            }
        });