0

I have an Eclipse RCP application that uses an SWT browser to visualize data via D3.js. Additionally I'd like now to plot some live data using Cubism.js. The values to plot arrive at irregular intervals at the RCP application.

My current feeble attempt to feed data to the cubism chart from the RCP application is the following (sorry for my bad JavaScript):

function getGraphData(name) {
      var value = 0,
          values = [],
          i = 0,
          last;

    return context.metric(function(start, stop, step, callback) {
    start = +start, stop = +stop;
    values = [];
    if (isNaN(last)) last = start;
        last += step;
        // extVals is a global variable that is set by the RCP application
        for(var j = 0; j < extVals.length; j++){ 
            values.push(extVals[j]);
        }
        // Clear the array
        extVals.length = 0;

    callback(null, values)
    }, name);

}

The current situation is that I can set new data from the RCP application using the global extVals array but the graph will only show those new values if one of them is greater than the previous value in the graph.

Any help on this is greatly appreciated.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
  • I would love to know how you got D3 working in the SWT browser. I'm trying to accomplish that currently. – J. Dimeo Jul 15 '13 at 17:00
  • 1
    @J.Dimeo: I read [this tutorial](http://blog.vogella.com/2009/12/21/javascript-swt/). Per default SWT browser uses IE on Windows to render the website. As I have IE10 installed -which supports D3 in general- the graphs work just fine. – Matthias Braun Jul 17 '13 at 12:56
  • Thanks, I think I discovered that page shortly after my comment. And I'm off to the races! – J. Dimeo Jul 18 '13 at 01:41

1 Answers1

0

I ran into this problem of data arriving at irregular intervals while creating an application that shows stock chart data.

I've described how to fill this data in my Cubism tutorial here: http://xaranke.github.io/articles/cubism-intro/

  • Could you please show me the method that inserts new data into the graph? – Matthias Braun Jun 11 '13 at 23:39
  • if you have multiple series, say S1 that receive data at :01, :07, :11, :13, :15, :24 and S2 at :14, :25, :27, :30, how do you push those data in cusbism chart? would you choose a step of one second and fill with latest data? –  Aug 10 '13 at 06:51
  • @cx Yes, I would fill with the latest available data. I've shown how in the link. –  Aug 10 '13 at 11:28