score:0
You can add a labelFormatter
function to your label which will truncate the legend name and add a title element (which provides the tool tip) to the legend text. It's a hacky solution with setTimeout
to wait for the chart to render but it works:
labelFormatter: function() {
var cut = 5,
fullName = this.name;
if (this.name.length > cut) {
setTimeout(function() {
let child = document.createElementNS("http://www.w3.org/2000/svg",'title');
child.innerHTML = fullName;
document.querySelector(".highcharts-legend-item.highcharts-series-" +
this.index).childNodes[0].appendChild(child);
//if you have more then 1 chart at the page
//then you'll need to add the container id to the querySelector
}.bind(this),200)
return this.name.substr(0, cut) + "...";
}
return this.name;
}
EDIT: Based on Kamil Kulig's solution I've made a much shorter and less hacky solution using a wrapper function:
(function(H) {
var old_buildText = H.SVGRenderer.prototype.buildText;
H.SVGRenderer.prototype.buildText = function(wrapper) {
wrapper.styles = wrapper.styles || {};
wrapper.styles.textOverflow = 'ellipsis';
old_buildText.call(this, wrapper);
}
})(Highcharts);
score:0
Another approach is to force ellipsis in Highcharts.SVGRenderer.prototype.buildText
core function. Responsible line:
ellipsis = true, //textStyles && textStyles.textOverflow === 'ellipsis', // force ellipsis
Live working demo: http://jsfiddle.net/kkulig/5qj0uL04/
Source: stackoverflow.com
Related Query
- How do you set the text-overflow property of a highcharts-legend-item to ellipsis in styled mode?
- How do you add text to the bottom center of legend and bottom center of chart under legend?
- How can I add a text link just below the legend box in highcharts
- how do you set the yaxis values in highcharts
- How to set the enable property to a highcharts line in page load
- Highcharts - How to Make the legend item width half of the contianer?
- How do you change the colour of each category within a highcharts column chart?
- How to modify highcharts legend item click event?
- how to set the interval of points on Y - Axis highcharts
- How to change the text color in Highcharts
- How do you increase the performance of highcharts chart creation and rendering
- Highcharts - How to display legend symbol inside the tooltip
- Highcharts - How to set custom colors for the series
- Highcharts Bar Chart - How to set the minimum bar width/length
- How to Check and Uncheck all the Legend elements in HighCharts Linechart?
- How to set the z-index of points on a HighCharts scatter plot?
- How do I remove the color swatch from my HighCharts legend without affecting the column?
- Highcharts (Highstock) how to manually set the navigator selected range
- How do I set the background color of a Highcharts HTML label?
- How do you set the stack order of the series in a stacked bar chart?
- highcharts legend items align to the left when width is set
- How to set series-label to false by default and change the color of series label text in highchart
- How to color series legend in highcharts when colorbypoint is set to true
- highcharts pie monochrome: how to set the default color?
- How to set 'lang' property in Highcharts using Angular JS?
- how to display 2 same highcharts without duplicate the code
- Set custom legend item symbol (or icon) in HIghcharts
- Highcharts server side image generation, how to set up legend labelFormatter in callback argument
- How can you have more than 10 colors represented in the graph and legend in highcharts?
- How to keep the highcharts legend "on" while hiding the series
More Query from same tag
- How to install additional modules included in a Bower package?
- Convert datetime to timestamp milliseconds adding +1 month
- Add Flag based on button event
- Irregular Display of Chart In Highstocks
- HighCharts Map Point with lat and long is not working
- Moving Average Line in Highcharts Scattered Chart
- SplitSeries does not work in Packed Bubble Highchart in r
- applying stock chart style in highchart
- Error in render: "TypeError: Cannot read property 'seriesNames' of undefined"
- How to fill dynamic json value in drill down highchart
- Call addPoint hang in HighCharts
- Highcharts Pie chart not accepting values
- How to make xAxis on bar chart match pointWidth
- DOM Node count increase when loading Highcharts documents (Chrome)
- Highcharts: Dates Off By 1 Month
- Highcharts Output Data to HTML Table
- Highcharts dont show: "undefined is not a function"
- Tick and label for every xAxis Unit in Highcharts Chart
- Resizing Annotation shapes
- Highstock dual x-axis with scrollbar
- Add stacked border color in Highchart?
- Using Highcharts with FastAPI
- Highcharts highmaps points not plotting when second chart loaded
- highcharts and wordpress
- array containing timestamps. push from array when second in current minute = second from each timestamp value in array
- HighCharts show/hide data points
- HighCharts color on each - columnrange bar
- Highmaps with US States in Rails
- Force Highcharts to use my min and max
- HighCharts areaspline multicolor gradient opacity fade