0

I am trying to build a bar chart using highcharts. This is my function:

function monthly_web_login() {

        $.getJSON('monthly_web_login.php', function(data) {

        var chart = new highcharts({
         chart: {
                borderColor: '#98AFC7',
                borderRadius: 20,
                borderWidth: 1,
                renderTo: 'login',
                type: 'bar',
                marginRight: 10,

            },

            exporting: {
            enabled: true
        },
            rangeSelector: {
                enabled:false              
            },

            scrollbar: {
                    enabled: false
                    },
            navigator : {
                enabled : false
            },
            xAxis: {
            type: 'datetime',
            tickInterval: 30 * 24 * 3600 * 1000, // 6 months month
            dateTimeLabelFormats: {
                millisecond: '%H:%M:%S.%L',
                second: '%H:%M:%S',
                minute: '%H:%M',
                hour: '%H:%M',
                day: '%e. %b',
                week: '%e. %b',
                month: '%b',
                year: '%Y'
            }
        },
            yAxis: { // Primary yAxis
                labels: {
                    style: {
                        color: 'blue'
                    }
                },
                gridLineColor: '#197F07',
                gridLineWidth: 0,
                title: {
                    text: 'Monthly Logons',
                    style: {
                        color: 'blue'
                    }
                }
            },

            credits: {
                enabled: false
            },

            title: {
                text: 'TOTAL MONTHLY LOGONS',
                style: {
                    color: '#333000',
                    fontSize: '14px'
                }
            },

            tooltip: {
                pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y} </b><br>',
                valueDecimals: 2
            },
            series: data


    });
    });
}

This is my json file:

[{"name":"logon","pointStart":Date.UTC(2011, 1, 1),"pointInterval":30 * 24 * 3600 * 1000,"data":[284697404,268944957,297847827,287150001,277779620,262275285]}]

this is the html:

<div id="login" style="width:700px; height:300px;"></div>

I dont see any errors and no charts either. Any ideas, what I am doing wrong here?

4

1 回答 1

1

您似乎没有将图表与 DOM 元素相关联。

代替:

var chart = new highcharts({})...

尝试:

var chart = $('#login').highcharts({})...

请参阅此 jsfiddle ( http://jsfiddle.net/pSTcC/ ) 以获取使用您的代码稍作修改的工作示例。

于 2013-09-04T15:53:28.573 回答