Thanks to Highcharts Android wrapper you can now assign native Android callbacks to on click events for specific chart elements. We will show you a small taste of such usage. For these purpose we will let appear a simple Toast with point coordinates when it's clicked but keep in mind that you can achieve much more with HIFunction mechanism!


First of all, you need to create a series:


HISpline spline = new HISpline();
spline.setData(new ArrayList<>(Arrays.asList(0.3,5.3,8.0,9.1,3.2,5.4,4.0,4.2,2.1,10.0)));


Now, you can refer to the point event and add on click callback like this:


spline.setPoint(new HIPoint());
spline.getPoint().setEvents(new HIEvents());
spline.getPoint().getEvents().setClick(new HIFunction(
    f -> {
        Toast t = Toast.makeText(
            this,
            "Clicked point [ " + f.getProperty("x") + ", " + f.getProperty("y") + " ]",
            Toast.LENGTH_SHORT);
            t.show();
        },
        new String[] {"x", "y"}
));


As you can see in the above code snippet first argument of the HIFunction is the actual callback defined in the lambda expression. Second argument is simple array of chart elements. We need to put them here to let wrapper pull them for us during HIFunction instantiation. Thanks to this, we can refer to these elements corresponding values by getProperty() method. You can pull any data from chart like this. Depending on the current needs you can just run some code, withdraw data from chart, return a String to the chart (e.g. in HITooltip formatter) and even put pure JavaScript function in the constructor in the String format. For more information feel free to check the API documentation.



Original info at: the Highcharts Android wrapper GitHub repository