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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?