具有数据表的Highcharts

时间:2012-08-09 13:56:41

标签: highcharts html-table

有一个highcharts的例子:

http://jsfiddle.net/highcharts/z9zXM/

但是我无法在桌面反转x轴和y轴。我的意思是我想要它:

Tokyo       Jan Feb ..
New York
Berlin
London

此外,我想在图表下方的中间找到该表。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

这就是循环的方式:

// 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();

    });



});

以下是链接:http://jsfiddle.net/pJ3qL/1/

然后你应该再次在循环中绘制表格边框;)