[MERGE] Remove the embedded pychart library, and use the online version
[odoo/odoo.git] /
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
4
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14 #
15 import coord
16 import canvas
17
18 class T(coord.T):
19     def __init__(self, data, col):
20
21         """This attribute is meaningful only when x_coord_system ==
22         'category'. This attribute selects the column of
23         'x_category_data' from which X values are computed.
24         Meaningful only when x_coord_system == 'category'.  This
25         attribute specifies the data-set from which the X values are
26         extracted. See also x_category_col."""
27         
28         self.data = data
29         self.col = col
30         
31     def get_canvas_pos(self, size, val, min, max):
32         i = 0.5
33         for v in self.data:
34             if v[self.col] == val:
35                 return size * i / float(len(self.data))
36             i += 1
37         # the drawing area is clipped. So negative offset will make this plot
38         # invisible.
39         return canvas.invalid_coord;
40     def get_tics(self, min, max, interval):
41         tics = []
42         if interval == None: interval = 1
43         
44         for i in range(0, len(self.data), interval):
45             tics.append(self.data[i][self.col])
46         return tics    
47         #return map(lambda pair, self = self: pair[self.col], self.data)
48