Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #200 from jaystream/tree_api
Browse files Browse the repository at this point in the history
edge fix
  • Loading branch information
curtisdelicata authored Jun 28, 2018
2 parents 7b789d4 + 34fd30e commit 0481856
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
23 changes: 22 additions & 1 deletion app/Http/Controllers/Tree/TreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ public function edge($parent_id = 1, $nest = 1)

$tree = $this->getChildren($parents, (int) $nest, false);

return $tree;
$this->linkData = [];
$link = $this->edgeLink($tree[0]['id'],$tree[0]['children']);

$data['tree'] = $tree;
$data['links'] = $link;
return $data;
}


public function edgeLink($currentID, $children){

foreach ($children as $key => $value) {
$this->linkData[] = [
'source' => $currentID,
'target' => $value['id'],
'type' => rand(1,2)
];

$this->edgeLink($value['id'],$value['children']);
}

return $this->linkData;
}
}
31 changes: 11 additions & 20 deletions resources/assets/js/pages/trees/Edge.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div id="graph">
<hierarchical-edge-bundling identifier="id" :data="tree" :links="links" node-text="name" :margin-x="20" :margin-y="20">
<hierarchical-edge-bundling identifier="id" zoomable="true" :data="tree" :links="links" node-text="name" :margin-x="20" :margin-y="20" layoutType="circular" type="cluster">

</hierarchical-edge-bundling>
</div>
Expand All @@ -15,31 +15,22 @@ export default {
},
data() {
return {
tree: [],
links: [{ source: 3, target: 1, type: 1 }, { source: 3, target: 4, type: 2 }],
linkTypes: [
{ id: 1, name: 'depends', symmetric: true },
{
id: 2,
name: 'implement',
inName: 'implements',
outName: 'is implemented by',
},
{
id: 3,
name: 'uses',
inName: 'uses',
outName: 'is used by',
},
],
tree: {
name: "father",
children:[]
},
links: [],
};
},
mounted() {
axios
.get(route('trees.edge', { parent_id: 1, nest: 3 }))
.get(route('trees.edge', {'parent_id':7,'nest':3}))
.then(response => {
this.tree = response.data;
let data = response.data;
this.tree = data.tree[0];
this.links = data.links;
})
.catch(error => this.handleError(error));
},
Expand Down

0 comments on commit 0481856

Please sign in to comment.