Skip to content

Commit

Permalink
fix bug in filled line plots with a black fill color, spotted by Brad…
Browse files Browse the repository at this point in the history
… Buran. Also improving handling when there are no points in the filled line plot.
  • Loading branch information
pwang committed May 13, 2010
1 parent 62a694d commit 43a951a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions enthought/chaco/filled_line_plot.py
@@ -1,11 +1,10 @@
import logging


from enthought.traits.api import Property, Enum

# Local imports
from polygon_plot import PolygonPlot

logger = logging.getLogger(__name__)

def Alias(name):
return Property(lambda obj: getattr(obj, name),
Expand All @@ -22,11 +21,9 @@ class FilledLinePlot(PolygonPlot):
fill_direction = Enum("down", "up")

def _render(self, gc, points):
# If there is nothing to render, render nothing
if len(points) == 0:
logger.warning("No datasource for plot")
return

if self.fill_direction == 'down':
ox, oy = self.map_screen([[0,0]])[0]
else:
Expand All @@ -38,8 +35,9 @@ def _render(self, gc, points):
gc.clip_to_rect(self.x, self.y, self.width, self.height)

# If the fill color is not transparent, then draw the fill polygon first
if self.face_color_[-1] != 0 and self.face_color_[:3] != (0,0,0):
gc.set_fill_color(self.face_color_)
face_col = self.face_color_
if not (len(face_col) == 4 and face_col[-1] == 0):
gc.set_fill_color(face_col)
gc.begin_path()
startx, starty = points[0]
if self.orientation == "h":
Expand All @@ -64,8 +62,9 @@ def _render(self, gc, points):

# If the line color is not transparent, or tha same color
# as the filled area:
if self.edge_color_[-1] != 0 and self.edge_color_ != self.face_color_:
gc.set_stroke_color(self.edge_color_)
edge_col = self.edge_color_
if (not (len(edge_col) == 4 and edge_col[-1] == 0)) and edge_col != face_col:
gc.set_stroke_color(edge_col)
gc.set_line_width(self.edge_width)
gc.set_line_dash(self.edge_style_)
gc.begin_path()
Expand Down

0 comments on commit 43a951a

Please sign in to comment.