Package pygtk_chart :: Module line_chart :: Class Graph
[hide private]
[frames] | no frames]

Class Graph

source code


This class represents a graph or the data you want to plot on your LineChart widget.

Instance Methods [hide private]
 
__init__(self, name, title, data)
Create a new instance.
source code
 
do_get_property(self, property) source code
 
do_set_property(self, property, value) source code
 
has_something_to_draw(self) source code
 
_do_draw_title(self, context, rect, last_point)
Draws the title.
source code
 
_do_draw_fill(self, context, rect, xrange) source code
 
_do_draw(self, context, rect)
Draw the graph.
source code
 
get_x_range(self)
Get the the endpoints of the x interval.
source code
 
get_y_range(self)
Get the the endpoints of the y interval.
source code
 
get_name(self)
Get the name of the graph.
source code
 
get_title(self)
Returns the title of the graph.
source code
 
set_title(self, title)
Set the title of the graph.
source code
 
set_range_calc(self, range_calc) source code
 
get_color(self)
Returns the current color of the graph or COLOR_AUTO.
source code
 
set_color(self, color)
Set the color of the graph.
source code
 
get_type(self)
Returns the type of the graph.
source code
 
set_type(self, type)
Set the type of the graph to one of these:
source code
 
get_point_size(self)
Returns the radius of the data points.
source code
 
set_point_size(self, size)
Set the radius of the drawn points.
source code
 
get_fill_to(self)
The return value of this method depends on the filling under the graph.
source code
 
set_fill_to(self, fill_to)
Use this method to specify how the space under the graph should be filled.
source code
 
get_fill_color(self)
Returns the color that is used to fill space under the graph or COLOR_AUTO.
source code
 
set_fill_color(self, color)
Set which color should be used when filling the space under a graph.
source code
 
get_fill_opacity(self)
Returns the opacity that is used to fill space under the graph.
source code
 
set_fill_opacity(self, opacity)
Set which opacity should be used when filling the space under a graph.
source code
 
get_show_values(self)
Returns True if y values are shown.
source code
 
set_show_values(self, show)
Set whether the y values should be shown (only if graph type is GRAPH_POINTS or GRAPH_BOTH).
source code
 
get_show_title(self)
Returns True if the title of the graph is shown.
source code
 
set_show_title(self, show)
Set whether to show the graph's title or not.
source code
 
add_data(self, data_list)
Add data to the graph.
source code
 
get_data(self)
Returns the data of the graph.
source code

Inherited from chart.ChartObject: draw, get_antialias, get_visible, set_antialias, set_visible

Inherited from unreachable.GObject: __cmp__, __copy__, __deepcopy__, __delattr__, __gdoc__, __gobject_init__, __hash__, __new__, __repr__, __setattr__, chain, connect, connect_after, connect_object, connect_object_after, disconnect, disconnect_by_func, emit, emit_stop_by_name, freeze_notify, get_properties, get_property, handler_block, handler_block_by_func, handler_disconnect, handler_is_connected, handler_unblock, handler_unblock_by_func, notify, props, set_data, set_properties, set_property, stop_emission, thaw_notify, weak_ref

Inherited from object: __getattribute__, __reduce__, __reduce_ex__, __str__

