Get max value of y-axis

Hi,

is there a possibility to get the max value of a y-axis? Hard to explain why i want that, but i’ll try. I have a line diagramm with open user connections over time (x-axis: time, y-axis: connections). To have a smooth y-axis scale, i only set ticks{min:0, suggestedMax: 3}. Now there ist a second line for total possible connections (default: 80). I have set that data on another y-axis and i want its ticks with the percentage of the highest possible tick of the first y-axis.

for example:
dataset_1(user connections) = [0,1,2,1,1] -> max value is 2 but ticks of y-axis go from 0 to 3
total possible connections : 80
->dataset_2(percentage) = 3/80*100 = 3.75 ->[3.75,3.75,3.75,3.75,3.75] -> max value set to 3.75

Thats why i need the 3 of dataset_1 as max

Greetings

Author: Fantashit

3 thoughts on “Get max value of y-axis

  1. @Ofenlord you can get this info for numerical scales (linear and logarithmic):

    // Find the scale in the chart instance
    var axis = chartInstance.scales.<scale id>;
    var max = axis.max;
    var min = axis.min;
  2. Hello, regarding with this issue. Is it possible to get the max and min for y-axis? Can I do like this?

    yAxis: {
    ticks: {
    suggestedMin: min – 1,
    suggestedMax: max + 1,
    }
    }

Comments are closed.