Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide the line & symbol next to Highcharts legend items?

Tags:

highcharts

I have my legend aligned with my data series, so I don't want the little sample bit of line/symbol to show next to the legend item.

symbolWidth:0 obviously removes the symbool, but I'm still left with a few pixels of line.

I've looked in the reference guide and can't find any options to adjust this, which seems odd, am I missing something obvious?

like image 572
Codemonkey Avatar asked Apr 23 '15 15:04

Codemonkey


3 Answers

You can hide it simply using css.

This worked for me

Square and circle:

.highcharts-legend-item rect{
    display:none;
}

Line :

.highcharts-legend-item path {
    display: none;
}
like image 98
Akbar Badhusha Avatar answered Oct 26 '22 14:10

Akbar Badhusha


You can hide the symbols using legend options:

legend: {
    symbolPadding: 0,
    symbolWidth: 0,
    symbolHeight: 0,
    squareSymbol: false
},

Highcharts.chart('container', {

  legend: {
    symbolPadding: 0,
    symbolWidth: 0,
    symbolHeight: 0,
    squareSymbol: false
  },

  xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  },

  series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  }, {
    type: 'column',
    data: [95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1]
  }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>

Example: https://jsfiddle.net/BlackLabel/b04woedh/1/

like image 22
Kacper Madej Avatar answered Oct 26 '22 16:10

Kacper Madej


One workout is by giving .001 to hide symbol

 legend: {
   symbolHeight: .001,
   symbolWidth: .001,
   symbolRadius: .001
 },

jsfiddle

like image 37
Aniket Tiwari Avatar answered Oct 26 '22 14:10

Aniket Tiwari