0

有一个highcharts的例子:

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

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

Tokyo       Jan Feb ..
New York
Berlin
London

我还想在图表下方找到该表。

有任何想法吗?

4

1 回答 1

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/

然后,如果需要,您应该再次在循环内绘制表格边框;)

于 2012-08-16T06:18:53.747 回答