Tuesday, 9 February 2021

Use hyperlinks and add extra notes to each dot in the graph

I am using pygraphviz (I don't want to use other libs).

I am creating a graph with urls and I want them to be clickable and send me to that url in a browser. And I also want to add extra notes to each link when I hover over that link.

This is part of my code (using example.com):

from pygraphviz import *

A = AGraph()
styles = {
    'graph': {
        'label': 'Example',
        'fontsize': '20',
        'fontcolor': 'white',
        'bgcolor': '#333333',
        'rankdir': 'BT',
    },
    'nodes': {
        'fontname': 'Helvetica',
        'shape': 'hexagon',
        'fontcolor': 'white',
        'color': 'white',
        'style': 'filled',
        'fillcolor': '#006699',
    },
    'edges': {
        'style': 'dashed',
        'color': 'white',
        'arrowhead': 'open',
        'fontname': 'Courier',
        'fontsize': '20',
        'fontcolor': 'white',
    }
}

edges = [("https://example.com/", "https://example.com/videos"),
         ("https://example.com/", "https://example.com/videos"),
         ("https://example.com/", "https://example.com/search"),
         ("https://example.com/", "https://example.com/videos?sort=likes-down"),
         ("https://example.com/", "https://example.com/videos?sort=views-down"),
         ("https://example.com/", "https://example.com/videos?sort=duration-down"),
         ("https://example.com/", "https://accounts.example.com/free-signup"),
         ("https://example.com/", "https://accounts.example.com/login")]

A.add_edges_from(edges)
A.draw('example.pdf', prog='fdp')

I want to be able to click all the links and use pdf if possible.

Also, when I hover, I want to show extra notes about that link.



from Use hyperlinks and add extra notes to each dot in the graph

No comments:

Post a Comment