Change first tick label on yAxis in stock chart - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

Change first tick label on yAxis in stock chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Jugal | Show tick on min and max of y axis | Highchart &amp; Highstock</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#container{    min-width:500px;
}


      </style> 
      <script type="text/javascript">
    var VanillaRunOnDomReady = function() {
var chartingOptions = {// ww w .j  av  a  2 s.co  m
    yAxis: {
        showFirstLabel: true,
        showLastLabel: true,
        tickPositioner: function(min, max) {
            var interval = Math.round((max - min) / 5);
            var dataMin = this.dataMin;
            var dataMax = this.dataMax;
            var positions = [dataMin];
            var defaultPositions = this.getLinearTickPositions(interval, dataMin, max);
            for (var i = 0; i < defaultPositions.length; i++) {
                if (defaultPositions[i] > dataMin && defaultPositions[i] < dataMax) {
                    positions.push(defaultPositions[i]);
                }
            }
            // push the max value at the end of the array
            positions.push(dataMax);
            return positions;
        }
    }
};
chartingOptions = $.extend({}, jugalsLib.getBasicChartOptions(1, {
    minValue: 0,
    maxValue: 100
}), chartingOptions);
var chart = new Highcharts.StockChart(chartingOptions);
    }
var alreadyrunflag = 0;
if (document.addEventListener)
    document.addEventListener("DOMContentLoaded", function(){
        alreadyrunflag=1;
        VanillaRunOnDomReady();
    }, false);
else if (document.all && !window.opera) {
    document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>');
    var contentloadtag = document.getElementById("contentloadtag")
    contentloadtag.onreadystatechange=function(){
        if (this.readyState=="complete"){
            alreadyrunflag=1;
            VanillaRunOnDomReady();
        }
    }
}
window.onload = function(){
  setTimeout("if (!alreadyrunflag){VanillaRunOnDomReady}", 0);
}

      </script> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.2.js"></script> 
      <script type="text/javascript" src="http://code.jugal.me/js/jugalsLib.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/highstock.src.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/stock/modules/exporting.src.js"></script> 
      <div id="container"></div>  
   </body>
</html>

Related Tutorials