change the icons of the chart legend - Javascript highcharts

Javascript examples for highcharts:Chart Legend

Description

change the icons of the chart legend

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

.highcharts-legend-item .highcharts-point,
.highcharts-legend-item .highcharts-graph {
   display: none
}


      </style> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/5.0.14/highcharts.src.js"></script> 
      <div id="container"></div> 
      <script type="text/javascript">
var chart = Highcharts.chart('container', {
  series: [{/* w  w  w  .j a va  2 s. c om*/
    data: [1, 2, 4, 11, 66, 5]
  }],
  chart: {
    events: {
      load: function() {
        this.legend.allItems.forEach(function(item) {
          item.legendItem.attr({
            x: item.legendItem.x - 10
          });
        });
      }
    }
  },
  legend: {
    useHTML: true,
    labelFormatter: function() {
      return "<img src='https://www.java2s.com/style/demo/Opera.png' height='20'> " + this.name
    }
  }
});

      </script>  
   </body>
</html>

Related Tutorials