rberenguel / bear-note-graph

Generate a graphviz visualisation of your Bear notes. It also has a partial Markdown parser, because why not
39 stars 2 forks source link

Graphs based on individual notes or tags #7

Open mjknght opened 4 years ago

mjknght commented 4 years ago

More feature request than issue: do you have any plans to make it possible to generate a graph not of all notes but from a specific note? (I am aware, for example, that Roam Research has such a feature.)

I have around 9,000 notes, so this is something that would make the tool far more useful to me personally. When I played around with this, restricting by tag appears not to remove the other notes not related to that tag from the graph. I found that using gvpr -c "N[$.degree==0]{delete(NULL, $)}" bear_graph.gv enabled me to remove those to achieve what I wanted, which is great, but means an extra step. But given what the original output is, this would not help me get a graph for a single note?

In the back of my mind, something else that I can imagine being useful in certain instance is to start from a single note and see not just the links, but the links of links – a family tree relating to a single point of departure.

Very aware, in raising these points, that it might be just me! And grateful again for this tool.

rberenguel commented 4 years ago

@mjknght I'm not sure, it's not in the plans because it doesn't fit very well with the current implementation, but it absolutely makes sense as a feature.

Right now the first thing in the pipeline is adapting the same D3 visualisation I use for my site's sitemap for BNG. In this viz, you can filter once the graph is generated, and lets you find only connected pages/notes/tags. I.e. if you search for the title of a note, you find 1-depth links to it.

mjknght commented 4 years ago

Even better than I’d hoped! D3 looks excellent. I'll look forward to giving it a go.

Thanks for getting back to me. In the meantime I've now also managed to generate graphs for single notes from the .gv your tool generates (using this), and am very happy indeed with the results, so I'm flying with creating a few of these graphs, and attaching the PDFs to the notes where they'll be useful. Indebted to you for this!

In case this is of any use, I also had a go at Bear-ifying the configuration. It probably doesn't sufficiently distinguish tag edges enough from note edges at the moment, but here it is:

graph:
  anonymise: False                         # Make the output anonymous
  max_label_length: 260                     # Max length to show of the notes/tags
  include_only_tags: ""                    # Generate graph only for these tags (comma separated)
  exclude_titles: "readings,> "            # Skip all notes with titles containing this (comma separated)
  exclude_tags: "journal,@"                # Skip all tags containing this (comma separated)
  show_tag_edges: True                     # Whether to show tags and the linking between tags and notes
  show_note_edges: True                    # Whether to show note edges
  prune: True                             # Remove all notes with no tags (useful for include_only)
  overlap: False                           # Overlap mode for nodes in the graph
  sep: "+90,90"                            # Margins around nodes
  splines: True                            # Whether to use splines for the arrows
  bgcolor: "#2F3235"         # Background colour for the graph
  free_form: "K=0.9"                       # Any additional parameters to Graphviz
  tmp: "/tmp"                              # Temporary folder for the copy of the Bear SQLite database
  destination: "/tmp/bear_graph"           # Default destination for the Graphviz result
  output_format: "pdf"                     # Format of the output graphviz (only useful if run_graphviz is set)
  run_graphviz: "sfdp"                     # Algorithm to run automatically sfdp or neato recommended

tag:
  shape: "box"                          # Shape
  style: "rounded,filled"                  # Style
  fill_color: "#7A7C7F"      # Fill
  strike_color: "#2f3235"    # Stroke
  free_form: "fontname=\"Avenir Next Medium\", fontcolor=\"#2f3235\""

note:
  shape: "note"
  style: "filled"
  fill_color: "#CE5654"
  strike_color: "#2F3235"
  free_form: "fontname=\"Avenir Next Medium\", fontcolor=\"#ffffff\""

tag_link:
  strike_color: "#57585A"
  arrowhead: "none"                        # Arrowhead
  free_form: "penwidth=\"1.5\""            # You can add any additional parameters

note_link:
  strike_color: "#cfcfcf"
  arrowhead: "dot "
  free_form: "penwidth=\"1.5\""

custom_palette_here:                       # You can inline palettes here
  screaming_color: "#AAAAAA"               # You can inline palettes here
mjknght commented 3 years ago

I hope this finds you well and just wanted to say, in case you have gone further with this project but not yet updated the code here, that I’d love to use the features you hinted at if you were happy to share!

rberenguel commented 3 years ago

@mjknght I didn't move forward with it because it was very hard to use compared with the graphviz result (especially how to open it, since it needs a server), and I moved to work on other personal itches. I haven't been using bear-note-graph much lately (well, it runs automatically on the background daily), which may hint at why I haven't done any upgrades/updates. Hopefully I'll have some days off during the holidays and I will take a look to see what can be done with the D3 version

mjknght commented 3 years ago

I'm very grateful for the tool! And entirely understandable that you would only update it if you were making use of it. Look forward to seeing whatever you do come up with should you return to it, but thanks again, and thanks for this update as well.