Help, trying to get force directed vega graph working

Hello All,

I am trying to get a force directed graph working with my data in ES and vega,

Here is a pastebin link to my vega code because its too long to post here.

When I look at the dat with the VEGA_DEBUG on the console in the developer tools it looks as I would expect, but I don't get any paths generated. Can anyone see something wrong with my linkpath? I am at an impasse, I have tried several variations on things but don't seem to be able to make any progress.

Can you provide a schema that includes some data?

Hello @aaron-nimocks,

Thanks for the feedback, here is some example data. (I have hand redacted the values so hopefully I didn't mess it up but should give you a feel for what it looks like)

[
   {
      "_index":"graphing_9_2021",
      "_type":"_doc",
      "_id":"REL_1",
      "_score":1.0,
      "_source":{
         "id":"REL_1",
         "timestamp":1633309253125,
         "type":"relationship",
         "label":"shared",
         "from":"USER_1",
         "to":"CARD_1",
         "from_label":"User",
         "to_label":"CardShare",
         "directionality":"right"
      }
   },
   {
      "_index":"graphing_9_2021",
      "_type":"_doc",
      "_id":"CHAT_1",
      "_score":1.0,
      "_source":{
         "month":"9",
         "year":"2021",
         "id":"CHAT_1",
         "day":"4",
         "timestamp":1633309253197,
         "type":"Chat"
      }
   },
   {
      "_index":"graphing_9_2021",
      "_type":"_doc",
      "_id":"REL_2",
      "_score":1.0,
      "_source":{
         "id":"REL_2",
         "timestamp":1633309253214,
         "type":"relationship",
         "label":"participated",
         "from":"USER_1",
         "to":"CHAT_1",
         "from_label":"User",
         "to_label":"Chat",
         "directionality":"right"
      }
   },
   {
      "_index":"graphing_9_2021",
      "_type":"_doc",
      "_id":"USER_1",
      "_score":1.0,
      "_source":{
         "id":"USER_1",
         "timestamp":1633309266911,
         "user_email":"USER_1@foo.com",
         "email_domain":"foo.com",
         "type":"User"
      }
   }
]

If you can provide it in the format I linked to it would be helpful. You have multiple queries and I wouldn't know how to put that sample data in the correct format.

Hello @aaron-nimocks,

Sorry for the confusion:

Had to pastebin it b/c its too long. anyway I appreciate the assist here!

Thank you

I can help dig in if needed but your initial problem is your table chat-connections-2 is empty. So I would start with that and make sure the data is formatted the same as the demo.

Which means your lookup isn't producing the results as expected.

    {
      "name": "chat-connections-2",
      "source": "chat-connections",
      "transform": [    
        {
          "type": "lookup",
          "from": "nodes",
          "key": "from",
          "fields": ["id"],
          "as": ["source"]
        }
      ]
    }

Hello @aaron-nimocks,

When I am messing with it in the debugger, it appears that when I add the line:

links: user-connections

To the transform section of the nodes mark it makes that table undefined, not sure why, if I comment that one out the table isn't any thoughts?

I would look at the demo I linked to above to see how it works.

The link table needs to look just like the demo on how it's structured. It has to have source.x and source.y along with the target.x and target.y so it knows how to draw the line. Your link source is missing that currently and you would need to backtrack to see where that is missing.

Your data and transformations are doing a lot so it's difficult to visualize what you are doing and why. I might have more time to sit down and look at it all at some point to give a better answer but as of right now what I posted is where the issue is.

Hello @aaron-nimocks,

I believe I am on the right track to resolve this but have a question, how can I get the position of a datum in the table? It looks as though my attempt is failing because the example wants to link items by their position in the data table.

Thank you!

When you say position do you mean index? Here is an example I made before that the data isn't perfect like the demo where I had to do transformations. You can see how I made the index field there.

Yes, I mean the index in the table I was cautious of saying "index" because the source example has an index property as well.

Got ya. If you didn't see I solved that by using the identifier transform which just increments numbers starting at 1. Then I used the formula transformation to subtract 1 from that because it needs to start at 0.

{"type": "identifier", "as": "index"},
{"type": "formula", "as": "index", "expr": "datum['index'] - 1"},

@aaron-nimocks Thank you, that got me to where I needed to be!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.