Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you increase the height of the x-axis labels area on a highchart.js chart?

I have a simple line graph created by highcharts.js. I have a lot of tick marks in the x-axis (30), so I set stagger to 2 deal with the marks overlapping each other horizontally. However, the lower row of x-axis tick labels is being cut off by the end of the chart.

No matter how tall I make the chart the lower row of x-axis tick mark labels is cut off. How can I increase the height of this area to fix this? Or is there some other method?

month_chart = new Highcharts.Chart({
chart: {
    borderRadius: 0,
    height: chart_height,
    marginRight: 30,
    marginBottom: 25,
    renderTo: 'leads-by-month',
    type: 'line',
},
title: {
    text: 'Past 30 Days',
},
xAxis: {
    categories: [<?php print $bymonth_categories; ?>],
    labels: {
        staggerLines: 2,
    },
},
yAxis: {
    title: {
        text: 'Leads',
        style: {color: '#3d3e41', }
    },
    plotLines: [{
        value: 0,
        width: 1,
        color: '#808080'
    }],
    min: 0,
},
plotOptions: {
    line: {
        color: '#578df1',
        dataLabels: {
            enabled: true,
            color: '#3d3e41',
        },
        enableMouseTracking: false
    }
},
legend: {
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'top',
    x: -100,
    y: 74,
    floating: true,
    borderWidth: 1,
    backgroundColor: '#FFFFFF',
    shadow: true
},
series: [{
    name: '<?php print $organization['name']; ?>',
    data: [<?php print $bymonth_data; ?>]
}]
        });
like image 695
Justin Avatar asked Jul 10 '12 20:07

Justin


People also ask

How do I change height in Highcharts?

use chart. setSize(width, height, doAnimation = true); in your actual resize function to set the height and width dynamically.

What is the label of the X axis?

Horizontal axis labels represent the X axis. They do not apply to pie, funnel, or gauge charts. Vertical axis labels represent the Y1 axis in a single axis chart. They represent a numeric scale, usually located on the left side of a vertical chart.

How do you label axes?

Click the chart, and then click the Chart Layout tab. Under Labels, click Axis Titles, point to the axis that you want to add titles to, and then click the option that you want. Select the text in the Axis Title box, and then type an axis title.


1 Answers

Just bump up the marginBottom option. The default is 70 which should be plenty for 2 rows of tick labels, you've set it to 25 which is not.

like image 175
Mark Avatar answered Oct 26 '22 23:10

Mark