无法使用flot绘制图形

时间:2015-01-23 07:10:46

标签: javascript flot

//我正在尝试使用flotchart在同一图表中绘制多个图形,m使用类别插件,但它不适用于以下数据

$(function() {

    var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ];
           $.plot($("#placeholder"), [
                 {
                    data: data,
                    lines: { show: true, fill: true }
                 }, 
                 {
                  data: data,
                  bars: { show: true, fill: true }
                  } 
            ]);

       });

1 个答案:

答案 0 :(得分:1)

您需要将data放在数组中作为$.plot的第二个参数,并且您的选项格式不正确。试试这个:

$.plot("#placeholder", [ data ], {
    series: {
        lines: {
            show: true,
            fill: true
        },
        bars: {
            show: true,
            fill: true
        }
    },
    xaxis: {
        mode: "categories"
    }
});

这是一个有效的例子:

http://plnkr.co/edit/3SMVMZ1ZcCD8b9DZ3T51?p=preview