Note that there are some explanatory texts on larger screens.

plurals
  1. POSerialize data for Flot Pie compatibility
    primarykey
    data
    text
    <p>Even though the data I am passing from my server to client is same as Flot accepts but it is not being drawn. There is also an error on the line where I am trying to parse the returned string JSON. Code Below:</p> <pre><code> //server_processing.aspx.cs [WebMethod] public static string GetPieData() { List&lt;PieData&gt; pieData = new List&lt;PieData&gt;(); pieData.Add(new PieData { label = "A", data = 40 }); pieData.Add(new PieData { label = "B", data = 40 }); pieData.Add(new PieData { label = "C", data = 20 }); var serializer = new JsonSerializer(); var stringWriter = new StringWriter(); var writer = new JsonTextWriter(stringWriter); writer.QuoteName = false; serializer.Serialize(writer, pieData); writer.Close(); var json = stringWriter.ToString(); return json; } //PieData.cs [JsonObject(MemberSerialization.OptIn)] public class PieData { [JsonProperty] public string label { get; set; } [JsonProperty] public int data { get; set; } } &lt;%-- Charts.aspx --%&gt; &lt;script type="text/javascript"&gt; var options = { series: { pie: {show: true} } }; $(document).ready(function () { $.ajax({ type: "POST", url: "server_processing.aspx/GetPieData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { // Replace the div's content with the page method's return. var jsObj = []; //Error on the line below //0x800a03f6 - JavaScript runtime error: Invalid character jsObj.push($.parseJSON(msg.d)); // [{label:"A",data:40},{label:"B",data:40},{label:"C",data:20}] $.plot($("#piechart"), jsObj, options); } }); }); </code></pre> <p></p> <p>I did the same thing for the Flot Line Chart and it worked perfectly. Can someone please kindly point me where I am going wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload