pygooglechart Module

pygooglechart - A complete Python wrapper for the Google Chart API

http://pygooglechart.slowchop.com/

Copyright 2007-2013 Gerald Kaszuba

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

exception pygooglechart.AbstractClassException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.Axis(axis_index, axis_type, **kw)[source]

Bases: object

BOTTOM = 'x'
LEFT = 'y'
RIGHT = 'r'
TOP = 't'
TYPES = ('x', 't', 'y', 'r')
positions_to_url()[source]
set_index(axis_index)[source]
set_positions(positions)[source]
set_style(colour, font_size=None, alignment=None)[source]
style_to_url()[source]
exception pygooglechart.BadContentTypeException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.BarChart(*args, **kwargs)[source]

Bases: pygooglechart.Chart

get_url_bits(data_class=None, skip_chbh=False)[source]
set_bar_width(bar_width)[source]
set_zero_line(index, zero_line)[source]
class pygooglechart.Chart(width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None)[source]

Bases: object

Abstract class for all chart types.

width are height specify the dimensions of the image. title sets the title of the chart. legend requires a list that corresponds to datasets.

ALPHA = 'a'
BACKGROUND = 'bg'
BASE_URL = 'http://www.google.com/chart'
CHART = 'c'
LINEAR_GRADIENT = 'lg'
LINEAR_STRIPES = 'ls'
SOLID = 's'
VALID_SOLID_FILL_TYPES = ('bg', 'c', 'a')
add_data(data)[source]
add_data_line(colour, data_set, size, priority=0)[source]
add_fill_range(colour, index_start, index_end)[source]
add_fill_simple(colour)[source]
add_horizontal_range(colour, start, stop)[source]
add_marker(index, point, marker_type, colour, size, priority=0)[source]
add_marker_text(string, colour, data_set, data_point, size, priority=0)[source]
add_vertical_range(colour, start, stop)[source]
annotated_data()[source]
axis_to_url()[source]
data_class_detection(data)[source]

