Changeset 75

Show
Ignore:
Timestamp:
12/20/07 06:21:14 (4 years ago)
Author:
lgs
Message:

Simplify the Scatter Plot by inheriting from LineChart?

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/line.py

    r54 r75  
    3434                x = (xval - self.minxval) * self.xscale 
    3535                y = 1.0 - (yval - self.minyval) * self.yscale 
    36                 point = Point(x, clamp(0.0, 1.0, y), xval, yval, name) 
     36                point = Point(x, y, xval, yval, name) 
    3737                 
    38                 if 0.0 <= point.x <= 1.0: 
     38                if 0.0 <= point.x <= 1.0 and 0.0 <= point.y <= 1.0: 
    3939                    self.points.append(point) 
    4040     
  • trunk/src/scatter.py

    r74 r75  
    1818from pycha.chart import Chart 
    1919from pycha.color import hex2rgb, clamp 
    20 from pycha.line import Point 
     20from pycha.line import Point, LineChart 
    2121 
    22 class ScatterplotChart(Chart): 
    23      
    24     def __init__(self, surface=None, options={}): 
    25         super(ScatterplotChart, self).__init__(surface, options) 
    26         self.points = [] 
    27          
    28     def _updateChart(self): 
    29         """Evaluates measures for scatterplots""" 
    30         self.points = [] 
    31  
    32         for i, (name, store) in enumerate(self.datasets): 
    33             for item in store: 
    34                 xval, yval = item 
    35                 x = (xval - self.minxval) * self.xscale 
    36                 y = 1.0 - (yval - self.minyval) * self.yscale 
    37                 point = Point(x, clamp(0.0, 1.0, y), xval, yval, name) 
    38                  
    39                 if 0.0 <= point.x <= 1.0: 
    40                     self.points.append(point) 
    41      
     22class ScatterplotChart(LineChart): 
     23       
    4224    def _renderChart(self, cx): 
    4325        """Renders a scatterplot"""