1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
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
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
21 from pychart_types import *
26 class T(chart_object.T):
27 __doc__ = range_plot_doc.doc
29 "data" : (AnyType, None, pychart_util.data_desc),
30 "label": (StringType, "???", pychart_util.label_desc),
31 "xcol" : (IntType, 0, pychart_util.xcol_desc),
32 "min_col": (IntType, 1,
33 "The lower bound of the sweep is extracted from "
34 + "this column of data."),
35 "max_col": (IntType, 2,
36 "The upper bound of the sweep is extracted from "
37 + "this column of data."),
38 "line_style": (line_style.T, line_style.default,
39 "The style of the boundary line."),
40 "fill_style": (fill_style.T, fill_style.default,
44 ##AUTOMATICALLY GENERATED
46 ##END AUTOMATICALLY GENERATED
48 def check_integrity(self):
50 def get_data_range(self, which):
52 return pychart_util.get_data_range(self.data, self.xcol)
54 ymax = (pychart_util.get_data_range(self.data, self.max_col))[1]
55 ymin = (pychart_util.get_data_range(self.data, self.min_col))[0]
57 def get_legend_entry(self):
59 return legend.Entry(line_style=self.line_style,
60 fill_style=self.fill_style,
64 def draw(self, ar, can):
73 # Draw the boundary in a single stroke.
76 for pair in self.data:
78 y = pychart_util.get_sample_val(pair, self.max_col)
82 xmin = min(xmin, ar.x_pos(x))
83 xmax = max(xmax, ar.x_pos(x))
84 ymin = min(ymin, ar.y_pos(y))
85 ymax = max(ymax, ar.y_pos(y))
87 can.lineto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
89 can.moveto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
92 for i in range(len(self.data)-1, -1, -1):
95 y = pychart_util.get_sample_val(pair, self.min_col)
99 xmin = min(xmin, ar.x_pos(x))
100 xmax = max(xmax, ar.x_pos(x))
101 ymin = min(ymin, ar.y_pos(y))
102 ymax = max(ymax, ar.y_pos(y))
103 can.lineto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
106 # create a clip region, and fill it.
108 can.fill_with_pattern(self.fill_style, xmin, ymin, xmax, ymax)
115 can.set_line_style(self.line_style)
116 for pair in self.data:
118 y = pychart_util.get_sample_val(pair, self.min_col)
123 can.lineto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
125 can.moveto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
131 can.set_line_style(self.line_style)
132 for pair in self.data:
134 y = pychart_util.get_sample_val(pair, self.max_col)
139 can.lineto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))
141 can.moveto(xscale(ar.x_pos(x)), yscale(ar.y_pos(y)))