use CSS3 background linear-gradients for labels - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

use CSS3 background linear-gradients for labels

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Stock Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <style id="compiled-css" type="text/css">

.label {/*  ww  w . j  a v  a  2  s  .  c o  m*/
   color:#fff;
   background-image: linear-gradient(bottom, rgb(26, 7, 57) 37%, rgb(52, 33, 86) 69%);
   background-image: -o-linear-gradient(bottom, rgb(26, 7, 57) 37%, rgb(52, 33, 86) 69%);
   background-image: -moz-linear-gradient(bottom, rgb(26, 7, 57) 37%, rgb(52, 33, 86) 69%);
   background-image: -webkit-linear-gradient(bottom, rgb(26, 7, 57) 37%, rgb(52, 33, 86) 69%);
   background-image: -ms-linear-gradient(bottom, rgb(26, 7, 57) 37%, rgb(52, 33, 86) 69%);
   background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.37, rgb(26, 7, 57)), color-stop(0.69, rgb(52, 33, 86)));
}


      </style> 
      <script type="text/javascript">
$(function () {
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container'
        },
        yAxis: {
            labels: {
                useHTML: true,
                formatter: function () {
                    return '<div class="label">' + this.value + ' </div>';
                }
            }
        },
        series: [{
            name: 'USD to EUR',
            data: [1, 2, 3, 4, 5, 6, 7, 8]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <script src="https://code.highcharts.com/highcharts.js"></script>  
   </body>
</html>

Related Tutorials