Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created addData method #218

Open
Marco-Sulla opened this issue Mar 17, 2016 · 2 comments
Open

Created addData method #218

Marco-Sulla opened this issue Mar 17, 2016 · 2 comments

Comments

@Marco-Sulla
Copy link

I created an addData method, useful if you want append new data instead of replace it entirely.
This is useful to me because server does not send 1 datum to my clients every 1 second, but it sends an array of data every 50 seconds. So I can't use time.line.

Code is written in Javascript. I do not know CoffeScript, so I can't create a pull request.

  Base.prototype.addData = function(data, options) {
    var prepared;
    if (options == null) {
      options = {};
    }
    prepared = this._prepareData((this.rawData = this._formatData(data)));

    var values;
    var toadd_values;
    var add_data = this._annotateLayers(prepared);

    for (var i=0; i<this.data.length; i+=1) {
        values = this.data[i].values;
        toadd_values = add_data[i].values;

        values.push.apply(values, toadd_values);
    }

    return this.data;
  };
@rsandor
Copy link
Collaborator

rsandor commented Mar 17, 2016

So Coffeescript is a 1-to-1 translation of JavaScript. This means that your implementation should be able to be easily transformed in its current state. Please give it a go (even if it doesn't work right off the bat) and I can help you get it all the way via a PR :)

To get started check out the various methods already implemented in the library and use this as a simple reference: http://coffeescript.org/

@Marco-Sulla
Copy link
Author

Well, check it: #220

PS: do you think it's possible to change the behavior of time.line so push() can accept an array of values instead of a single value only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants