jimmybow / visdcc

Dash Core Components for Visualization.
MIT License
144 stars 18 forks source link

Hovering over edges to make labels visible #37

Closed MaximilianMayerhofer closed 2 years ago

MaximilianMayerhofer commented 2 years ago

Hi! I want to make the labels of all edges invisible except the user hovers over them or selects them. I found this for vis.js, which I'm trying to adapt in viddcc: https://stackoverflow.com/questions/32690394/how-to-hide-label-in-edge-in-visjs-graph Here is the code I'm currently working on:

DEFAULT_OPTIONS = {
    'height': '600px',
    'width': '100%',
    'interaction':{'hover': True},
    # 'edges': {'scaling': {'min': 1, 'max': 5}},
    'physics':{'stabilization':{'iterations': 100}}
}

def get_options(directed, opts_args):
    opts = DEFAULT_OPTIONS.copy()
    opts['edges'] = { 'arrows': { 'to': directed }, 'font': { 'size': 0 }, 'chosen': { 'label': 'function (values,id,selected,hovering) {values.size = 14;}'}}
    if opts_args is not None:
        opts.update(opts_args)
    return opts

The result is, the font is actually set to zero (the labels are invisible), but they do not get visible when hovering over the edges or selecting them. Any suggestions?

jimmybow commented 2 years ago

you can also see advanced usage example code