Package GChartWrapper :: Module GChart' :: Class GChart
[hide private]
[frames] | no frames]

type GChart

source code

object --+    
         |    
      dict --+
             |
            GChart
Known Subclasses:

Main chart class

Chart type must be valid for cht parameter Dataset can be any python iterable and be multi dimensional Kwargs will be put into chart API params if valid

Instance Methods [hide private]
new empty dictionary

__init__(self, ctype=None, dataset=[], **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self) source code
 
_parts(self) source code
 
bar(self, *args)
For bar charts, specify bar thickness and spacing with the args args are <bar width>,<space between bars>,<space between groups> bar width can be relative or absolute, see the official doc APIPARAM: chbh
source code
 
check_size(self, x, y)
Make sure the chart size fits the standards
source code
 
check_type(self, type)
Check to see if the type is either in TYPES or fits type name
source code
 
checksum(self)
Returns the unique SHA1 hexdigest of the chart URL param parts
source code
 
color(self, *args)
Add a color for each dataset args are of the form <color 1>,...<color n> APIPARAM: chco
source code
 
dataset(self, data, series='')
Update the chart's dataset, can be two dimensional or contain string data
source code
 
encoding(self, arg)
Specifies the encoding to be used for the Encoder Must be one of 'simple','text', or 'extended'
source code
 
fill(self, *args)
Apply a solid fill to your chart args are of the form <fill type>,<fill style>,...
source code
 
getdata(self)
Returns the decoded dataset from chd param
source code
 
getname(self)
Gets the name of the chart, if it exists
source code
 
grid(self, *args)
Apply a grid to your chart args are of the form:
source code
 
image(self)
Returns a PngImageFile instance of the chart
source code
 
img(self, **kwargs)
Returns an XHTML <img/> tag of the chart
source code
 
label(self, *args)
Add a simple label to your chart call each time for each dataset APIPARAM: chl
source code
 
legend(self, *args)
Add a legend to your chart call each time for each dataset APIPARAM: chdl
source code
 
legend_pos(self, pos)
Define a position for your legend to occupy APIPARAM: chdlp
source code
 
level_data(self, *args)
Just used in QRCode for the moment args are error_correction,margin_size APIPARAM: chld
source code
 
line(self, *args)
Called one at a time for each dataset args are of the form <data set n line thickness>,<length of line segment>,<length of blank segment> APIPARAM: chls
source code
 
map(self, geo, country_codes)
Creates a map of the defined geography with the given country/state codes Geography choices are africa, asia, europe, middle_east, south_america, and world ISO country codes can be found at http://code.google.com/apis/chart/isocodes.html US state codes can be found at http://code.google.com/apis/chart/statecodes.html APIPARAMS: chtm & chld
source code
 
margin(self, *args)
Set the margins of your chart args are of the form <left margin>,<right margin>,<top margin>,<bottom margin>[,<legend width>,<legend height>] the legend args are optional APIPARAM: chma
source code
 
marker(self, *args)
Defines markers one at a time for your graph args are of the form <marker type>,<color>,<data set index>,<data point>,<size>,<priority> see the official developers doc for the complete spec APIPARAM: chm
source code
 
orientation(self, angle)
Set the chart's orientation for pie charts angle is <angle in radians> APIPARAM: chp
source code
 
output_encoding(self, encoding)
Output encoding to use for QRCode encoding Must be one of 'Shift_JIS','UTF-8', or 'ISO-8859-1' APIPARAM: choe
source code
 
position(self, angle)
Set the chart's orientation for pie charts angle is <angle in radians> APIPARAM: chp
source code
 
render(self)
Renders the chart context and axes into the dict data
source code
 
save(self, fname=None)
Download the chart from the URL into a filename as a PNG
source code
 
scale(self, *args)
Scales the data down to the given size args must be in the form of <data set 1 minimum value>,<data set 1 maximum value>,<data set n minimum value>,<data set n maximum value> will only work with text encoding APIPARAM: chds
source code
 
show(self, *args, **kwargs)
Shows the chart URL in a webbrowser
source code
 
size(self, *args)
Set the size of the chart, args are width,height and can be tuple APIPARAM: chs
source code
 
title(self, title, *args)
Add a title to your chart args are optional style params of the form <color>,<font size> APIPARAMS: chtt,chts
source code
 
type(self, type)
Set the chart type, either Google API type or regular name APIPARAM: cht
source code
 
urlopen(self)
Grabs readable PNG file pointer
source code
 
write(self, fp)
Writes out PNG image data in chunks to file pointer fp
source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __setitem__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Class Methods [hide private]
 
fromurl(cls, qs)
Reverse a chart URL or dict into a GChart instance
source code
Properties [hide private]
  url
Returns the rendered URL of the chart
Method Details [hide private]

__init__(self, ctype=None, dataset=[], **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns:
new empty dictionary

Overrides: dict.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: dict.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
Overrides: object.__str__
(inherited documentation)

check_type(self, type)

source code 

Check to see if the type is either in TYPES or fits type name

Returns proper type

checksum(self)

source code 

Returns the unique SHA1 hexdigest of the chart URL param parts

good for unittesting...

fill(self, *args)

source code 

Apply a solid fill to your chart args are of the form <fill type>,<fill style>,... fill type must be one of c,bg,a fill style must be one of s,lg,ls the rest of the args refer to the particular style, refer to the official doc APIPARAM: chf

fromurl(cls, qs)
Class Method

source code 

Reverse a chart URL or dict into a GChart instance

>>> G = GChart.fromurl('http://chart.apis.google.com/chart?...')
>>> G
<GChartWrapper.GChart instance at...>
>>> G.image().save('chart.jpg','JPEG')

grid(self, *args)

source code 

Apply a grid to your chart args are of the form:

   <x axis step size>,
   <y axis step size>,
   <length of line segment>,
   <length of blank segment>
   <x offset>,
   <y offset>

APIPARAM: chg

image(self)

source code 

Returns a PngImageFile instance of the chart

You must have PIL installed for this to work

img(self, **kwargs)

source code 

Returns an XHTML <img/> tag of the chart

kwargs can be other img tag attributes, which are strictly enforced uses strict escaping on the url, necessary for proper XHTML

save(self, fname=None)

source code 

Download the chart from the URL into a filename as a PNG

The filename defaults to the chart title (chtt) if any

show(self, *args, **kwargs)

source code 

Shows the chart URL in a webbrowser

Other arguments passed to webbrowser.open

write(self, fp)

source code 

Writes out PNG image data in chunks to file pointer fp

fp must support w or wb


Property Details [hide private]

url

Returns the rendered URL of the chart