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

Live daha support #43

Open
oguzy opened this issue May 10, 2013 · 3 comments
Open

Live daha support #43

oguzy opened this issue May 10, 2013 · 3 comments

Comments

@oguzy
Copy link

oguzy commented May 10, 2013

We are using kartograph.js for displaying live malware information.
We used noverlap at the clustering example: http://kartograph.org/showcase/clustering/ But unfortunately we couldn't figured it out how will the circles' radius will increase when the new data is arrived. It seems there is no easy way for doing that.

@gka
Copy link
Contributor

gka commented May 10, 2013

This is possible, I have used the same technique for the real-time visitor map in Piwik (which used Kartograph.js).

// initally generate the symbol group
symbolgroup = map.addSymbols(...)

function newDataArrived(data) {
   // remove symbols that are gone using .remove(filterFunc)
   symbolgroup.remove(function(symbolData) {
       // eg. remove after one second
       return now - symbolData.created_at > 1000;
   });

   // update existing symbols
   symbolgroup.update({
       radius: function(s) { ... } 
   });

   // add new symbols
   $.each(data, function(i, row) {
      symbolgroup.add(row);
   });
}

You can see this code in action here.

@ggercek
Copy link

ggercek commented May 13, 2013

Hi,

Thanks for the tip.

I have a question about this issue. I manage to show/update symbols real-time but when I use noverlap to cluster symbols then the new symbol does not show up and there is no error.

Is it possible to use noverlap with realtime updates?

Thanks

Here is the code that I used.

        clustering: 'noverlap',
        aggregate: function (data) {
                var nc = { };
                nc[key] = 0;
                nc.country = '';
                nc.country_codes = [];
                $.each(data, function(i, d) {
                    nc[key] += d[key];
                    nc.country_codes = __arrayUnique(nc.country_codes.concat(d.country_codes ? d.country_codes : [d.country]));
                });
                nc.country = nc.country_codes[0];
                return nc;
            },

@ggercek
Copy link

ggercek commented May 19, 2013

I managed to add new symbols to map while using noverlap;

// add new symbols
$.each(data, function(i, row) {
    var s = symbolgroup.add(row);
    var xy = map.lonlat2xy(s.location);
    s.x = xy[0]
    s.y = xy[1]
    s.render();
});

I used following code for non-clustering maps to add new symbols but when I use clustering new symbols does not show up. Moreover last line cause to duplicate the clustered symbols.

// add new symbols
$.each(data, function(i, row) {
    var s = symbolgroup.add(row);
});
symbolgroup.layout().render();

Is there an easy way to do it right? Or my first approach is just fine?

Thanks,
Gurcan

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

3 participants