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

Allow defining a node caption with a function. #48

Merged
merged 1 commit into from
Feb 5, 2019

Conversation

kenkeiras
Copy link
Contributor

This might come in handy when a node caption is a combination of several attributes instead of a single one. The way to use it would be to define the usual configuration with a caption entry that, instead of a constant value, contains a function that takes as first parameter the node and as result outputs the desired caption.

Following the example on the README file:

<script type="text/javascript">

        var viz;

        function draw() {
            var config = {
                container_id: "viz",
                server_url: "bolt://localhost:7687",
                server_user: "neo4j",
                server_password: "sorts-swims-burglaries",
                labels: {
                    "Character": {
                        /* <new functionality> */
                        "caption": (node) => node.properties.name.toUpperCase(),
                        /* </new functionality> */
                        "size": "pagerank",
                        "community": "community"
                    }
                },
                relationships: {
                    "INTERACTS": {
                        "thickness": "weight",
                        "caption": false
                    }
                },
                initial_cypher: "MATCH (n)-[r:INTERACTS]->(m) RETURN *"
            };

            viz = new NeoVis.default(config);
            viz.render();
        }
    </script>```

@johnymontana
Copy link
Contributor

Thanks @kenkeiras! Sorry for the delay in merging this, somehow I missed seeing it.

@johnymontana johnymontana merged commit 8a1023a into neo4j-contrib:master Feb 5, 2019
@kenkeiras kenkeiras deleted the caption-from-function branch February 5, 2019 12:05
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

Successfully merging this pull request may close these issues.

2 participants