模态显示后,amChart无法初始化

时间:2016-08-01 09:58:01

标签: ajax modal-dialog amcharts

$.ajax({
        cache: false,
        type: "POST",
        url: route,
        data: data,
        success: function(response){
            $('#evolutieProdus').show();
            function showEvProd(data){                                          
                var chart = AmCharts.makeChart("chart_2",{
                "type": "serial",
                  "theme": "dark",                     
                  "dataProvider" : data,
                  "valueAxes": [ {
                    "gridColor": "#FFFFFF",
                    "gridAlpha": 0.2,
                    "dashLength": 0
                  } ],
                  "gridAboveGraphs": true,
                  "startDuration": 1,
                  "graphs": [ {
                    "balloonText": "[[date]]: <b>[[bucati]] bucati vandute </b>",
                    "fillAlphas": 0.8,
                    "lineAlpha": 0.2,
                    "type": "column",
                    "valueField": "bucati"
                  } ],
                  "chartCursor": {
                    "categoryBalloonEnabled": false,
                    "cursorAlpha": 0,
                    "zoomable": false
                  },
                  "categoryField": "date",
                  "categoryAxis": {
                    "gridPosition": "start",
                    "gridAlpha": 0,
                    "tickPosition": "start",
                    "tickLength": 20
                  },
                  "export": {
                    "enabled": true
                  }             
                }); 
            }
            showEvProd(response);
            console.log(response);              
        },
        error: function(){
            toastr.error('Eroare, ceva nu a functionat corect, reveniti mai tarziu');
        }       
    }); 

这是我的ajax电话。我收到了数据的回调,但在图中我看到的都是未定义的。我的代码有什么问题。 附:如果我对dataProvider对象进行硬编码就可以了。但我想通过ajax响应加载服务器提供的数据。

0 个答案:

没有答案