pradeepkumarreddy
Posts: 16
Joined: Mon Jun 20, 2022 1:58 pm

How to add axis ticks for plot bands

From the below screenshot, it is difficult to figure out the plot band low and high value by looking at the chart.
Is it possible to add y-axis ticks for the plot bands high and low values ?
Screenshot_20220624-183910.png
Screenshot_20220624-183910.png (31.75 KiB) Viewed 426 times
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: How to add axis ticks for plot bands

Hi pradeepkumarreddy!
We appreciate you reaching out to us!

You can add ticks to wanted places by using tickPositioner, you can write a callback function, which will return an array of ticks.

Demo: https://jsfiddle.net/BlackLabel/honwz0a6/
API Reference: https://api.highcharts.com/highcharts/y ... Positioner

Feel free to ask any further questions.
Best regards!
Hubert Kozik
Highcharts Developer
pradeepkumarreddy
Posts: 16
Joined: Mon Jun 20, 2022 1:58 pm

Re: How to add axis ticks for plot bands

Hi Hubert,
Can you please share the code to do the same on HighCharts Android ?
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: How to add axis ticks for plot bands

pradeepkumarreddy,
Here is a demo with ticks in wanted places by using tickPositioner in Android:

Code: Select all

HIChartView chartView = findViewById(R.id.chartview1);
HIOptions options = new HIOptions();

HIYAxis yAxis = new HIYAxis();
yAxis.setTitle(new HITitle());
yAxis.getTitle().setText("");
HIPlotBands plotBands = new HIPlotBands();
plotBands.setFrom(1);
plotBands.setTo(3);
yAxis.setPlotBands(new ArrayList<>(Arrays.asList(plotBands)));
yAxis.setTickPositioner(new HIFunction("function() { let positions = [], tick = this.dataMin; positions.push(tick); this.userOptions.plotBands.forEach(plotBand => { positions.push(plotBand.from); positions.push(plotBand.to); }); positions.sort(); return positions; }"));
options.setYAxis(new ArrayList<HIYAxis>(){{add(yAxis);}});

HISeries series = new HISeries();
series.setData(new ArrayList<>(Arrays.asList(4.2)));
options.setSeries(new ArrayList<>(Arrays.asList(series)));
Regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Usage”