Set Max value for Y Axis in a Chart

Comments

4 comments

  • Avatar
    Brian Wilson

    Quick and easy -- thanks Shruthi!

    0
    Comment actions Permalink
  • Avatar
    Janet Erdman

    It worked great for almost all but I had this one widget that it didn't work on for some reason for the red data. I'm on version 8.1.3.11001 if that helps.

     

    1
    Comment actions Permalink
  • Avatar
    Adrian Guzy

    Hi Janet,

    You probably know that already because your post is quite old but the script doesn't work with this graph because it's using "break by".

    0
    Comment actions Permalink
  • Avatar
    Adrian Guzy

    The script below is an amended version that should work with a widget using "classic break by".

    widget.on('processresult',function(widget, ev){

    max_data_value = 0      

    for (var i=0; i<ev.result.series.length; i++){

                    for (var j=0 ; j<ev.result.series[i].data.length; j++){

                                    if (ev.result.series[i].data[j].y > max_data_value) {

                                                    max_data_value=ev.result.series[i].data[j].y;}

    }

    }

    var increase_percent = 0.2; // Change the value as needed

    ev.result.yAxis[0].max = max_data_value + increase_percent * max_data_value;

    })

    0
    Comment actions Permalink

Please sign in to leave a comment.