Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将highstock的所有股票报价中的日期更改为UNIX时间戳_Javascript_Highstock - Fatal编程技术网

Javascript 将highstock的所有股票报价中的日期更改为UNIX时间戳

Javascript 将highstock的所有股票报价中的日期更改为UNIX时间戳,javascript,highstock,Javascript,Highstock,我想制作股票报价图(以csv格式从yahoo finance下载并更改为json数组),但日期是标准格式(mm/dd/yyyy),但highstocks只能在unix时间戳中工作(我猜)。请告诉我如何更改时间格式的全部代码。我知道date.parse(),但我不知道如何将其应用于整个数据。 请帮我查一下密码 $(function() { $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?a=e&filename

我想制作股票报价图(以csv格式从yahoo finance下载并更改为json数组),但日期是标准格式(mm/dd/yyyy),但highstocks只能在unix时间戳中工作(我猜)。请告诉我如何更改时间格式的全部代码。我知道date.parse(),但我不知道如何将其应用于整个数据。 请帮我查一下密码

$(function() {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?a=e&filename=aapl-ohlc.json&callback=?', function(data) {

        // create the chart
        $('#container').highcharts('StockChart', {
            rangeSelector: {
                inputEnabled: $('#container').width() > 480,
                selected: 1
            },
            title: {
                text: 'AAPL Stock Price'
            },
            series: [{
                type: 'candlestick',
                name: 'AAPL Stock Price',
                data: [ // Y: [Open, High ,Low, Close]
                    /* May 2006 */
                    [Date.parse("8/2/2012"), 602.84, 610.69, 600.25, 607.79, 83039600],
                    [Date.parse("8/3/2012"), 613.63, 617.98, 611.56, 615.7, 86230200],
                    [Date.parse("8/6/2012"), 617.29, 624.87, 615.26, 622.55, 75525800],
                    [Date.parse("8/7/2012"), 622.77, 625, 618.04, 620.91, 72611700]
                    ["8/7/2012", 622.77, 625, 618.04, 620.91, 72611700],
                    ["8/6/2012", 617.29, 624.87, 615.26, 622.55, 75525800],
                    ["8/3/2012", 613.63, 617.98, 611.56, 615.7, 86230200],
                    ["8/2/2012", 602.84, 610.69, 600.25, 607.79, 83039600],
                    ["8/1/2012", 615.91, 616.4, 603, 606.81, 96125400]
                ],
                dataGrouping: {
                    units: [
                        [
                            'week', // unit name
                            [1] // allowed multiples
                        ],
                        [
                            'month', [1, 2, 3, 4, 6]
                        ]
                    ]
                }
            }]
        });
    });
});
我正在手动输入数据,但我不知道样本数据的用途

 $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?a=e&filename=aapl-ohlc.json&callback=?', function (data) {

当您从json获取数据时,需要在预处理中使用将日期映射到时间戳。使用任何循环/条件准备带有序列的新数组,包括正确的值