donglang6656 2014-02-04 13:44
浏览 46
已采纳

数据阵列中的Highcharts类别

I'm trying to pull data from a mysql table and set it as the x-axis categories but I don't quite understand how.

Basically, I have Job numbers in a table, and I want to pull those and make them the categories on the x-axis, eventually when a column is clicked for a specific job, it'll drill down for more columns (which add up to the total percentage of the job number).

Here's an example of what I'm trying to do, it works with the column data when using an array there but not with the categories so it wouldn't work this way.

http://codepen.io/anon/pen/BoJqA

How would I go about doing this?

  • 写回答

4条回答 默认 最新

  • douque8855 2014-02-04 14:09
    关注

    I'm not sure if the question is "how can i do this with php/mysql" or "how can i define column names in highcharts". i'll try to answer the latter. try this code to show custom column names instead of 1,2,3,...:

    $(function () { 
        var data = {"name":"Percentage","data":[50,28,150,125,34,75]};
        var categories = [5600, 5700,5800,5900,6000,6100];
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'column'
            },
            title: {
                text: 'Job Budget Report'
            },
            xAxis: {
                categories: categories
            },
            yAxis: {
                title: {
                    text: '% Budget hrs'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                 }]
            },
            series: [data]
        });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?