luftikus143
luftikus143

Reputation: 1285

Why are the xAxis labels in my Highcharts graphic so strangely positioned?

I am having trouble to correctly display the xAxis labels. They look like this: enter image description here

I tried to reproduce this in a fiddle, but there, it works fine.

My code looks like this:

        $(function () {
            $.get('graph_sea_ice_extent.csv', function(data)
            {
                var chart = new Highcharts.Chart({
                    chart: {
                        renderTo: "div_graph",
                        type: "line",
                        marginLeft: 40
                    },
                    title: {
                        text: "Arctic Sea Ice Extent",
                        align: "center"
                    },
                    xAxis: {
                        labels: {
                            step: 31
                        },
                        tickWidth: 0
                    },
                    yAxis: {
                        title: {
                            text: "Million sq. km",
                            align: "high",
                            rotation: 0,
                            x: 90,
                            y: -20
                        }
                    },
                    legend: {
                      enabled: false  
                    },
                    data: {
                        csv: data  
                    },
                    plotOptions: {
                        series: {
                            connectNulls: true,
                            shadow: false,
                            lineWidth: 1,
                            color: 'rgba(100, 100, 100, 0.2)',
                            marker: {
                                enabled: false
                            }
                        }
                    }
                });
            });
        });

I remember having read something about Highcharts reading the labels at a too-late stage of the process, so it doesn't know where/how to put them. But I have no idea what could be done to solve this.

Thanks for any hints.

Upvotes: 1

Views: 101

Answers (1)

Pandiyan Cool
Pandiyan Cool

Reputation: 6585

maxStaggerLines: Number

When staggerLines is not set, maxStaggerLines defines how many lines the axis is allowed to add to automatically avoid overlapping X labels. Set to 1 to disable overlap detection. Defaults to 5.(docs link)

Upvotes: 1

Related Questions