最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ajax - JavaScript charts - dynamically adding data points - Stack Overflow

programmeradmin1浏览0评论

I am trying to dynamically add data points to jqplot as a result of AJAX received data, but I do not see a way to acplish this. Is this not possible?

If it isn't, what other packages are available that can acplish the same basic graphing plus allow for dynamic data?

I am trying to dynamically add data points to jqplot as a result of AJAX received data, but I do not see a way to acplish this. Is this not possible?

If it isn't, what other packages are available that can acplish the same basic graphing plus allow for dynamic data?

Share Improve this question asked Jan 22, 2010 at 18:18 David PfefferDavid Pfeffer 39.9k30 gold badges132 silver badges206 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You may want to check the example below on how this is handled in Flot. Flot is an open-source plotting library based on jQuery, like jqplot. Both libraries are very similar.

This is how fetching and plotting the data with AJAX would look like in code:

function fetchData() {
   $.ajax({
      url:      "json_fetch_new_data.php",
      method:   "GET",
      dataType: "json",
      success:  function(series) {
         var data = [ series ];

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

   setTimeout(fetchData, 1000);
}

Make sure to check the following demo to see it in action:

  • Flot Examples - Updating graphs with AJAX

For further information on Flot:

  • Flot Project Site
  • Flot Examples
  • Other Flot Examples
发布评论

评论列表(0)

  1. 暂无评论