lix joy
lix joy

Reputation: 71

How to display a dynamic node picture using neovis 2.1.0

The following code displays all product nodes with fixed images:

labels: {
    product: {                  
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
            static: { 
                shape: "image",
                image: "drone.svg"
            }
        }
    }   
},   

I now want to display different images on each product node based on its image property, the code below doesn't work:

labels: {
    product: {               
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
            static: { 
                shape: "image",
                image: (props) => props.image
            }
        }
    },     
},        

I tried another encoding, but it didn't work either:

labels: {
    product: {
                 
      shape: 'image',
      image: function(node) {
        return node.properties.image ? node.properties.image  : null;
        }
    }     
},    

would anyone please tell me what should I do? Thanks!

Upvotes: 0

Views: 113

Answers (1)

Finbar Good
Finbar Good

Reputation: 1426

Try:

labels: {
    product: {                  
        [NeoVis.NEOVIS_ADVANCED_CONFIG]: {
            static: { 
                shape: "image"
            },
            function: {
                image: (node) => node.image
            }
        }
    }   
}, 

Upvotes: 0

Related Questions