Generowanie wykresów za pomocą HTML-Graphs
15 October 2008
Comments
HTML-Graphs to prosta biblioteka Pythona umożliwiająca generowanie wykresów słupkowych. Pakiet możemy pobrać ze strony projektu (link na dole strony). Wykresy generowane są z wykorzystaniem HTMLa (głównie tabel). Opisy poszczególnych typów wykresów oraz dostępne metody również znajdziemy na stronie projektu. Oto prosty przykład:
# -*- coding: utf-8 -*-
import graphs
data = {'php': 100, 'python': 13, 'java':90}
graph = graphs.BarGraph('hBar')
graph.titles = [u'Język', 'Ofert']
graph.values = data.values()
graph.labels = data.keys()
graph.showValues = 1
print graph.create()
|
<table border=0 cellspacing=0 cellpadding=0><tr><td><table border=0 cellspacing=2 cellpadding=0><tr><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;text-align:center;"> python </td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap> 13 </td><td height=100% width=142><table border=0 cellspacing=0 cellpadding=0 height=100%><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td style="border:2px outset white;" bgcolor="#0000FF" title="13"><div style="width:13px; height:20px; line-height:1px; font-size:1px;"></div></td></tr></table></td><td style="color:black;font-family:Arial, Helvetica;font-size:12px;" width=125 align=left nowrap> 6% </td></tr></table></td></tr><tr><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;text-align:center;"> php </td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap> 100 </td><td height=100% width=142><table border=0 cellspacing=0 cellpadding=0 height=100%><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td style="border:2px outset white;" bgcolor="#0000FF" title="100"><div style="width:101px; height:20px; line-height:1px; font-size:1px;"></div></td></tr></table></td><td style="color:black;font-family:Arial, Helvetica;font-size:12px;" width=38 align=left nowrap> 49% </td></tr></table></td></tr><tr><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;text-align:center;"> java </td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap> 90 </td><td height=100% width=142><table border=0 cellspacing=0 cellpadding=0 height=100%><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td style="border:2px outset white;" bgcolor="#0000FF" title="90"><div style="width:90px; height:20px; line-height:1px; font-size:1px;"></div></td></tr></table></td><td style="color:black;font-family:Arial, Helvetica;font-size:12px;" width=48 align=left nowrap> 44% </td></tr></table></td></tr></table></td></tr></table>
RkBlog
Comment article