Jqplot ajax request

Posted by Moozy on Stack Overflow See other posts from Stack Overflow or by Moozy
Published on 2012-11-25T23:01:51Z Indexed on 2012/11/25 23:03 UTC
Read the original article Hit count: 315

Filed under:
|
|
|

I'm trying to do a dynamic content load for JQplot charts, but something is wrong: this is my javascript code:

$(document).ready(function(){

var ajaxDataRenderer = function(url, plot, options) {
var ret = null;
$.ajax({
  // have to use synchronous here, else the function
  // will return before the data is fetched
  async: false,
  url: url,
  dataType:"json",
  success: function(data) {
    ret = data;
    console.warn(data);
  }
});
return ret;


 };


 // The url for our json data   var jsonurl = "getData.php";
     var plot1 = $.jqplot('chart1', jsonurl, {
      title:'Data Point Highlighting', 
 dataRenderer: ajaxDataRenderer,  
  dataRendererOptions: {  
      unusedOptionalUrl: jsonurl
    },

      axes:{
        xaxis: {
                    renderer:$.jqplot.DateAxisRenderer,
                    min: '11/01/2012',
                    max:   '11/30/2012',

                    tickOptions:{formatString:'%b %#d'},
                    tickInterval:'5 days'
                },
        yaxis:{
          tickOptions:{
            formatString:'%.2f'
            }
        }
      },
      highlighter: {
        show: true,
        sizeAdjust: 7.5
      },
      cursor: {
        show: false
      }   }); }); </script>

and it is displaying the chart, but it is not displaying the values, looklike its not getting my data.

output of:

console.warn(data);

is:

[["11-01-2012",0],["11-02-2012",0],["11-03-2012",0],["11-04-2012",0],["11-05-2012",0],["11-06-2012",0],["11-07-2012",0],["11-08-2012",0],["11-09-2012",0],["11-10-2012",0],["11-11-2012",0],["11-12-2012",0],["11-13-2012",0],["11-14-2012",0],["11-15-2012",2],["11-16-2012",5],["11-17-2012",0],["11-18-2012",1],["11-19-2012",0],["11-20-2012",0],["11-21-2012",0],["11-22-2012",0],["11-23-2012",0],["11-24-2012",0],["11-25-2012",1],["11-26-2012",0],["11-27-2012",0],["11-28-2012",0],["11-29-2012",0],["11-30-2012",0]]

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery