2
# Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
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
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
23
from pychart_types import *
31
"data" : (AnyType, None, pychart_util.data_desc),
32
"label": (StringType, "???", pychart_util.label_desc),
33
"data_label_offset": (CoordType, (0, 5),
34
"""The location of data labels relative to the sample point. Meaningful only when data_label_format != None."""),
35
"data_label_format": (FormatType, None,
36
"""The format string for the label printed
37
beside a sample point.
38
It can be a `printf' style format string, or
39
a two-parameter function that takes the (x, y)
40
values and returns a string. """
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,
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,
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>>"),
51
"line_style": (line_style.T, lambda: line_style_itr.next(), pychart_util.line_desc,
52
"By default, a style is picked from standard styles round-robin. <<line_style>>"),
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>>"),
59
class T(chart_object.T):
60
__doc__ = line_plot_doc.doc
62
def check_integrity(self):
65
##AUTOMATICALLY GENERATED
67
##END AUTOMATICALLY GENERATED
68
def get_data_range(self, which):
70
return pychart_util.get_data_range(self.data, self.xcol)
72
return pychart_util.get_data_range(self.data, self.ycol)
73
def get_legend_entry(self):
75
return legend.Entry(line_style=self.line_style,
76
tick_mark=self.tick_mark,
81
def draw(self, ar, can):
85
clipbox = theme.adjust_bounding_box([ar.loc[0], ar.loc[1],
86
ar.loc[0] + ar.size[0],
87
ar.loc[1] + ar.size[1]]);
89
can.clip(clipbox[0],clipbox[1],clipbox[2],clipbox[3])
92
for pair in self.data:
93
yval = pychart_util.get_sample_val(pair, self.ycol)
94
xval = pair[self.xcol]
95
if None not in (xval, yval):
96
points.append((ar.x_pos(xval), ar.y_pos(yval)))
97
can.lines(self.line_style, points)
100
# Draw tick marks and error bars
101
can.clip(ar.loc[0] - 10, ar.loc[1] - 10,
102
ar.loc[0] + ar.size[0] + 10,
103
ar.loc[1] + ar.size[1] + 10)
104
for pair in self.data:
106
y = pychart_util.get_sample_val(pair, self.ycol)
107
if None in (x, y): continue
113
plus = pair[self.y_error_plus_col or self.y_error_minus_col]
114
minus = pair[self.y_error_minus_col or self.y_error_plus_col]
115
if self.y_qerror_minus_col or self.y_qerror_plus_col:
116
q_plus = pair[self.y_qerror_plus_col or self.y_qerror_minus_col]
117
q_minus = pair[self.y_qerror_minus_col or self.y_qerror_plus_col]
118
if None not in (minus,plus,q_minus,q_plus):
119
self.error_bar.draw(can, (x_pos, y_pos),
122
ar.y_pos(y - q_minus),
123
ar.y_pos(y + q_plus))
125
if None not in (minus,plus): #PDS
126
self.error_bar.draw(can, (x_pos, y_pos),
131
self.tick_mark.draw(can, x_pos, y_pos)
132
if self.data_label_format:
133
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))
140
global line_style_itr
141
line_styles = object_set.T()
142
for org_style in line_style.standards.list():
143
style = line_style.T(width = default_width, color = org_style.color,
144
dash = org_style.dash)
145
line_styles.add(style)
147
line_style_itr = line_styles.iterate()
149
theme.add_reinitialization_hook(init)