~activity/openobject-server/trunk

« back to all changes in this revision

Viewing changes to bin/pychart/line_plot.py

  • Committer: Dainius Malachovskis
  • Date: 2009-06-11 21:01:55 UTC
  • mfrom: (1235.2.5 server)
  • Revision ID: dainius.malachovskis@sandas.eu-20090611210155-ql9k1pd0dnr9avr0
merged

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
 
30
30
_keys = {
31
 
    "data" : (AnyType, None, pychart_util.data_desc),
32
 
    "label": (StringType, "???", pychart_util.label_desc),
33
 
    "data_label_offset": (CoordType, (0, 5),
 
31
    'data' : (AnyType, None, pychart_util.data_desc),
 
32
    'label': (StringType, '???', pychart_util.label_desc),
 
33
    'data_label_offset': (CoordType, (0, 5),
34
34
                          """The location of data labels relative to the sample point. Meaningful only when data_label_format != None."""),
35
 
    "data_label_format": (FormatType, None,
 
35
    'data_label_format': (FormatType, None,
36
36
                          """The format string for the label printed 
37
37
                          beside a sample point.
38
38
                          It can be a `printf' style format string, or 
39
39
                          a two-parameter function that takes the (x, y)
40
40
                          values and returns a string. """
41
41
                          + pychart_util.string_desc),
42
 
    "xcol" : (IntType, 0, pychart_util.xcol_desc),
43
 
    "ycol": (IntType, 1, pychart_util.ycol_desc),
44
 
    "y_error_minus_col": (IntType, 2,
 
42
    'xcol' : (IntType, 0, pychart_util.xcol_desc),
 
43
    'ycol': (IntType, 1, pychart_util.ycol_desc),
 
44
    'y_error_minus_col': (IntType, 2,
45
45
                          """The column (within "data") from which the depth of the errorbar is extracted. Meaningful only when error_bar != None. <<error_bar>>"""),
46
 
    "y_error_plus_col": (IntType, -1,
 
46
    'y_error_plus_col': (IntType, -1,
47
47
                         """The column (within "data") from which the height of the errorbar is extracted. Meaningful only when error_bar != None. <<error_bar>>"""),
48
 
    "y_qerror_minus_col":  (IntType, -1, "<<error_bar>>"),
49
 
    "y_qerror_plus_col":  (IntType, -1, "<<error_bar>>"),
 
48
    'y_qerror_minus_col':  (IntType, -1, '<<error_bar>>'),
 
49
    'y_qerror_plus_col':  (IntType, -1, '<<error_bar>>'),
50
50
 
51
 
    "line_style": (line_style.T, lambda: line_style_itr.next(), pychart_util.line_desc,
 
51
    'line_style': (line_style.T, lambda: line_style_itr.next(), pychart_util.line_desc,
52
52
                   "By default, a style is picked from standard styles round-robin. <<line_style>>"),
53
53
 
54
 
    "tick_mark": (tick_mark.T, None, pychart_util.tick_mark_desc),
55
 
    "error_bar": (error_bar.T, None,
56
 
                  "The style of the error bar. <<error_bar>>"),
 
54
    'tick_mark': (tick_mark.T, None, pychart_util.tick_mark_desc),
 
55
    'error_bar': (error_bar.T, None,
 
56
                  'The style of the error bar. <<error_bar>>'),
57
57
    }
58
58
 
59
59
class T(chart_object.T):
60
60
    __doc__ = line_plot_doc.doc
61
61
    keys =  _keys
62
62
    def check_integrity(self):
63
 
        self.type_check()
 
63
        assert chart_object.T.check_integrity(self)
64
64
        
65
65
##AUTOMATICALLY GENERATED
66
66
 
70
70
            return pychart_util.get_data_range(self.data, self.xcol)
71
71
        else:
72
72
            return pychart_util.get_data_range(self.data, self.ycol)
73
 
    def get_legend_entry(self):
 
73
    def get_legend_entry(self): 
74
74
        if self.label:
75
 
            return legend.Entry(line_style=self.line_style,
 
75
            line_style = self.line_style
 
76
            if not line_style and self.error_bar:
 
77
                line_style = getattr(self.error_bar, 'line_style', None) or \
 
78
                             getattr(self.error_bar, 'hline_style', None) or \
 
79
                             getattr(self.error_bar, 'vline_style', None)
 
80
                if not line_style:
 
81
                    raise Exception, 'Line plot has label, but an empty line style and error bar.'
 
82
            return legend.Entry(line_style=line_style,
76
83
                                tick_mark=self.tick_mark,
77
84
                                fill_style=None,
78
85
                                label=self.label)
131
138
                self.tick_mark.draw(can, x_pos, y_pos)
132
139
            if self.data_label_format:
133
140
                can.show(x_pos + self.data_label_offset[0],
134
 
                            y_pos + self.data_label_offset[1],
135
 
                            "/hC" + pychart_util.apply_format(self.data_label_format, (x, y), 1))
 
141
                         y_pos + self.data_label_offset[1],
 
142
                         '/hC' + pychart_util.apply_format(self.data_label_format, (x, y), 1))
136
143
 
137
144
        can.endclip()
138
145