简体   繁体   English

高图将不显示数据

[英]Highcharts will not display data

I am pulling data from the mtgox api, I can see in my console that all the data is reaching my chart correctly. 我正在从mtgox api中提取数据,我可以在控制台中看到所有数据都能正确到达图表。 However, I cannot get the data to display on my chart. 但是,我无法使数据显示在图表上。 Any help is appreciated thanks. 任何帮助表示赞赏,谢谢。

     var now = new Date();
        $('#container').highcharts({
            chart: {
                type: 'line',
            },
            title: {
                text: 'Bitcoin Price',
            },
            subtitle: {
                text: 'Source: MtGox.com',
            },
            xAxis: {
                type: 'datetime'
            },
        plotOptions: {
        series: {
            pointStart: Date.UTC(now.getYear(), now.getMonth(), now.getDate()),
            pointInterval: 24 * 3600 * 1000 // one day
        }
    },
            yAxis: {
                title: {
                    text: 'Price'
                },
            },

            series: [{
                name: 'Bitcoin',
                data: series
            }]
        });

    }  
  });

});

I think the issue is that you've wrapped part of your success callback in $(function () {...}) . 我认为问题在于,您已经将成功回调的一部分包装在$(function () {...}) This attaches an event handler that will be fired when the DOM is ready. 这将附加一个事件处理程序,该事件处理程序将在DOM准备就绪时触发。 You won't need it in your AJAX success callback since that is already wrapped in $(document).ready(function() {...}); 您无需在AJAX成功回调中使用它,因为该回调已经包装在$(document).ready(function() {...});

Remove the $(function () {...}) wrapper in your success callback and see if your chart works then. 在成功回调中删除$(function () {...})包装器,然后查看图表是否正常工作。

EDIT 编辑

Also, you need to pass a year, month, and (optional) date to the Date.UTC function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC 另外,您需要将日期,月份和(可选)日期传递给Date.UTC函数: https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC

Working Fiddle 工作小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM