Skip to content Skip to sidebar Skip to footer

Highcharts With Datatable

There is an example for highcharts: http://jsfiddle.net/highcharts/z9zXM/ However I couldn't reverse x axis and y axis at table. I mean I want it like: Tokyo Jan Feb .. New Y

Solution 1:

This is how the loops should be:

// draw category labels
$.each(series, function(serie_index, serie) {
    renderer.text(
        serie.name, 
        cellLeft + cellPadding, 
        tableTop + (serie_index + 2) * rowHeight - cellPadding
    )
    .css({
        fontWeight: 'bold'
    })       
    .add();
});

$.each(chart.xAxis[0].categories, function(category_index, category) {
    cellLeft += colWidth;

    // Apply the cell text
    renderer.text(
            category,
            cellLeft - cellPadding + colWidth, 
            tableTop + rowHeight - cellPadding
        )
        .attr({
            align: 'right'
        })
        .css({
            fontWeight: 'bold'
        })
        .add();

    $.each(series, function(i) {


        renderer.text(
                Highcharts.numberFormat(series[i].data[category_index].y, valueDecimals) + valueSuffix, 
                cellLeft + colWidth - cellPadding, 
                tableTop + (i + 2) * rowHeight - cellPadding
            )
            .attr({
                align: 'right'
            })
            .add();

    });



});

Here is the link: http://jsfiddle.net/pJ3qL/1/

Then you should draw the table borders inside the loops again if you want ;)

Post a Comment for "Highcharts With Datatable"