Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts write xaxis values on 2 different lines

Tags:

highcharts

I am using the following for the x axis:

 xAxis: {
                        type: 'datetime',
                        tickInterval: 3600 * 1000, // one hour
                        tickWidth: 0,
                        gridLineWidth: 1,
                        gridLineColor: '<?php echo($gridlinecolor); ?>',
                        labels: {
                            align: 'center',
                            x: -3,
                            y: 20,
                            formatter: function() {
                                return Highcharts.dateFormat('%d-%m', this.value) + ' / '  + Highcharts.dateFormat('%l%p', this.value);
                            }
                        }
                    }

Which gives me things like 13-02 / 4PM.

I would like to have this with a new line like 13-02 4PM

How can I achieve this?

Thanks,

John.

like image 756
user2040597 Avatar asked Nov 30 '25 20:11

user2040597


1 Answers

You can use the html <br/>:

formatter: function() {
    return Highcharts.dateFormat('%d-%m', this.value) + '<br/>'  + Highcharts.dateFormat('%l%p', this.value);
}

Example fiddle here.

See the section here on HTML in Highcharts.

like image 183
Mark Avatar answered Dec 02 '25 20:12

Mark



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!