tags:

views:

598

answers:

2

The code in javascript is

$(document).ready(function () {var options = {
    series: { points: { show: true }, shadowSize: 0 },
    xaxis: { mode: "time" },
    yaxis: {  min:0, max: 100 },
    pan: { interactive: true }};
    $.getJSON("http://localhost:8085/WebApplication1/metricsJson.jsp?instanceId=3457",
        function(data){
        alert(data);
        var plot = $.plot($("#placeholder"), data, options);
  });});

and http://localhost:8085/WebApplication1/metricsJson.jsp?instanceId=3457 returns

{"data":[[[1258216500000,4.91],[1258212240000,4.39],[1258216920000,4.46],[1258211640000,4.39],[1258210980000,4.82] ]]}

thank you

+1  A: 

I normally test before I post, but I will post blindly here.

I believe one thing to check is how you pass the data to flot. I think your call to the flot plotter should look like this (given how you have your variables named):

$.plot($("#placeholder"), data.data, options);

That's because of how JSON works.

Second, I think flot expects a 2d array, not a 3d one. Your JSON object consists of an array of 2 element arrays within another array. If you can, have your server only return a 2-d array. Otherwise you could try:

$.plot($("#placeholder"), data.data[0], options);
jeremyosborne
It will work if you pass `data.data`, here is a working example using the given options and data: http://jsbin.com/udace
Ryan Lynch
Thanks Ryan! I wasn't set up here to try it out.
jeremyosborne
I tried both data.data and data.data[0], still the graphs do not get plotted.
Santhosh S
thank you Ryan and jeremy...It works in firefox. In IE I get the foll error Webpage error detailsUser Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)Timestamp: Sat, 14 Nov 2009 18:05:16 UTCMessage: 'window.G_vmlCanvasManager' is null or not an objectLine: 554Char: 17Code: 0URI: http://localhost:8085/WebApplication1/jquery.flot.js
Santhosh S
the problem still persists .. with $.getjson it does not work.I am sending the response back as string from the getJson URL ... should I change something there ?
Santhosh S
Hi Santhosh, Flot uses Canvas, which is a tag that is not supported natively by IE. I found an article, http://www.wpwp.org/forums/topic/not-seeing-main-stat-graph, where someone experienced essentially the same error. IE8 updates, in my experience, have "broken" the IE canvas compatibility layer. I would check and make sure that you are using the most recent version of flot.
jeremyosborne
A: 

Are you certain you have included "js/flot/excanvas.min.js" for the IE browser?