I'm currently working on a responsive chart that features a dynamic text box positioned next to the chart itself. This text box updates with new information each time I hover over data points on the chart.
Interestingly, the text box functions perfectly on smaller screens when hovering over the first data set. However, it fails to update or display properly when hovering over the second and third sets of data.
If you'd like to see for yourself, check out this live demo: http://jsfiddle.net/b0u10ndw/
Below is the code snippet responsible for the responsive behavior:
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
align: 'center',
verticalAlign: 'bottom',
layout: 'horizontal'
},
series: { point: { events: { mouseOver: function () {
var chart = this.series.chart;
if (!chart.lbl) {
chart.lbl = chart.renderer.label('')
.add();
}
chart.lbl
.show()
.css({ width: '80' })
.attr({ text: 'this is the text and I have to make it really long so that it goes for multiple lines' });
chart.lbl.align(Highcharts.extend(chart.lbl.getBBox(), {
align: 'right',
x: 0, // offset
verticalAlign: 'top',
y: 50 // offset
}), null, 'spacingBox');
}
} } },
To observe the issue in action, simply resize the chart to a smaller size and hover over each bar one by one.
Although I attempted to set the width of the text box as a percentage, it appears that only pixel units are being accepted at this time.