Highcharts with datatable

醉酒当歌 提交于 2019-12-13 05:20:11

问题


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 York
Berlin
London

Also I want to locate that table at middle under chart.

Any ideas?


回答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 ;)



来源:https://stackoverflow.com/questions/11885092/highcharts-with-datatable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!