Kumar Anand
Kumar Anand

Reputation: 189

JS Highcharts table - How to set Category name

Please check this fiddle - http://jsfiddle.net/kumar4215/kfyajdjq/

I am using similar table structure, to display information, can anyone help me how to set the label name for months as well.

Here's sample code -

/**
 * Create the chart
 */
window.chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container',
        events: {
            load: Highcharts.drawTable
        },
        borderWidth: 2
    },

    title: {
        text: 'Average monthly temperatures'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        title: {
        text:'month'
        }
    },

    yAxis: {
        title: {
            text: 'Temperature (°C)'
        }
    },

    legend: {
        y: -300
    },

    series: [{
         name: 'City',
         data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
      }]
});

Thanks.

Upvotes: 0

Views: 99

Answers (1)

Prashanth kumar
Prashanth kumar

Reputation: 985

Here is a fiddle I made - http://jsfiddle.net/prashu421/7zck9f1g/

Add the below part of JS to your code, and you should be good to go -

    renderer.text(
        "Month", 
        cellLeft + cellPadding, 
        tableTop + (1) * rowHeight - cellPadding
    )
    .css({
        fontWeight: 'bold'
    })       
    .add();

Upvotes: 1

Related Questions