Как сделать равномерный цвет для набора узлов в neovis.js / vis.js - PullRequest
0 голосов
/ 27 декабря 2018

Я работаю с приложением Neo4j.И это создает узловой граф.Для отображения узлового графика в пользовательском интерфейсе у нас есть Neovis.js.Имя Neovis.js взято из vis.js.Выходные данные, которые я получаю: -

Neovis Nodal graph

Здесь на рисунке все узлы имеют разные цвета.У нас есть отношения, такие как отдел, функция, система, параметр и т. Д.Мне нужен единый цвет для всех узлов со связью - Параметр и всех узлов со связью - Отдел и т. Д. Как на этом рисунке -

uniform colored nodes

Пожалуйста, предложите изменения в следующих кодах.Это будет очень полезно.

код -

visjs в Neovis.js

visjs: {
        interaction: {
            hover: true,
            hoverConnectedEdges: true,
            selectConnectedEdges: false,
    //        multiselect: true,
            multiselect: 'alwaysOn',
            zoomView: false,
            experimental: { }
        },
        physics: {
            barnesHut: {
                damping: 0.1
            }
        },
        nodes: {
            mass: 4,
            shape: 'neo',
            labelHighlightBold: false,
            widthConstraint: {
                maximum: 40
            },
            heightConstraint: {
                maximum: 40
            }
        },
        edges: {
            hoverWidth: 0,
            selectionWidth: 0,
            smooth: {
                type: 'continuous',
                roundness: 0.15
            },
            font: {
                size: 9,
                strokeWidth: 0,
                align: 'top'
            },
            color: {
                inherit: false
            },
            arrows: {
                to: {
                    enabled: true,
                    type: 'arrow',
                    scaleFactor: 0.5
                }
            }
        }

    }

интерфейс Neovis.js дляузлы отображения

      var config = {
         container_id: "viz",
         server_url: "bolt://localhost:7474/",
         server_user: "neo4j",
         server_password: "ib1",
        labels: {
             //"Character": "name",
             "Banking": {
                 "caption": "name",
                 "size": "pagerank",
                 community: "community",

                 "sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
             },
             "Parameter": {
                "thickness": "weight",
                "caption": true,
                community: "community",
                "sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
            },
            "Method": {
               "thickness": "weight",
               "caption": true,
               community: "community",
               "sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
           },
           "Request": {
               "thickness": "weight",
               "caption": true,
               community: "community",
           },
           "Response": {
               "thickness": "weight",
               "caption": true,
               "community": "Pink"
           },
           "Paths": {
               "thickness": "weight",
               "caption": true,
               "community": "Purple"
           },
           "API": {
               "thickness": "weight",
               "caption": true,
               "community": "Black"
           },
           "Department": {
               "thickness": "weight",
               "caption": true,
               community: "community",
               "sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
           },
           "System": {
               "thickness": "weight",
               "caption": true,
               "community": "Red"
           },

         },
         relationships: {
             "Parameter": {
                 thickness: "weight",
                 caption: true,
                 community: "community",
                 color:'red'
             },
             "Method": {
                "thickness": "weight",
                "caption": true,
                "community": "Blue",
                'color':'red'
            },
            "Request": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'green'
            },
            "Response": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'black'
            },
            "Paths": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'pink'
            },
            "API": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'pink'
            },
            "Department": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'pink'
            },
            "System": {
                "thickness": "weight",
                "caption": true,
                "community": "Red",
                'color':'pink'
            },
         },

         initial_cypher:cypherQuery ,        
        arrows: true,
        hierarchical_layout:true,
        hierarchical_sort_method:"directed",

     };         
...