无法获得高图表的结果



我使用highchart,它给出了结果。

但是,当我要创建日期范围时,什么都没有发生,甚至我的结果都是空白的!

我只是想找出我错在哪里!

下面是我的代码:
<script type="text/javascript">
    $(document).ready(function() 
    {
        var options = { 
            chart: 
            {
                renderTo: 'container',
                type: 'column',                                
                marginRight: 130,
                marginBottom: 25
            },
            rangeSelector: 
            {
                selected: 1,
                inputDateFormat: '%Y-%m-%d',
                inputEditDateFormat: '%Y-%m-%d'
            },
            title: 
            {
                text: 'Project Requests',
                x: -20 //center
            },
            subtitle: 
            {
                text: '',
                x: -20
            },
            xAxis: 
            {
                categories: []
            },
            yAxis: 
            {
                title: 
                {
                    text: 'Requests'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: 
            {
                formatter: function() {
                    return '<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y;
                }
            },
            legend: 
            {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -10,
                y: 100,
                borderWidth: 0
            },                      
            series: []
        }
        $.getJSON("data", function(json) 
        {
            options.xAxis.categories = json[0]['data'];
            options.series[0] = json[1];
            options.series[1] = json[2];
            // options.series[2] = json[3];
            chart = new Highcharts.StockCart(options);
        });
        function (chart) 
        {
            setTimeout(function () 
            {
                $('input.highcharts-range-selector', $(chart.container).parent())
                .datepicker({
                    format: "dd/mm/yyyy",
                    todayBtn: "linked",
                    orientation: "auto left",
                    autoclose: true,
                    todayHighlight: true
                });
            }, 0);
            $.datepicker.setDefaults
            ({
                dateFormat: 'yy-mm-dd',
                onSelect: function (dateText) {
                    this.onchange();
                    this.onblur();
                }
            });
</script>

这里是我的控制器:

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Chart extends CI_Controller
{
    public function __construct() 
    {
        parent::__construct();
        $this->load->database();
        $this->load->model('Data');
        $this->load->helper('url');
    }
    public function index()
    {
        //echo "adsf";exit;
        $this->load->view('allindex');
    }
    public function data()
    {
            $data = $this->Data->get_data();
            $category = array();
            $category['name'] = 'date';
            $series1 = array();
            $series1['name'] = 'employee_id';
            $series2 = array();
            $series2['name'] = 'customer_id';
//            $series3 = array();
//            $series3['name'] = 'sale_id';
            foreach ($data as $row)
            {
                $category['data'][] = $row->date;
                $series1['data'][] = $row->employee_id;
                $series2['data'][] = $row->customer_id;
//                $series3['data'][] = $row->sale_id;
            }
            $result = array();
            array_push($result,$category);
            array_push($result,$series1);
            array_push($result,$series2);
//            array_push($result,$series3);
            print json_encode($result, JSON_NUMERIC_CHECK);
    }

这是模型:

 <?php
class Data extends CI_Model
{
    public function __construct() 
    {
        parent::__construct();
    }
    public function get_data()
    {
        $this->db->select('date,sale_id,employee_id,customer_id');
        $this->db->from('ospos_sales');
        $this->db->where("`date` BETWEEN '2013-10-11' AND '2013-10-12'");
        $query = $this->db->get();
        return $query->result();
    }
}

唯一的想法是dateFormat有问题。试着注释这几行

inputDateFormat: '%Y-%m-%d',
inputEditDateFormat: '%Y-%m-%d'

i have more idea

最新更新