weixin_33695082 2014-07-15 15:17 采纳率: 0%
浏览 26

更新浮点数据和轴

I have created a highly interactive graph. all of the interactions have been achieved without re-initiating the flot object. re-initiating the flot object causes the interactions to break, i would have liked to have done this as efficiently as possible.

the interactions my graph supports are:

  • changing visibility of individual series
  • multiple y-axes and toggling between them
  • zoom graph(with a reset)
  • click and drag panning

the final two features i have to add are:

  • adding/subtracting individual series
  • updating individual series

both of which require ajax requests, the graph must support 1000's of datapoints so efficiency is key (i will have to reduce the datapoints at some point).

as i mentioned i have managed to do all of this so far without multiple calls to $.plot, i have used plugins in-built functions and setting some options from the getOptions() method. instead of using $.plot i call the plot.draw() method to update the chart. But, i am struggling to find anyway to push data into the provided methods that don't involve calling the entire function again (besides doing so makes it harder to keep track of the variables i am changing in options.)

My question is has anyone had experience with updating, not replacing, flot axes and data using ajax requests and how were you able to achieve efficient results?

  • 写回答

1条回答 默认 最新

  • ?yb? 2014-07-16 16:25
    关注

    The method you are missing is the setupGrid. This will recreate the axises without re-initing the plot.

    In general my workflow for modfiying an existing plot is something like this:

    var series = plot.getData(); // reference to your series
    series[0].data = someNewArray;
    series[0].color = 'blue'; // modify existing series
    series.push({data: [[0, 5], [1, 1], [2, 7]], color: 'green'}); // add a new one
    plot.setData(series); // you need to set the data so that flot will re-process any newly added series
    var opts = plot.getOptions() // get a reference to the options
    opts.xaxes[0].min = -1; // adjust an axis min, use the xaxes property NOT the xaxis
    // there is no need to "setOptions"...
    plot.setupGrid() // if you need to redraw the axis/grid
    plot.draw()
    
    评论

报告相同问题?

悬赏问题

  • ¥15 鸿业暖通修改详细负荷时闪退
  • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体