I have a requirement where the y-axis labels need to be the following: 1, 0.1, 0.01, 0.001, 0
Is there a way to achieve this custom y-axis in AnyChart?
More or less possible. You can set the desired logarithmic scale with these settings:
var logScale = anychart.scales.log();
logScale.minimum(0);
logScale.maximum(1);
// Get ticks
var ticks = logScale.ticks();
ticks.count(4);
// Minor ticks
var minorTicks = logScale.minorTicks();
minorTicks.count(3);
chart.yScale(logScale);
chart.yAxis({minorTicks: true, minorLabels: true});
However, as far as I know, it is not possible to jump from 0.001 to 0. This happens because internally the from 0.001 to 0 there is a big gap of numbers that we can't just skip while keeping the chart scale consistent.
Demo: https://playground.anychart.com/CnDenhWb/2
On the other hand if you really wish to show only [1, 0.1, 0.01, 0.001, 0]
, then you can add this code:
var ticksArray = [1, 0.1, 0.01, 0.001, 0];
chart.yScale().ticks().set(ticksArray);
This will hide other labels in between 0.001 and 0.