How to get min, max after selection of chart
I am trying to fetch a range of xAxis after selection in the chart. This is a simple demo and it's not working in HighChart 7.1.1. I am always getting the value of xMin and xMax as null.
HIChartView chartView = (HIChartView) findViewById(R.id.hc);
HIOptions options = new HIOptions();
HIChart chart = new HIChart();
chart.setType("line");
chart.setZoomType("x");
chart.setEvents(new HIEvents());
chart.getEvents().setSelection(new HIFunction(
f -> {
String xMin = (String) f.getProperty("min");
String xMax = (String) f.getProperty("max");
Log.d("log", "min and max : = " + xMin + "" + xMax);
// Log.d("log", "min and max : = " + f.getProperty("min") + "" + f.getProperty("max"));
},
new String[]{"min", "max"}
));
options.setChart(chart);
HITitle title = new HITitle();
title.setText("Demo chart");
options.setTitle(title);
HILine series = new HILine();
series.setData(new ArrayList<>(Arrays.asList(49.9, 71.5, 106.4, 129.2, 144, 176, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4)));
options.setSeries(new ArrayList<HISeries>(Collections.singletonList(series)));
chartView.setOptions(options);
My question is similar to IOS issue related to Highchart https://github.com/highcharts/highcharts-ios/issues/193 but IOS solution is not working in android. I tried function with event.xAxis[0].min and event.xAxis[0].max. it also giving null value.
Kindly take a look in this bug.
Hello @gauravgupta188 ! Thanks for the question. At this moment, functions which need passing a reference via an argument in the original framework are not supported in the Android wrapper yet. The issue you presented needs such reference. You can pass a javascript function to HIFunction class to print the min and max values in the console but unfortunately, you can't get them in native code.
chart.getEvents().setSelection(new HIFunction("function(events) { console.log('value: ' +events.xAxis[0].max);}"));