Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to truncate legend items in Highcharts/Highstock

Working with a responsive site where the page width can shrink and expand, is it possible for items in the legend to truncate?

Series titles could be quite long, so ideally I would want to set the legend items to be around 95% of the chart and then add ellipsis if they are too long.

I've tried using HTML for the legend and applying ellipsis with CSS however this is not working. Any help would be great, thanks.

like image 260
hcharge Avatar asked Nov 30 '25 14:11

hcharge


1 Answers

Latest (4.1.1) version of Highcharts supports inline styles for truncation. So you can do this:

legend:{
    itemStyle: {
            width:'50px',
            textOverflow: 'ellipsis',
            overflow: 'hidden'
        }  
}

http://jsfiddle.net/awq913h1/


Related github issue: https://github.com/highcharts/highcharts/issues/3331
Related JsFiddle: http://jsfiddle.net/highcharts/d4johssh/

like image 111
DanielS Avatar answered Dec 03 '25 05:12

DanielS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!