AJAXリクエストからjqPlot棒グラフをレンダリングしようとしていますが、動作させることができません。dataRender in jqPlot AJAXリクエストからのASP.NET
私は、次のJavaScriptコードを持っている:
var ajaxDataRenderer = function (url, plot) {
var ret = null;
$.ajax({
// have to use synchronous here, else returns before data is fetched
async: false,
url: url,
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (data) {
ret = data;
}
});
return ret;
};
var jsonurl = "WebService1.asmx/HelloWorld";
plo12 = $.jqplot('chart2', jsonurl, {
title: 'AJAX JSON Data Renderer',
dataRenderer: ajaxDataRenderer,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
// Put a 30 pixel margin between bars.
barMargin: 30,
// Highlight bars when mouse button pressed.
// Disables default highlighting on mouse over.
highlightMouseDown: true
},
pointLabels: { show: true }
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer
},
yaxis: {
// Don't pad out the bottom of the data range. By default,
// axes scaled as if data extended 10% above and below the
// actual range to prevent data points right on grid boundaries.
// Don't want to do that here.
padMin: 0
}
},
legend: {
show: true,
location: 'e',
placement: 'outside'
}
});
そして、私のWebService1.asmx
は次のようになります。
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService {
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string HelloWorld()
{
return "[[2],[7],[14]]";
}
}
私はthisソリューションを見てきましたが、私はこれに新しいですし、私は理解できません私の問題は何か