jqplot里面的AJAX响应不起作用

时间:2014-05-31 15:22:51

标签: javascript jquery ajax jqplot

我尝试使用jqplot将AJAX响应中的数据呈现为条形图。要渲染此条形图,我使用两个变量:

  1. s1,其中包含数字ex:s1 = [22,67,32,89]
  2. 包含与s1 ex中的数字对应的名称的刻度:ticks = [" Jack"," Mary"," Paul","约翰"]
  3. 所以我的AJAX返回两个变量data1和data2。

    • 当我在console.log(data1)时,我得到22,67,32,89
    • 当我在console.log(data2)时,我得到了#34; Jack"," Mary"," Paul"," John"

    然后我添加方括号并更改变量:

    s1 = [data1] ticks = [data2]

    • 当我在console.log(s1)时,我得到[" 22,67,32,89"]
    • 当我在console.log(ticks)时,我得到了#34; Jack"," Mary"," Paul"," John"

    图表没有呈现,这是我的代码:

    s1 = [data1];
    ticks = [data2];        
    
    plot4 = $.jqplot('chartdiv4', [s1], {
                    animate: !$.jqplot.use_excanvas,
                    series:[{color:'#5FAB78'}],
                    seriesDefaults:{
                        renderer:$.jqplot.BarRenderer,
                        pointLabels: { show: true }
                    },
                    axes: {
                        xaxis: {
                            renderer: $.jqplot.CategoryAxisRenderer,
                            ticks: ticks
                        },
                        yaxis:{min:0, max:100, label:'%',labelRenderer: $.jqplot.CanvasAxisLabelRenderer}
                    },
                    highlighter: { show: false }
                });
            });
    

0 个答案:

没有答案