Accepted answer

it feels more like a hack than a genuine solution, but i have come up with a workaround that solves my issue for now, i have the function below:

var labelbackground = null;
function labeldrawback(crt) {
    if ( isintraday ) {
        var textbox = crt.yaxis[ 0 ].plotlinesandbands[ 0 ].label;
        if ( !!labelbackground ) {
            labelbackground.attr({ y: textbox.y - 10 });
        } else {
            var box = textbox.getbbox();
            labelbackground = crt.renderer.rect( box.x - 3, box.y + 1, box.width + 6, box.height, 3 ).attr( {
                fill: '#fff',
                id: 'labelback',
                opacity: .65,
                'stroke-width': 0,
                zindex: 4

i make sure this function is executed immediately after the chart is initialized and additionally i attach the function to the chart object that is returned from the stockchart call:

var chartobj = new highcharts.stockchart( chartconfig, function ( crt ) {
        labeldrawback( crt );
} );
chartobj.labeldraw = labeldrawback;

and in the chart options i have added this to the chart.redraw event:

events: {
    redraw: function() {

this works as intended, moving the transparent background with the label (which is moved vertically when the chart is resized). the reason i have redirected the call in the chart redraw event is that the labeldrawback function is defined in another function than the one where my chart options are defined, thus the labeldrawback function is out of scope there.

Related Query

More Query from same tag