Mike
Mike

Reputation: 33

How to add tooltip in a node using jsMind library?

I want to customize my mind map using jsMind

Currently this is my code:

var mind = {            meta: {
                        name: 'jsMind remote',
                        author: '[email protected]',
                        version: '0.2',
                    },
                    format: 'node_tree',
                    data: {
                        id: 'root',
                        topic: 'jsMind',
                        children: [
                            {
                                id: 'easy',
                                topic: 'Easy',
                                direction: 'left',
                                children: [
                                    { id: 'easy1', topic: 'Easy to show' },
                                    {
                                        'id': 'other3',
                                        'background-image': 'ant.png',
                                        'width': '100',
                                        'height': '100',
                                    },
                                ],
                            },
                            {
                                id: 'open',
                                topic: 'Open Source',
                                direction: 'right',
                                children: [
                                    {
                                        'id': 'open2',
                                        'topic': 'BSD License',
                                        'leading-line-color': '#ff33ff',
                                    },
                                ],
                            }
                };
                _jm.show(mind);

Any ideas to complete this challenge are welcome.

I tried to execute in the browser but i don't know how to implement that i wanted to do. EDITED I have changed the code a made a new line perfectly but a tooltip doesn't appear. enter image description here

Upvotes: 3

Views: 400

Answers (2)

dante vitale
dante vitale

Reputation: 36

you can add a span with its ID in topic and then use tippy:

          var mind = {
                meta: {
                    name: 'math1',
                    author: 'myself',
                    version: '0.1',
                },
                format: 'node_array',
                data: [
                    { id: 'root', isroot: true, topic: '<span id="t_root" >Trasporto ottimale (Monge-Kantorovich)</span>' },

.....

<script src="js/popper.min.js"></script>
<script src="js/tippy.js"></script>
<script>
  tippy('#t_root', {
    content: 'Teoria che si occupa di capire come trasportare una distribuzione di massa da un posto ad un altro in maniera ottimale',
  });
</script>

Upvotes: 1

hizzgdev
hizzgdev

Reputation: 21

jsMind does not provide a built-in mechanism to display tooltip, but the topic of node can be HTML, so would you like to have a try to add a tooltip to it with HTML? Like that:

var mind = {
    // ...
    data: {
        id: 'root'
        topic: '<span title="good">jsMind Example<span>'
    }
    // ...
}

screenshot of it

Upvotes: 1

Related Questions