日期:2014-05-17  浏览次数:20714 次

jqplot咋使用啊
我的图表用了dateaxisrenderer插件,横坐标显示月份,纵坐标显示数量。
jqplot的data 如何获取获取啊,求例子。。。。

------解决方案--------------------
jqplot 获取 json 数据的例子:
$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify(DTO), //JSON.stringify(AnDParms), combined, 
    url: "GetAdmitsDischarges.asmx/GetAandD",
    dataType: "json",
    success: function (data) {
        //do chart stuff here.
        var line1 = [];
        for (var prop_name in data.d) {
            line1.push([prop_name, data[prop_name]])
        }
        var ticks = ['Admits', 'Discharges'];

        var plot1 = $.jqplot('chartdiv', [line1], {
            title: 'Admits & Discharges',
            series: [{ renderer: $.jqplot.BarRenderer}],
            axesDefaults: {
                tickRenderer: $.jqplot.CanvasAxisTickRenderer
            },
            axes: {
                xaxis: {
                    renderer: $.jqplot.CategoryAxisRenderer
                }
            }
        });
        //to prove the flow is working...
        //alert("Data: " + data.d);

    }, //end of success
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert(textStatus + ' ' + errorThrown&