dtamho6404 2014-07-20 03:49
浏览 30

高清内部日与ajax json php数据

I've been trying to create a highchart intra-day chart with ajax json php data but no luck. please take a look at my code.

chart.php:

//Filename: chart.php
<script type="text/javascript">
$(function() {

    $.getJSON('http://yourdomain.com/json.php', function(data) {

        // create the chart
        $('#container').highcharts('StockChart', {


            title: {
                text: 'AAPL stock price by minute'
            },

            xAxis: {
                gapGridLineWidth: 0
            },

            rangeSelector : {
                buttons : [{
                    type : 'hour',
                    count : 1,
                    text : '1h'
                }, {
                    type : 'day',
                    count : 1,
                    text : '1D'
                }

                /*, {
                    type : 'all',
                    count : 1,
                    text : 'All'
                }*/

                ],
                selected : 1,
                inputEnabled : false
            },

            series : [{
                name : 'AAPL',
                type: 'area',
                data : data,
                gapSize: 5,
                tooltip: {
                    valueDecimals: 2
                },
                fillColor : {
                    linearGradient : {
                        x1: 0, 
                        y1: 0, 
                        x2: 0, 
                        y2: 1
                    },
                    stops : [
                        [0, Highcharts.getOptions().colors[0]], 
                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                    ]
                },
                threshold: null
            }]
        });
    });
});

</script>

json.php:

//Filename: json.php
$arr = array( array(1405578572,2.3,373.25,372.3,2.15),
          array(1405589777,3.3,373.25,372.3,3.15),
          array(1405649399,4.3,373.25,372.3,4.15),
          array(1405649843,5.3,373.25,372.3,5.15),
          array(1405649896,2.3,373.25,372.3,2.15)
);
echo json_encode($arr);

I have tried everything I could but I couldnt get the highchart intra-day chart work with json data.

Please help me with a sample of highchart intra day chart sample with PHP.

Any help is highly appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试