doujiong3146 2010-07-22 07:31
浏览 44

MYSQL数据+ PHP到FLOTgraphing

im quite new to mysql and flot graphing, but i get the general idea. This is my scenario: I receive data from a device, in which i put into mysql database. am i wrong in saying that the new data will replace the existing data in the database? i then need to plot that on a graph, how do i get(store) the old values so i can put in the data in this line?

 $(function () {
    var d4 = [[36,37],[50,51],null,[23,24],[18,17]];
    $.plot($("#placeholder"), [d4]);
  });

if not, i'll only be getting the current data... and that doesnt give me a line.. it'll give me datapoints haha Thanks for your help!

  • 写回答

1条回答 默认 最新

  • dsfsad089111 2011-03-28 07:25
    关注

    First, you'll want to set the stage for a graph that you can recreate dynamically. To do so, grab your container then fire off an ajax call to the script that wraps up your data. Within the ajax success call, catch the script's results within a function and send it off to a method such as resetGraph that will reset the graph according to the new information found within the database.

    var dataview = $("#placeholder");
    $.ajax({
        url: "index.php",
        data: "stuff&junk&things",
        method: 'GET',
        dataType: 'json',
        success: function(msg){
            resetGraph(msg);
        }
    });
    
    function resetGraph( data ){
    
        plot = $.plot(dataview, data.data, {
            points: { show: true, radius: 5 },
            xaxis: { ticks: data.ticks, tickSize: 7 },
            yaxis: {labelHeight: 2}
        });
    
    }
    

    Your script should be populating arrays with the necessary information then json_encoding it before sending it back to Jquery. For example,

    echo json_encode( 
        array( 
            "data" => array(
                array("data" => array(1,2,3))
            ),
            "ticks" => array(2, "two")
        )
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