How do I adjust tooltip in Pygal?
<p>I tried to produce a bar chart that visualizes the most-starred projects on GitHub. I added <code>'label'</code> and <code>'xlink'</code> inside tooltips, however, <code>'label'</code> contents are not very well fit in for some items, also, some links are not shown up in certain projects' tooltip. See below,</p>

<p><a href="http://i.stack.imgur.com/WtchD.png" rel="nofollow"><img src="http://i.stack.imgur.com/WtchD.png" alt="enter image description here"></a></p>

<p>Below is the Python code using Pygal module, run it and see the .svg file yourself.</p>

<pre><code>import requests, pygal


url = 'https://api.github.com/search/repositories?q=language:python&amp;sort=star'
r = requests.get(url)
repo_list = r.json()['items']

names, stars = [], []
for k in repo_list:
    names.append(k['name'])
    temp = {
            'value': k['stargazers_count'], 
            'label': k['description'],
            'xlink': k['html_url'],
           }
    stars.append(temp)

my_config = pygal.Config() 
my_config.x_label_rotation = 45

chart = pygal.Bar(my_config)
chart.title = 'GitHub, Python Most Starred Projects'
chart.x_labels = names
chart.add('', stars)
chart.render_to_file('MyFile.svg', force_uri_protocol = 'http')
</code></pre>

<p>How do I solve this problem, either by adjusting font size of tooltip or tooltip window size?</p>

<p>I don't think there's a clean way to do this; I think you'd need to modify the .svg file directly. There's an <a href="https://github.com/Kozea/pygal/issues/324" rel="nofollow">open issue</a> on the Pygal project asking this question. Someone seems to have found <a href="https://github.com/Kozea/pygal/issues/258" rel="nofollow">a solution</a> using <code>\n</code> and the <code>force_uri_protocol='http'</code>, but that doesn't work for me. On my machine <code>\n</code> just gets converted to a single space.</p>

<p>The best I could come up with is truncating the description to a certain number of characters, something like this:</p>

<pre><code>temp = {
        'value': k['stargazers_count'], 
        'label': k['description'][:80] + "..." ,
        'xlink': k['html_url'],
       }
</code></pre>

<p>If you like this solution you can add some logic so short labels don't have the ellipsis at the end. I think this is the solution I'll use next time I run into this issue.</p>

python pygal