Generowanie wykresów za pomocą HTML-Graphs

Opis prostej biblioteki Pythona generującej HTMLowe wykresy słupkowe.

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()
Co da wykres:
 python  13 
 6% 
 php  100 
 49% 
 java  90 
 44% 
A kod wykresu wygląda tak:
<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;">&nbsp;python&nbsp;</td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap>&nbsp;13&nbsp;</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>&nbsp;6%&nbsp;</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;">&nbsp;php&nbsp;</td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap>&nbsp;100&nbsp;</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>&nbsp;49%&nbsp;</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;">&nbsp;java&nbsp;</td><td style="color:black;background-color:#C0E0FF;border:2px groove white;font-family:Arial, Helvetica;font-size:12px;" align=right nowrap>&nbsp;90&nbsp;</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>&nbsp;44%&nbsp;</td></tr></table></td></tr></table></td></tr></table>
blog comments powered by Disqus

Kategorie

Strony