[reportlab-users] Looks like a bug ...

JP Glutting reportlab-users@reportlab.com
Mon, 11 Oct 2004 14:50:23 +0200


Ok, I found the problem and I have a fix for the "Don't graph None
values but use them for labels" bug. This works with my test data. So
far it has not created any problems, but YMMV. It does graph lines
with missing values in the middle (like (55, 30, None, 100, 44)) by
"bridging" the gap instead of breaking the line, but the current code
does the same thing,and it also labels them incorrectly. (This is JP
Glutting posting from home, by the way - I am out sick).

Changes:

In the calcPositions function, starting at line 191, the current code reads:

                if datum is not None:
                    (groupX, groupWidth) = self.categoryAxis.scale(colNo)
                    x = groupX + (0.5 * self.groupSpacing * normFactor)
                    y = self.valueAxis.scale(0)
                    height = self.valueAxis.scale(datum) - y
                    lineRow.append((x, y+height))
            self._positions.append(lineRow)

two lines need to be added, like this:

                if datum is not None:
                    (groupX, groupWidth) = self.categoryAxis.scale(colNo)
                    x = groupX + (0.5 * self.groupSpacing * normFactor)
                    y = self.valueAxis.scale(0)
                    height = self.valueAxis.scale(datum) - y
                    lineRow.append((x, y+height))
-->             else:
-->                lineRow.append(())
            self._positions.append(lineRow)


Also, two more changes need to be made, on lines 294 and 301, in the
makeLines function, which currently reads like this:


            if uSymbol:
                for colNo in range(len(row)):
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)

needs to read like this:


            if uSymbol:
                for colNo in range(len(row)):
-->                if not row[colNo]: continue
                    x1, y1 = row[colNo]
                    symbol = uSymbol2Symbol(uSymbol,x1,y1,rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo in range(len(row)):
-->                if not row[colNo]: continue
                x1, y1 = row[colNo]
                self.drawLabel(g, rowNo, colNo, x1, y1)


Cheers,

JP