Reporting, web et print

Arthur Vuillard, #!⌨

Reporting, web et print

Arthur Vuillard, #!⌨

Mon problème dans la vie

N'y aurait-il pas de solution plus... pythonesque ?

Un rapport ?

Et pourquoi pas du java ?

Résultat

Résultat print

Solution Python

Pygal

Pygal : code

line_chart = pygal.Line()
line_chart.title = 'Browser usage evolution (in %)'
line_chart.x_labels = map(str, range(2002, 2013))
line_chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 
45.5, 46.3, 42.8, 37.1])
...
line_chart.render()
        

Pygal : code

Browser usage evolution (in %)200220032004200520062007200820092010201120120.010.020.030.040.050.060.070.080.0094.1769230769307.96153846216.6136.984615385249.54751658625179.792307692219.9886139531222.6198.87511206736.4265.407692308179.87296037345.5308.215384615147.85081585146.3351.023076923145.03568226642.8393.830769231157.35189169837.1436.638461538177.4097184870265.407692308307.9615384623.9308.215384615294.23776223810.8351.023076923269.95723507323.8393.830769231224.21131432735.3436.638461538183.74376905185.88.561538461546.0384615384684.651.369230769210.26116191584.794.17692307699.9092702169674.5136.98461538545.802223417666179.79230769275.713017751558.6222.6101.75300340754.7265.407692308115.47677963144.8308.215384615150.31405773736.2351.023076923180.57674376926.6393.830769231214.35834678120.1436.638461538237.23130715414.28.56153846154257.99291733915.451.3692307692253.77021696315.394.1769230769254.1221086618.9136.984615385276.6431773359179.792307692276.29128563710.4222.6271.3648018658.9265.407692308276.6431773355.8308.215384615287.5518199756.7351.023076923284.3847946926.8393.830769231284.0329029947.5436.638461538281.56966110816.6253136.445.546.342.837.13.910.823.835.385.884.684.774.56658.654.744.836.226.620.114.215.415.38.9910.48.95.86.76.87.5FirefoxChromeIEOthersBrowser usage evolution (in %)

Pygal : exemples

Browser usage evolution (in %)200220032004200520062007200820092010201120120.010.020.030.040.050.060.070.080.0093.0094405594307.96153846216.6131.925524476278.75452752425170.841608392263.97507620631209.757692308253.41832526436.4248.673776224243.91724941745.5287.58986014227.90617715646.3326.505944056226.49861036442.8365.422027972232.6567150837.1404.338111888242.6856284740257.235314685307.9615384623.9296.151398601301.0996503510.8335.067482517288.95938676723.8373.983566434266.08642639435.3412.89965035245.85265375685.832.3003496503157.084.671.2164335664159.11135018884.7110.132517483158.93540433974.5149.048601399176.8818809466187.964685315191.83727810758.6226.880769231204.85727093454.7265.796853147211.71915904644.8304.712937063229.13779809936.2343.629020979244.26914111526.6382.545104895261.15994262120.1421.461188811272.59642280814.240.8618881119282.977227915.479.777972028280.86587771215.3118.694055944281.0418235618.9157.61013986292.3023578999196.526223776292.12641204910.4235.442307692289.6631701638.9274.358391608292.3023578995.8313.274475524297.7566792186.7352.190559441296.1731665776.8391.106643357295.9972207287.5430.022727273294.76559978516.6253136.445.546.342.837.13.910.823.835.385.884.684.774.56658.654.744.836.226.620.114.215.415.38.9910.48.95.86.76.87.5FirefoxChromeIEOthersBrowser usage evolution (in %)

Pygal : exemples

Browser usage in February 2012 (in %)19.66%283.114871902105.73028135136.90%290.681741008222.11967194736.59%164.453391678167.7139731944.54%218.2410343994.9492048062.32%234.13096221992.049268677719.66%36.90%36.59%IEFirefoxChromeSafariOperaBrowser usage in February 2012 (in %)

Pygal : exemples

V8 benchmark resultsRichardsDeltaBlueCryptoRayTraceEarleyBoyerRegExpSplayNavierStokes12000.010000.08000.06000.04000.02000.00.06395213.682.41371000338212121.45877211789.2744720146752094.2732277849157.07218132.61176536216.52786909412464213.6302.370370371660232.225723123170.6902552922123247.28759806157.08607310.17325236186.01685102657473213.669.84075916428099122.72666772790.20639903141170027.9453145058157.02651183.854944579178.8631727586361213.6231.1897405271044225.314009165.6100159793797273.850499216157.09450319.6319780279.06451053793472213.6116.5053011932933180.690815711132.8111332714203146.907124519157.05229154.928972162200.1243041695810213.6224.7633064711828234.110736066172.0757751049013356.617579518157.04669265.987651362118.49409520743213.6156.49848155341213.139967079156.66186718959212.663792612157.079212.713595104157.651524198144213.6158.679503637136215.125962858158.12161127734214.139509342157.0102214.744472144156.158791542639582127520721812464166021238607747380991170026516361104437979450347229334203522958101828901346694341597914413634102ChromeFirefoxOperaIEV8 benchmark results

Weasyprint

API Weasyprint

            from weasyprint import HTML
            html = HTML('http://weasyprint.org/')
            html.write_pdf('/tmp/weasyprint-website.pdf')
            html.write_png('/tmp/weasyprint-website.png')
        

Flask-WeasyPrint

            from flask_weasyprint import render_pdf
            @app.route('/hello.pdf')
            def hello_pdf():
                return render_pdf(url_for('hello_html'))
        

Existe aussi pour django

Mais aussi

Démo

Des questions ?

Arthur Vuillard, #!⌨, arthur@hashbang.fr