Determines the appropriate data encoding type to give satisfactory resolution (http://code.google.com/apis/chart/#chart_data).

data_to_url(data_class=None)[source]
data_x_range()[source]

Return a 2-tuple giving the minimum and maximum x-axis data range.

data_y_range()[source]

Return a 2-tuple giving the minimum and maximum y-axis data range.

download(file_name=False, use_post=True)[source]
fill_linear_gradient(area, angle, *args)[source]
fill_linear_stripes(area, angle, *args)[source]
fill_solid(area, colour)[source]
fill_to_url()[source]
get_url(data_class=None)[source]
get_url_bits(data_class=None)[source]
get_url_extension(data_class=None)[source]
markers_to_url()[source]
scaled_data(data_class, x_range=None, y_range=None)[source]

Scale self.data as appropriate for the given data encoding (data_class) and return it.

An optional y_range – a 2-tuple (lower, upper) – can be given to specify the y-axis bounds. If not given, the range is inferred from the data: (0, <max-value>) presuming no negative values, or (<min-value>, <max-value>) if there are negative values. self.scaled_y_range is set to the actual lower and upper scaling range.

Ditto for x_range. Note that some chart types don’t have x-axis data.

set_axis_labels(axis_type, values)[source]
set_axis_positions(axis_index, positions)[source]
set_axis_range(axis_type, low, high)[source]
set_axis_style(axis_index, colour, font_size=None, alignment=None)[source]
set_colours(colours)[source]
set_colours_within_series(colours)[source]
set_grid(x_step, y_step, line_segment=1, blank_segment=0)[source]
set_legend(legend)[source]

legend needs to be a list, tuple or None

set_legend_position(legend_position)[source]

Sets legend position. Default is ‘r’.

b - At the bottom of the chart, legend entries in a horizontal row. bv - At the bottom of the chart, legend entries in a vertical column. t - At the top of the chart, legend entries in a horizontal row. tv - At the top of the chart, legend entries in a vertical column. r - To the right of the chart, legend entries in a vertical column. l - To the left of the chart, legend entries in a vertical column.

set_line_style(index, thickness=1, line_segment=None, blank_segment=None)[source]
set_title(title)[source]
set_title_style(colour=None, font_size=None)[source]
class pygooglechart.ChartGrammar[source]

Bases: object

create_chart_instance(grammar=None)[source]
download()[source]
static get_possible_chart_types()[source]
parse(grammar)[source]
parse_data(data)[source]
class pygooglechart.Data(data)[source]

Bases: object

static check_clip(scaled, clipped)[source]
classmethod clip_value(value)[source]
classmethod float_scale_value(value, range)[source]
classmethod int_scale_value(value, range)[source]
classmethod scale_value(value, range)[source]
exception pygooglechart.DataOutOfRangeException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.ExtendedData(data)[source]

Bases: pygooglechart.Data

enc_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'
max_value = 4095
class pygooglechart.GoogleOMeterChart(*args, **kwargs)[source]

Bases: pygooglechart.PieChart

Inheriting from PieChart because of similar labeling

type_to_url()[source]
class pygooglechart.GroupedBarChart(*args, **kwargs)[source]

Bases: pygooglechart.BarChart

get_url_bits(data_class=None)[source]
set_bar_spacing(spacing)[source]

Set spacing between bars in a group.

set_group_spacing(spacing)[source]

Set spacing between groups of bars.

class pygooglechart.GroupedHorizontalBarChart(*args, **kwargs)[source]

Bases: pygooglechart.GroupedBarChart

type_to_url()[source]
class pygooglechart.GroupedVerticalBarChart(*args, **kwargs)[source]

Bases: pygooglechart.GroupedBarChart

annotated_data()[source]
type_to_url()[source]
exception pygooglechart.InvalidParametersException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.LabelAxis(axis_index, axis_type, values, **kwargs)[source]

Bases: pygooglechart.Axis

class pygooglechart.LineChart(*args, **kwargs)[source]

Bases: pygooglechart.Chart

class pygooglechart.MapChart(*args, **kwargs)[source]

Bases: pygooglechart.Chart

add_data_dict(datadict)[source]

Sets the data and country codes via a dictionary.

i.e. {‘DE’: 50, ‘GB’: 30, ‘AT’: 70}

get_url_bits(data_class=None)[source]
set_codes(codes)[source]

Set the country code map for the data. Codes given in a list.

i.e. DE - Germany
AT - Austria US - United States
set_geo_area(area)[source]

Sets the geo area for the map.

  • africa
  • asia
  • europe
  • middle_east
  • south_america
  • usa
  • world
type_to_url()[source]
exception pygooglechart.NoDataGivenException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.PieChart(*args, **kwargs)[source]

Bases: pygooglechart.Chart

annotated_data()[source]
get_url_bits(data_class=None)[source]
scaled_data(data_class, x_range=None, y_range=None)[source]
set_pie_labels(labels)[source]
class pygooglechart.PieChart2D(*args, **kwargs)[source]

Bases: pygooglechart.PieChart

type_to_url()[source]
class pygooglechart.PieChart3D(*args, **kwargs)[source]

Bases: pygooglechart.PieChart

type_to_url()[source]
exception pygooglechart.PyGoogleChartException[source]

Bases: exceptions.Exception

class pygooglechart.QRChart(*args, **kwargs)[source]

Bases: pygooglechart.Chart

data_to_url(data_class=None)[source]
get_url_bits(data_class=None)[source]
set_ec(level, margin)[source]
set_encoding(encoding)[source]
type_to_url()[source]
class pygooglechart.RadarChart(width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None)[source]

Bases: pygooglechart.Chart

type_to_url()[source]
class pygooglechart.RangeAxis(axis_index, axis_type, low, high, **kwargs)[source]

Bases: pygooglechart.Axis

class pygooglechart.ScatterChart(width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None)[source]

Bases: pygooglechart.Chart

annotated_data()[source]
type_to_url()[source]
class pygooglechart.SimpleData(data)[source]

Bases: pygooglechart.Data

enc_map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
max_value = 61
class pygooglechart.SimpleLineChart(*args, **kwargs)[source]

Bases: pygooglechart.LineChart

annotated_data()[source]
type_to_url()[source]
class pygooglechart.SparkLineChart(*args, **kwargs)[source]

Bases: pygooglechart.SimpleLineChart

type_to_url()[source]
class pygooglechart.SplineRadarChart(width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None)[source]

Bases: pygooglechart.RadarChart

type_to_url()[source]
class pygooglechart.StackedHorizontalBarChart(*args, **kwargs)[source]

Bases: pygooglechart.BarChart

type_to_url()[source]
class pygooglechart.StackedVerticalBarChart(*args, **kwargs)[source]

Bases: pygooglechart.BarChart

annotated_data()[source]
type_to_url()[source]
class pygooglechart.TextData(data)[source]

Bases: pygooglechart.Data

max_value = 100
classmethod scale_value(value, range)[source]
exception pygooglechart.UnknownChartType[source]

Bases: pygooglechart.PyGoogleChartException

exception pygooglechart.UnknownCountryCodeException[source]

Bases: pygooglechart.PyGoogleChartException

exception pygooglechart.UnknownDataTypeException[source]

Bases: pygooglechart.PyGoogleChartException

class pygooglechart.VennChart(width, height, title=None, legend=None, colours=None, auto_scale=True, x_range=None, y_range=None, colours_within_series=None)[source]

Bases: pygooglechart.Chart

annotated_data()[source]
type_to_url()[source]
class pygooglechart.XYLineChart(*args, **kwargs)[source]

Bases: pygooglechart.LineChart

annotated_data()[source]
type_to_url()[source]