~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/pychart/category_coord.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

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