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

<text> attribute x: Expected length #74

Open
magnaibayar opened this issue Jan 31, 2017 · 0 comments
Open

<text> attribute x: Expected length #74

magnaibayar opened this issue Jan 31, 2017 · 0 comments

Comments

@magnaibayar
Copy link

magnaibayar commented Jan 31, 2017

Hello. I'm glad to using Kartograph library.
But i have a issue about adding label symbols.

Here is my code:

.get('Aimag1.svg', function(svg) {
            var div = $('<div />').addClass('mapnail');
            $('#map').append(div);
            var map = kartograph.map(div, w * 0.5, w/3);           
            map.setMap(svg);

            map.addLayer('provinces', {
                styles: {                        
                    'stroke-width': 0.3,                        
                    'fill': "#FFF",
                    'stroke': "#000"                        
                },
                mouseenter: function(d, path) {                        
                    if(path.attr('fill') != 'red')
                        path.attr('fill', '#c04');                        
                },
                mouseleave: function(d, path) {                        
                    if(path.attr('fill') == '#c04')
                        path.animate({ fill: '#fff' }, 1000);
                },                    
                click: function(data, path, event) {                        
                    if(path.attr('fill') != 'red')
                        path.attr('fill', 'red');
                    else path.attr('fill', '#fff');                        
                },
                tooltips: function(d) {
                    return ['/km<sup>2</sup>'];
                }                    
           
               map.addSymbols({
                type: kartograph.Label,                    
                data: map.getLayer('provinces').getPathsData(),
                location: function(d) { 
                //console.log(map.getLayer('provinces').getPathsData()); 
                //return 'provinces.0'; 
                    return 'provinces.' + d.id
                },
                text: function(d) { return d.namemn; }
            });

And the log is: Error: <text> attribute x: Expected length, "NaN".

Thank you for helping!

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

1 participant