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

Do not accept Strings as keys for nodes and edges #44

Closed
bubnenkoff opened this issue Jul 16, 2021 · 3 comments
Closed

Do not accept Strings as keys for nodes and edges #44

bubnenkoff opened this issue Jul 16, 2021 · 3 comments

Comments

@bubnenkoff
Copy link

bubnenkoff commented Jul 16, 2021

My data is not int-based. Because some of real data have leading zero. The graphview crush on next data:

    var json = {
      "nodes": [
        {"id": "01", "label": 'circle'},
        {"id": "02", "label": 'ellipse'},
        {"id": "03", "label": 'database'},
        {"id": "04", "label": 'box'},
        {"id": "05", "label": 'diamond'},
        {"id": "06", "label": 'dot'},
        {"id": "07", "label": 'square'},
        {"id": "08", "label": 'triangle'},
      ],
      "edges": [
        {"from": "01", "to": "02"},
        {"from": "02", "to": "03"},
        {"from": "02", "to": "04"},
        {"from": "02", "to": "05"},
        {"from": "05", "to": "06"},
        {"from": "05", "to": "07"},
        {"from": "06", "to": "08"}
      ]
    };

error:

    The following TypeErrorImpl was thrown building GraphView$(dirty, state: _GraphViewState#a4f6c):
Expected a value of type 'int', but got one of type 'String'

I tried change to:

var a = node.key!.value.toString();

But got error:

Node{position: Offset(0.0, 0.0), key: [<1>], _size: Size(77.0, 48.0)} is not connected to primary ancestor
Node{position: Offset(0.0, 0.0), key: [<2>], _size: Size(77.0, 48.0)} is not connected to primary ancestor
@nabil6391
Copy link
Owner

Hm, I might have to give ability to create keys using strings.

@nabil6391
Copy link
Owner

This is now released in 1.0.0
. Have a look

@RottenSchnitzel
Copy link

RottenSchnitzel commented Mar 15, 2023

Is there anything required to do that? I get a type 'String' is not a subtype of type 'int?' in type cast error.

The function looks like this:

@override
void initState() {
  final node0 = Node.Id("0");
  final node1 = Node.Id("1");
  graph.addEdge(node0, node1);
  builder
    ..siblingSeparation = (10)
    ..levelSeparation = (50)
    ..subtreeSeparation = (100)
    ..orientation = (BuchheimWalkerConfiguration.ORIENTATION_LEFT_RIGHT);
}

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