how to get on hover animation of pygal graphs in i

2019-08-11 07:49发布

问题:

I have just started using pygal in ipython after installing CairoSVG with pip and Cairo with homebrew.

The graphs render but when I hover over them there is no interactivity (displaying the frequency for a single bar on a bar graph for example)?

What do I need to install to achieve the same rollover/hover functionality that can be seen in the Pygal Documentation?

http://www.pygal.org/en/latest/documentation/first_steps.html

For example when you click on a legend item on a graph, the legend item is greyed out and hidden. Clicking the legend item again makes it return. When I create the sample First Steps code in Ipython and click on a legend item it doesn't disappear.

回答1:

I stumbled across this issue today. It's the result of a slight typo in the pygal config file.

Fortunately it's simple to fix. Open the config.py file in the pygal directory and add http to the kozea github url as follows:

    js = Key(
    ('http://kozea.github.io/pygal.js/2.0.x/pygal-tooltips.min.js',),
    list, "Misc", "List of js file",
    "It can be any uri from file:///tmp/ext.js to //domain/ext.js",
    str)

That should fix it.



回答2:

I had the same problem, but after checking the code on git, the better solution would be not to change the config.py file, but instead add

force_uri_protocol='https'

as a parameter to your rendering function, e.g.

chart.render_to_file(output_file, force_uri_protocol='https')