pygal

Cannot render_to_file in pygal more than once in Spyder

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 03:42:17
问题 Short version When in Spyder, if I run a script more than once that saves a map with pygal's render_to_file , I get a TypeError . It works fine the first time. Detailed version I'm trying to save a map using pygal (2.4.0) in Python 3.6 as follows: from pygal.maps.world import World worldmap = World() worldmap.add('Random Places', ['mx', 'bz', 'ru', 'th', 'et']) worldmap.render_to_file('random_places.svg') It works fine when I run from the terminal as many times as I want (I'm on Ubuntu). It

pygal ValueError: Invalid PI name 'b'xml''

放肆的年华 提交于 2019-12-13 17:42:57
问题 relative code :hist.render_to_file('1.svg') this picture show the details I have try to install new version of lxml,but can't work; The process I install it just like this: apt-get install libxml2-dev libxslt-dev python-dev pip install lxml Can anybody tell me how to solve it? Thank you! And later I have try to solve it as the conmment said,this is the result. How can I upgrade it?I failed to upgrade it... davenny@davenny-X555LF:~$ pip install --upgrade pygal Collecting pygal Downloading

TypeError: bad operand type for abs(): 'datetime.datetime' when rendering using pygal

时光总嘲笑我的痴心妄想 提交于 2019-12-13 01:24:47
问题 I have a very simple code that should draw an XY chart using pygal library, firstly, the code: @app.route('/graph2/',methods=["GET","POST"]) def graph2(): graph = pygal.XY() f=[('f20', 2868, datetime(2016, 5, 1, 6, 54, 46)),('f21', 2887, datetime(2016, 5, 1, 6, 55, 37)),('c9', 2868, datetime(2016, 5, 1, 6, 55, 42)),('f20', 2868, datetime(2016, 5, 1, 6, 55, 46)),('f21', 2887, datetime(2016, 5, 1, 6, 56, 37)),('c9', 2862, datetime(2016, 5, 1, 6, 56, 42))] graph.add('f21', [(item[2],item[1] if

Save chartkick chart as image or in pdf using python, flask and pisa/ xhtml2pdf

自古美人都是妖i 提交于 2019-12-12 02:32:45
问题 My app is in python using the flask framework. I have a chart that I've generated with chartlink. I'd like to include it on a pdf that I'm outputting with pisa. Is this possible? Is there some way to save the chartkick chart as an image? Or should I look into another chart-generating option like pygal or matplotlib? 回答1: According to the chartkick documentation you can give users the option to download an image of the chart. You will have to include canvg before chartkick.js. Another option

pygal on windows - cannot access classes from pygal

ぐ巨炮叔叔 提交于 2019-12-12 01:38:16
问题 I have such short script: import pygal if __name__ == '__main__': bar_chart = pygal.Bar() and following error: AttributeError: 'module' object has no attribute 'Bar' Do you have any idea what is wrong? Shall I configure some additional paths? I am using windows. Thank you 回答1: If your script is named pygal.py , when you import pygal , it's going to import your script , not the pygal library you installed into your system site-packages. And your script obviously doesn't have a class named Bar

Python Pygal chart pulling data from database not matching values to labels

六眼飞鱼酱① 提交于 2019-12-11 16:18:35
问题 I am working on my first project and I am using Pygal to visualize some data from a database. I am using the latest version of Python (3.6.5), Flask, Pygal and my IDE is Pycharm The project is a simple budget application in which one enters the planned budget for a monthly expenditure and then the actual amounts for that expense/item (e.g. monthly car expenses, like gas). I use Pygal to show 2 bar charts. The first one (which works as intended) shows a total planned amounts vs total actual

Using PyGal, how can I embed a label on the pie chart itself on hover?

我的梦境 提交于 2019-12-10 10:35:16
问题 Using the code below, I can generate a pie chart. When I hover over a slice of the pie, it shows the percentage that slice occupies. import pygal results = [ (15232,'Value 1'), (947,'Value 2'), (246,'Value 3'), (117,'Value 4'), (50,'Value 5'), (50,'Value 6'), (50,'Value 7'), (50,'Value 8'), ] pie_chart = pygal.Pie() pie_chart.title = 'Title!' for r in results: pie_chart.add(r[1], r[0]) pie_chart.value_formatter = lambda x: "%.15f" % x pie_chart.render_to_file('piechart.svg') This produces a

Cannot render_to_file in pygal more than once in Spyder

ε祈祈猫儿з 提交于 2019-12-08 18:55:31
Short version When in Spyder, if I run a script more than once that saves a map with pygal's render_to_file , I get a TypeError . It works fine the first time. Detailed version I'm trying to save a map using pygal (2.4.0) in Python 3.6 as follows: from pygal.maps.world import World worldmap = World() worldmap.add('Random Places', ['mx', 'bz', 'ru', 'th', 'et']) worldmap.render_to_file('random_places.svg') It works fine when I run from the terminal as many times as I want (I'm on Ubuntu). It also works fine when I run it the first time from Spyder (3.2), using F5. Strangely, when I then try to

pygal charts not displaying tooltips in Jupyter / IPython notebook

隐身守侯 提交于 2019-12-06 11:36:24
After much research, I finally managed to get tooltips working in pygal thus: Config = pygal.Config() Config.js = ['http://kozea.github.io/pygal.js/2.0.x/pygal-tooltips.js'] bar_chart = pygal.Bar(Config) # Then create a bar graph object bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) # Add some values bar_chart.render_to_file('bar_chart.svg', force_uri_protocol='https') In the produced .svg, tooltips are now working nicely, but only when the file is opened in a browser . When the chart is displayed directly in Jupyter (either with IPython.core.display.SVG(filename="bar_chart

Pygal Maps World Not Working

耗尽温柔 提交于 2019-12-06 07:58:30
问题 I am trying to create a simple program so as to display the map of central America with their population using Pygal_maps_world.Here's the code for the same import pygal_maps_world as pa wm=pa.World() wm.title="Map of Central America" wm.add('North America',{'cd': 84949494949,'mx': 494794164,'us': 99794616}) wm.render_to_file('map.svg') I have tried a few combinations regarding the importing of the World maps to work properly but to no avail and i am not able to create the visualization. Help