Skip to content

Commit 19fa28f

Browse files
Add d3 visualisation option
1 parent 9f3224e commit 19fa28f

File tree

7 files changed

+1001
-12
lines changed

7 files changed

+1001
-12
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ This tool aims to -
1717

1818
## Inspiration
1919

20-
This tool is inspired by a number of projects [rubrowser](http://www.emadelsaid.com/rubrowser/) and [cpp-dependencies](https://github.com/tomtom-international/cpp-dependencies) and [objc-dependency-visualizer](https://github.com/PaulTaykalo/objc-dependency-visualizer).
20+
This tool is inspired by a number of projects [rubrowser](http://www.emadelsaid.com/rubrowser/), [cpp-dependencies](https://github.com/tomtom-international/cpp-dependencies) and [objc-dependency-visualizer](https://github.com/PaulTaykalo/objc-dependency-visualizer).
21+
22+
The pretty `d3` visualisations are directly copied from `objc-dependency-visualiser`.
2123

2224
A huge shout out to the poeple behind these projects.
2325

@@ -31,37 +33,39 @@ A huge shout out to the poeple behind these projects.
3133

3234
To generate the overall component depenency graph for a project, use it like so -
3335

34-
`cpp_dependency_graph generate_graph -r spec\test\example_project\ -o deps.dot`
36+
`cpp_dependency_graph visualise -r spec\test\example_project\ -o deps.dot -f dot`
37+
38+
Below is the overall `dot` and `d3` component dependency visualisations for [leveldb](https://github.com/google/leveldb)
3539

36-
Below is the overall componet dependency graph for [leveldb](https://github.com/google/leveldb)
40+
![Dot](examples/leveldb_overall.png)
3741

38-
![Overall component graph of leveldb](examples/leveldb_overall.png)
42+
![D3 Force Directed Graph](examples/leveldb_overall_d3.png)
3943

4044
**NOTE** - If your project has a large number of components (> 100 and lots of connections between them), then generation (and subsequent rendering) may take some time.
4145

4246
### Individual component dependency graph
4347

4448
This will highlight the dependencies coming in and going out of a specific component. This allows you to filter out extraneous detail and study individual components in more detail.
4549

46-
`cpp_dependency_graph generate_graph -r spec\test\example_project\ -c Engine -o deps.dot`
50+
`cpp_dependency_graph visualise -r spec\test\example_project\ -c Engine -o deps.dot -f dot`
4751

4852
Here's a component graph generated for the `queue` component in [rethinkdb](https://github.com/rethinkdb/rethinkdb)
4953

50-
![Queue component graph of rethinkdb](examples/rethinkdb_queue_component.png)
54+
![Queue component dot visualisation](examples/rethinkdb_queue_component.png)
5155

52-
Here's a component graph generated for the `table` component in [rocksdb](https://github.com/facebook/rocksdb)
53-
54-
![Table component graph of rethinkdb](examples/rocksdb_table_component.png)
56+
![Queue component d3 visualisation](examples/rethinkdb_queue_component_d3.png)
5557

5658
### Component include dependency graph
5759

5860
This will highlight dependencies of includes within a specific component
5961

60-
`cpp_dependency_graph generate_graph -r spec\test\example_project\ -c Engine --include -o deps.dot`
62+
`cpp_dependency_graph visualise_includes -r spec\test\example_project\ -c Engine`
6163

6264
Here's a component include graph generated for the `queue` component in [rethinkdb](https://github.com/rethinkdb/rethinkdb)
6365

64-
![Queue include graph of rethinkdb](examples/rethinkdb_queue_include.png)
66+
![Queue include graph dot](examples/rethinkdb_queue_include.png)
67+
68+
![Queue include graph d3](examples/rethinkdb_queue_include_d3.png)
6569

6670
## Development
6771

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [ ] Documentation
44
- [ ] Screencast of how to use tool on projects
5+
- [ ] Create a github.io homepage
56
- [ ] Progress messages
67
- [ ] Progress bar?
78
- [x] Allow user to specify a single component and the tool should print only that component

examples/leveldb_overall_d3.png

83.4 KB
Loading
104 KB
Loading
107 KB
Loading

lib/cpp_dependency_graph/graph_visualiser.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ def generate_html_file(deps, file)
3737

3838
json_nodes = JSON.pretty_generate(nodes)
3939
json_connections = JSON.pretty_generate(connections)
40-
File.write(file, json_nodes + json_connections)
40+
# File.write(file, json_nodes + json_connections)
41+
42+
template = File.read('views/index.html.template')
43+
contents = template % { dependency_links: json_connections }
44+
File.write(file, contents)
4145
end
4246

4347
private

0 commit comments

Comments
 (0)