0
votes

I am using Google Annotated Time Line chart, I want the scale in the Y-axis to show integer numbers only, not fractions(if min is 0 and max is between 1,4).

I have tried to do it using max and min but there are cases where a line exceeds the max, so is there any method to force this chart to display only integer numbers. I have read the options in documentation many times but still no luck.

1
Possible duplicate of this question. - jmac
but this vAxis: {maxValue: 10, format: '0'}} which is included in the answer is not valid in annotated time line chart,i have already tried to use it but seems to have no effect. but thanks anyway for your answer. - JokerDev
you're right -- I didn't realize it was annotated timeline. - jmac

1 Answers

1
votes

You can calculate the max of your data, and set the max of the chart based on that value, or 5, whichever is higher:

var max = 5;
for (var i = 1; i < data.getNumberOfColumns(); i++) {
    if (data.getColumnType(i) == 'number') {
        var range = data.getColumnRange(i);
        max = Math.max(max, range.max);
    }
}

Then in the chart's options, set max: max.