Say we have nodes and taxonomies linked together in no hierarchical relations.

When we concatenate two views one representing the taxonomy parent child graph and the other representing the node-taxonomy_term we can then merge both views output into 1 big graph.

Is that useful or are there other ways?

See ie #1429168: Does this also support the reference module? have 5 node references on one node

Comments

clemens.tolboom’s picture

An alternative is #1398768: Why not use the views relations to get relations?

I added a new render engine graphapi_raw.module for this purpose. It's output can be merged with other graph output to form a whole.

clemens.tolboom’s picture

For this to happen we need a 'raw' rendering mode which spits out just graph API data.

This would also help debugging graph data.

clemens.tolboom’s picture

Maybe this is better code practise (thanks to li_ tw_ o_l)

   function omgomgomg_views_get_result_rows($view) {
      $rows = array();            
      $fields = $view->get_items('field');
      foreach (array_keys($view->result) as $index) {
        foreach ($fields as $field_id => $field) {
          $field_value = $view->field[$field_id]->get_value($view->result[$index]);
          $rows[$index][$field_id] = $field_value;
        }
      }    
      return $rows;
    }

A hint from merlin@irc

You can use $view->execute() and then $view->result but you will not get any data that relied on a secondary query, which is pretty much anything that is many to one and a few other random things.
You can loop through $view->field and use get_value() to get the proper raw data, but interpreting it may be more difficult than you'd like.

Not sure what's best now :p

clemens.tolboom’s picture

clemens.tolboom’s picture

s.daniel’s picture

I have come across this requirenment before and think it should be adressed at a different level than graphapi. For example if someone ants to build a search based on views across different entity types that is currently not easy to do afaik. (One would probably use searchapi or such)

However since to my knowledge there currently is no such solution I think we probably may think of use case specific code. e.g.:
> How would we create a graph of all users and their relations to all nodes they have via author status or comments.

clemens.tolboom’s picture

The relationship user-comment-node-user would need 2 views.

user-comment-node
+
node-user

and that needs a merge I'm afraid. But it's not a big deal for me now. I'll try to sketch a views UI next week.

Trouble is with views arguments.

clemens.tolboom’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
socialnicheguru’s picture

clemens.tolboom’s picture

@SocialNicheGuru thanks for the pointer. That project does a cross join which only create a http://en.wikipedia.org/wiki/Complete_graph

The idea for this issue is to merge two graphs. That is merge from/to's and add links.

But I guess I could study their code on how do merge views data.

naught101’s picture

I was just thinking along the same lines, that graph nodes/vertexes could be added in one view, and then graph edges could be added in a views attachment. Is it possible for graphapi to take control of both outputs in a single canvas though?

The other way to do it would be to just add the relationship type as one field on the node, and the relationship other end point as another field (and possibly the relationship's directionality). That would lead to a lot of data duplication, especially if you wanted to put lots of other data on the node, but at least it'd be fairly simple. Ignore me, I see that's already the standard method.

clemens.tolboom’s picture

@naught101 my though of line is to render a sub view / graph in a raw format (the array or object 7.x-2.x)

The merge lies in the parent view when outputting to take and integrate the raw data.

Problem I'm facing is duplicate links from child views. When is a link duplicated and when not? #1209426: Multiple links from A to B are not supported

clemens.tolboom’s picture

Issue summary: View changes

Updated issue summary.

clemens.tolboom’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
Issue summary: View changes

This is postponed for 8.x-1.x