Class Variables [hide private]
  __gproperties__ = {"name":(gobject.TYPE_STRING, "graph id", "T...
  __gtype__ = <GType pygtk_chart+line_chart+Graph (169104040)>

Inherited from chart.ChartObject: __gsignals__

Properties [hide private]

Inherited from unreachable.GObject: __grefcount__

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, title, data)
(Constructor)

source code 

Create a new instance.

Parameters:
  • name (string) - A unique name for the graph. This could be everything. It's just a name used internally for identification. You need to know this if you want to access or delete a graph from a chart.
  • title (string) - The graphs title. This can be drawn on the chart.
  • data (list of pairs of numbers) - This is the data you want to be visualized. data has to be a list of (x, y) pairs.
Overrides: object.__init__

do_get_property(self, property)

source code 
Overrides: chart.ChartObject.do_get_property

do_set_property(self, property, value)

source code 
Overrides: chart.ChartObject.do_set_property

_do_draw_title(self, context, rect, last_point)

source code 

Draws the title.

Parameters:
  • context (cairo.Context) - The context to draw on.
  • rect (gtk.gdk.Rectangle) - A rectangle representing the charts area.
  • last_point (pairs of numbers) - The absolute position of the last drawn data point.

_do_draw(self, context, rect)

source code 

Draw the graph.

Parameters:
  • context (cairo.Context) - The context to draw on.
  • rect (gtk.gdk.Rectangle) - A rectangle representing the charts area.
Overrides: chart.ChartObject._do_draw

get_x_range(self)

source code 

Get the the endpoints of the x interval.

Returns:
pair of numbers

get_y_range(self)

source code 

Get the the endpoints of the y interval.

Returns:
pair of numbers

get_name(self)

source code 

Get the name of the graph.

Returns:
string

get_title(self)

source code 

Returns the title of the graph.

Returns:
string

set_title(self, title)

source code 

Set the title of the graph.

Parameters:
  • title (string) - The graph's new title.

get_color(self)

source code 

Returns the current color of the graph or COLOR_AUTO.

Returns:
a color (see set_color() for details).

set_color(self, color)

source code 

Set the color of the graph. color has to be a (r, g, b) triple where r, g, b are between 0 and 1. If set to COLOR_AUTO, the color will be choosen dynamicly.

Parameters:
  • color (a color) - The new color of the graph.

get_type(self)

source code 

Returns the type of the graph.

Returns:
a type constant (see set_type() for details)

set_type(self, type)

source code 

Set the type of the graph to one of these:

  • GRAPH_POINTS: only show points
  • GRAPH_LINES: only draw lines
  • GRAPH_BOTH: draw points and lines, i.e. connect points with lines
Parameters:
  • type - One of the constants above.

get_point_size(self)

source code 

Returns the radius of the data points.

Returns:
a poisitive integer

set_point_size(self, size)

source code 

Set the radius of the drawn points.

Parameters:
  • size (a positive integer in [1, 100]) - The new radius of the points.

get_fill_to(self)

source code 

The return value of this method depends on the filling under the graph. See set_fill_to() for details.

set_fill_to(self, fill_to)

source code 

Use this method to specify how the space under the graph should be filled. fill_to has to be one of these:

  • None: dont't fill the space under the graph.
  • int or float: fill the space to the value specified (setting fill_to=0 means filling the space between graph and xaxis).
  • a Graph object: fill the space between this graph and the graph given as the argument.

The color of the filling is the graph's color with 30% opacity.

Parameters:
  • fill_to (one of the possibilities listed above.)

set_fill_color(self, color)

source code 

Set which color should be used when filling the space under a graph. If color is COLOR_AUTO, the graph's color will be used.

Parameters:
  • color (a color or COLOR_AUTO.)

set_fill_opacity(self, opacity)

source code 

Set which opacity should be used when filling the space under a graph. The default is 0.3.

Parameters:
  • opacity (float in [0, 1].)

get_show_values(self)

source code 

Returns True if y values are shown.

Returns:
boolean

set_show_values(self, show)

source code 

Set whether the y values should be shown (only if graph type is GRAPH_POINTS or GRAPH_BOTH).

Parameters:
  • show (boolean)

get_show_title(self)

source code 

Returns True if the title of the graph is shown.

Returns:
boolean.

set_show_title(self, show)

source code 

Set whether to show the graph's title or not.

Parameters:
  • show (boolean.)

add_data(self, data_list)

source code 

Add data to the graph.

Parameters:
  • data_list (a list of pairs of numbers)

get_data(self)

source code 

Returns the data of the graph.

Returns:
a list of x, y pairs.
Overrides: unreachable.GObject.get_data

Class Variable Details [hide private]

__gproperties__

Value:
{"name":(gobject.TYPE_STRING, "graph id", "The graph's unique name.", \
"", gobject.PARAM_READABLE), "title":(gobject.TYPE_STRING, "graph titl\
e", "The title of the graph.", "", gobject.PARAM_READWRITE), "color":(\
gobject.TYPE_PYOBJECT, "graph color", "The color of the graph in (r,g,\
b) format. r,g,b in [0,1].", gobject.PARAM_READWRITE), "type":(gobject\
.TYPE_INT, "graph type", "The type of the graph.", 1, 3, 3, gobject.PA\
RAM_READWRITE), "point-size":(gobject.TYPE_INT, "point size", "Radius \
of the data points.", 1, 100, 2, gobject.PARAM_READWRITE), "fill-to":(\
...