Exemple #1
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle,'lineStyle',None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle=='bar':
                barWidth = getattr(rowStyle,'barWidth',Percentage(50))
                fillColor = getattr(rowStyle,'fillColor',rowColor)
                if isinstance(barWidth,Percentage):
                    hbw = self._hngs*barWidth*0.01
                else:
                    hbw = barWidth*0.5
                for colNo in range(len(row)):
                    x,y = row[colNo]
                    g.add(Rect(x-hbw,min(y,yzero),2*hbw,abs(y-yzero),strokeWidth=strokeWidth,strokeColor=rowColor,fillColor=fillColor))
            elif self.joinedLines or lineStyle=='joinedLine':
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            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)

        return g
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(self.lines[styleIdx], 'strokeWidth'):
                strokeWidth = self.lines[styleIdx].strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(self.lines[styleIdx], 'symbol'):
                uSymbol = self.lines[styleIdx].symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            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)

        return g
Exemple #3
0
    def makeLines(self):
        g = Group()
        bubblePlot = getattr(self,'_bubblePlot',None)
        if bubblePlot:
            yA = self.yValueAxis
            xA = self.xValueAxis
            bubbleR = min(yA._bubbleRadius,xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self,'_inFill',None)
        styleCount = len(self.lines)
        if inFill or [rowNo for rowNo in P if getattr(self.lines[rowNo%styleCount],'inFill',False)]:
            inFillY = self.xValueAxis._y
            inFillX0 = self.yValueAxis._x
            inFillX1 = inFillX0 + self.xValueAxis._length
            inFillG = getattr(self,'_inFillG',g)
        lG = getattr(self,'_lineG',g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            rowStyle = self.lines[rowNo % styleCount]
            rowColor = getattr(rowStyle,'strokeColor',None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                width = self.lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points = points + [xy[0], xy[1]]
                if inFill or getattr(rowStyle,'inFill',False):
                    fpoints = [inFillX0,inFillY] + points + [inFillX1,inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self,inFillG,rowNo,rowColor,fpoints)
                    else:
                        inFillG.add(Polygon(fpoints,fillColor=rowColor,strokeColor=rowColor,strokeWidth=width or 0.1))
                if inFill in (None,0,2):
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                j = -1
                if bubblePlot: drow = self.data[rowNo]
                for xy in row:
                    j += 1
                    symbol = uSymbol2Symbol(uSymbol,xy[0],xy[1],rowColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)

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

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self,g,rowNo,rowColor,row)

        return g
Exemple #4
0
    def makeLines(self):
        g = Group()
        bubblePlot = getattr(self, '_bubblePlot', None)
        if bubblePlot:
            yA = self.yValueAxis
            xA = self.xValueAxis
            bubbleR = min(yA._bubbleRadius, xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self, '_inFill', None)
        styleCount = len(self.lines)
        if inFill or [
                rowNo for rowNo in P
                if getattr(self.lines[rowNo % styleCount], 'inFill', False)
        ]:
            inFillY = self.xValueAxis._y
            inFillX0 = self.yValueAxis._x
            inFillX1 = inFillX0 + self.xValueAxis._length
            inFillG = getattr(self, '_inFillG', g)
        lG = getattr(self, '_lineG', g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            rowStyle = self.lines[rowNo % styleCount]
            rowColor = getattr(rowStyle, 'strokeColor', None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                width = self.lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points += [xy[0], xy[1]]
                if inFill or getattr(rowStyle, 'inFill', False):
                    fpoints = [inFillX0, inFillY
                               ] + points + [inFillX1, inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self, inFillG, rowNo, rowColor, fpoints)
                    else:
                        inFillG.add(
                            Polygon(fpoints,
                                    fillColor=rowColor,
                                    strokeColor=rowColor,
                                    strokeWidth=width or 0.1))
                if inFill in (None, 0, 2):
                    line = PolyLine(points,
                                    strokeColor=rowColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                j = -1
                if bubblePlot: drow = self.data[rowNo]
                for xy in row:
                    j += 1
                    symbol = uSymbol2Symbol(uSymbol, xy[0], xy[1], rowColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR * (drow[j][2] /
                                                     bubbleMax)**0.5
                        g.add(symbol)

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

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self, g, rowNo, rowColor, row)

        return g
Exemple #5
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self, '_inFillG', g)

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(self.lines[styleIdx], 'strokeWidth'):
                strokeWidth = self.lines[styleIdx].strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1, inFillY, inFillX0, inFillY]
                    inFillG.add(
                        Polygon(points,
                                fillColor=rowColor,
                                strokeColor=rowColor,
                                strokeWidth=0.1))
                else:
                    line = PolyLine(points,
                                    strokeColor=rowColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(self.lines[styleIdx], 'symbol'):
                uSymbol = self.lines[styleIdx].symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            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)

        return g
    def makeLines(self):
        g = Group()
        yA = self.yValueAxis
        xA = self.xValueAxis
        bubblePlot = getattr(self,'_bubblePlot',None)
        if bubblePlot:
            bubbleR = min(yA._bubbleRadius,xA._bubbleRadius)
            bubbleMax = xA._bubbleMax

        labelFmt = self.lineLabelFormat

        P = list(range(len(self._positions)))
        if self.reversePlotOrder: P.reverse()
        inFill = getattr(self,'_inFill',None)
        lines = self.lines
        styleCount = len(lines)
        if inFill or [rowNo for rowNo in P if getattr(lines[rowNo%styleCount],'inFill',False)]:
            inFillY = getattr(inFill,'yValue',None)
            if inFillY is None:
                inFillY = xA._y
            else:
                inFillY = yA.scale(inFillY)
            inFillX0 = yA._x
            inFillX1 = inFillX0 + xA._length
            inFillG = getattr(self,'_inFillG',g)
        lG = getattr(self,'_lineG',g)
        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleRowNo = rowNo % styleCount
            rowStyle = lines[styleRowNo]
            rowColor = getattr(rowStyle,'strokeColor',None)
            dash = getattr(rowStyle, 'strokeDashArray', None)

            if hasattr(rowStyle, 'strokeWidth'):
                width = rowStyle.strokeWidth
            elif hasattr(lines, 'strokeWidth'):
                width = lines.strokeWidth
            else:
                width = None

            # Iterate over data columns.
            if self.joinedLines:
                points = []
                for xy in row:
                    points += [xy[0], xy[1]]
                if inFill or getattr(rowStyle,'inFill',False):
                    fpoints = [inFillX0,inFillY] + points + [inFillX1,inFillY]
                    filler = getattr(rowStyle, 'filler', None)
                    if filler:
                        filler.fill(self,inFillG,rowNo,rowColor,fpoints)
                    else:
                        inFillG.add(Polygon(fpoints,fillColor=rowColor,strokeColor=rowColor,strokeWidth=width or 0.1))
                if inFill in (None,0,2):
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if width:
                        line.strokeWidth = width
                    if dash:
                        line.strokeDashArray = dash
                    lG.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(lines, 'symbol'):
                uSymbol = lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                if bubblePlot: drow = self.data[rowNo]
                for j,xy in enumerate(row):
                    if (styleRowNo,j) in lines._children:
                        juSymbol = getattr(lines[styleRowNo,j],'symbol',uSymbol)
                    else:
                        juSymbol = uSymbol
                    if juSymbol is uSymbol:
                        symbol = uSymbol
                        symColor = rowColor
                    else:
                        symbol = juSymbol
                        symColor = getattr(symbol,'fillColor',rowColor)
                    symbol = uSymbol2Symbol(symbol,xy[0],xy[1],symColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)
            else:
                if bubblePlot: drow = self.data[rowNo]
                for j,xy in enumerate(row):
                    juSymbol = getattr(lines[styleRowNo,j],'symbol',None)
                    if not juSymbol: continue
                    symColor = getattr(juSymbol,'fillColor',getattr(juSymbol,'strokeColor',rowColor))
                    symbol = uSymbol2Symbol(juSymbol,xy[0],xy[1],symColor)
                    if symbol:
                        if bubblePlot:
                            symbol.size = bubbleR*(drow[j][2]/bubbleMax)**0.5
                        g.add(symbol)

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

            shader = getattr(rowStyle, 'shader', None)
            if shader: shader.shade(self,g,rowNo,rowColor,row)

        return g
Exemple #7
0
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = range(len(self._positions))
        if self.reversePlotOrder: P.reverse()
        inFill = self.inFill
        if inFill:
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self,'_inFillG',g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo in P:
            row = self._positions[rowNo]
            styleCount = len(self.lines)
            styleIdx = rowNo % styleCount
            rowStyle = self.lines[styleIdx]
            rowColor = rowStyle.strokeColor
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle,'lineStyle',None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(self.lines, 'strokeWidth'):
                strokeWidth = self.lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle=='bar':
                barWidth = getattr(rowStyle,'barWidth',Percentage(50))
                fillColor = getattr(rowStyle,'fillColor',rowColor)
                if isinstance(barWidth,Percentage):
                    hbw = self._hngs*barWidth*0.01
                else:
                    hbw = barWidth*0.5
                for colNo in range(len(row)):
                    x,y = row[colNo]
                    g.add(Rect(x-hbw,min(y,yzero),2*hbw,abs(y-yzero),strokeWidth=strokeWidth,strokeColor=rowColor,fillColor=fillColor))
            elif self.joinedLines or lineStyle=='joinedLine':
                points = []
                for colNo in range(len(row)):
                    points += row[colNo]
                if inFill:
                    points = points + [inFillX1,inFillY,inFillX0,inFillY]
                    inFillG.add(Polygon(points,fillColor=rowColor,strokeColor=rowColor,strokeWidth=0.1))
                else:
                    line = PolyLine(points,strokeColor=rowColor,strokeLineCap=0,strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(self.lines, 'symbol'):
                uSymbol = self.lines.symbol
            else:
                uSymbol = None

            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)

        return g
    def makeLines(self):
        g = Group()

        labelFmt = self.lineLabelFormat
        P = self._positions
        if self.reversePlotOrder: P.reverse()
        lines = self.lines
        styleCount = len(lines)
        _inFill = self.inFill
        if (_inFill or self._pairInFills or [
                rowNo for rowNo in range(len(P))
                if getattr(lines[rowNo % styleCount], 'inFill', False)
        ]):
            inFillY = self.categoryAxis._y
            inFillX0 = self.valueAxis._x
            inFillX1 = inFillX0 + self.categoryAxis._length
            inFillG = getattr(self, '_inFillG', g)
        yzero = self._yzero

        # Iterate over data rows.
        for rowNo, row in enumerate(
                reversed(P) if self.reversePlotOrder else P):
            styleIdx = rowNo % styleCount
            rowStyle = lines[styleIdx]
            strokeColor = rowStyle.strokeColor
            fillColor = getattr(rowStyle, 'fillColor', strokeColor)
            inFill = getattr(rowStyle, 'inFill', _inFill)
            dash = getattr(rowStyle, 'strokeDashArray', None)
            lineStyle = getattr(rowStyle, 'lineStyle', None)

            if hasattr(rowStyle, 'strokeWidth'):
                strokeWidth = rowStyle.strokeWidth
            elif hasattr(lines, 'strokeWidth'):
                strokeWidth = lines.strokeWidth
            else:
                strokeWidth = None

            # Iterate over data columns.
            if lineStyle == 'bar':
                barWidth = getattr(rowStyle, 'barWidth', Percentage(50))
                if isinstance(barWidth, Percentage):
                    hbw = self._hngs * barWidth * 0.01
                else:
                    hbw = barWidth * 0.5
                for x, y in row:
                    g.add(
                        Rect(x - hbw,
                             min(y, yzero),
                             2 * hbw,
                             abs(y - yzero),
                             strokeWidth=strokeWidth,
                             strokeColor=strokeColor,
                             fillColor=fillColor))
            elif self.joinedLines or lineStyle == 'joinedLine':
                points = flatten(row)
                if inFill or isinstance(row, FillPairedData):
                    filler = getattr(rowStyle, 'filler', None)
                    if isinstance(row, FillPairedData):
                        fpoints = points + flatten(reversed(P[row.other]))
                    else:
                        fpoints = [inFillX0, inFillY
                                   ] + points + [inFillX1, inFillY]
                    if filler:
                        filler.fill(self, inFillG, rowNo, fillColor, fpoints)
                    else:
                        inFillG.add(
                            Polygon(fpoints,
                                    fillColor=fillColor,
                                    strokeColor=strokeColor
                                    if strokeColor == fillColor else None,
                                    strokeWidth=strokeWidth or 0.1))
                if not inFill or inFill == 2 or strokeColor != fillColor:
                    line = PolyLine(points,
                                    strokeColor=strokeColor,
                                    strokeLineCap=0,
                                    strokeLineJoin=1)
                    if strokeWidth:
                        line.strokeWidth = strokeWidth
                    if dash:
                        line.strokeDashArray = dash
                    g.add(line)

            if hasattr(rowStyle, 'symbol'):
                uSymbol = rowStyle.symbol
            elif hasattr(lines, 'symbol'):
                uSymbol = lines.symbol
            else:
                uSymbol = None

            if uSymbol:
                for colNo, (x, y) in enumerate(row):
                    symbol = uSymbol2Symbol(tpcGetItem(uSymbol, colNo), x, y,
                                            rowStyle.strokeColor)
                    if symbol: g.add(symbol)

            # Draw item labels.
            for colNo, (x, y) in enumerate(row):
                self.drawLabel(g, rowNo, colNo, x, y)

        return g