def drawLines(self, width=None, dash=None, linecap='butt',
                  linejoin='miter'):
        if not width:
            width = self.lineWidth
        self.ctx.set_line_width(width)
        originalWidth = width
        width = float(int(width) % 2) / 2
        if dash:
            self.ctx.set_dash(dash, 1)
        else:
            self.ctx.set_dash([], 0)
        self.ctx.set_line_cap({
            'butt': cairo.LINE_CAP_BUTT,
            'round': cairo.LINE_CAP_ROUND,
            'square': cairo.LINE_CAP_SQUARE,
        }[linecap])
        self.ctx.set_line_join({
            'miter': cairo.LINE_JOIN_MITER,
            'round': cairo.LINE_JOIN_ROUND,
            'bevel': cairo.LINE_JOIN_BEVEL,
        }[linejoin])

        # check whether there is an stacked metric
        singleStacked = False
        for series in self.data:
            if 'stacked' in series.options:
                singleStacked = True
        if singleStacked:
            self.data = sort_stacked(self.data)

        # stack the values
        if self.areaMode == 'stacked' and not self.secondYAxis:
            # TODO Allow stacked area mode with secondYAxis
            total = []
            for series in self.data:
                if 'drawAsInfinite' in series.options:
                    continue

                series.options['stacked'] = True
                for i in range(len(series)):
                    if len(total) <= i:
                        total.append(0)

                    if series[i] is not None:
                        original = series[i]
                        series[i] += total[i]
                        total[i] += original
        elif self.areaMode == 'first':
            self.data[0].options['stacked'] = True
        elif self.areaMode == 'all':
            for series in self.data:
                if 'drawAsInfinite' not in series.options:
                    series.options['stacked'] = True

        # apply alpha channel and create separate stroke series
        if self.params.get('areaAlpha'):
            try:
                alpha = float(self.params['areaAlpha'])
            except __HOLE__:
                alpha = 0.5

            strokeSeries = []
            for series in self.data:
                if 'stacked' in series.options:
                    series.options['alpha'] = alpha

                    newSeries = TimeSeries(
                        series.name, series.start, series.end,
                        series.step * series.valuesPerPoint,
                        [x for x in series])
                    newSeries.xStep = series.xStep
                    newSeries.color = series.color
                    if 'secondYAxis' in series.options:
                        newSeries.options['secondYAxis'] = True
                    strokeSeries.append(newSeries)
            self.data += strokeSeries

        # setup the clip region
        self.ctx.set_line_width(1.0)
        self.ctx.rectangle(self.area['xmin'], self.area['ymin'],
                           self.area['xmax'] - self.area['xmin'],
                           self.area['ymax'] - self.area['ymin'])
        self.ctx.clip()
        self.ctx.set_line_width(originalWidth)

        # save clip to restore once stacked areas are drawn
        self.ctx.save()
        clipRestored = False

        for series in self.data:

            if 'stacked' not in series.options:
                # stacked areas are always drawn first. if this series is not
                # stacked, we finished stacking. reset the clip region so
                # lines can show up on top of the stacked areas.
                if not clipRestored:
                    clipRestored = True
                    self.ctx.restore()

            if 'lineWidth' in series.options:
                self.ctx.set_line_width(series.options['lineWidth'])

            if 'dashed' in series.options:
                self.ctx.set_dash([series.options['dashed']], 1)
            else:
                self.ctx.set_dash([], 0)

            # Shift the beginning of drawing area to the start of the series
            # if the graph itself has a larger range
            missingPoints = (series.start - self.startTime) / series.step
            startShift = series.xStep * (missingPoints / series.valuesPerPoint)
            x = float(self.area['xmin']) + startShift + (self.lineWidth / 2.0)
            y = float(self.area['ymin'])

            startX = x

            if series.options.get('invisible'):
                self.setColor(series.color, 0, True)
            else:
                self.setColor(series.color,
                              series.options.get('alpha') or 1.0)

            # The number of preceeding datapoints that had a None value.
            consecutiveNones = 0

            for index, value in enumerate(series):
                if value != value:  # convert NaN to None
                    value = None

                if value is None and self.params.get('drawNullAsZero'):
                    value = 0.0

                if value is None:
                    if consecutiveNones == 0:
                        self.ctx.line_to(x, y)
                        if 'stacked' in series.options:
                            # Close off and fill area before unknown interval
                            if self.secondYAxis:
                                if 'secondYAxis' in series.options:
                                    self.fillAreaAndClip(
                                        x, y, startX,
                                        self.getYCoord(0, "right"))
                                else:
                                    self.fillAreaAndClip(
                                        x, y, startX,
                                        self.getYCoord(0, "left"))
                            else:
                                self.fillAreaAndClip(x, y, startX,
                                                     self.getYCoord(0))

                    x += series.xStep
                    consecutiveNones += 1

                else:
                    if self.secondYAxis:
                        if 'secondYAxis' in series.options:
                            y = self.getYCoord(value, "right")
                        else:
                            y = self.getYCoord(value, "left")
                    else:
                        y = self.getYCoord(value)

                    if y is None:
                        value = None
                    elif y < 0:
                        y = 0

                    if 'drawAsInfinite' in series.options and value > 0:
                        self.ctx.move_to(x, self.area['ymax'])
                        self.ctx.line_to(x, self.area['ymin'])
                        self.ctx.stroke()
                        x += series.xStep
                        continue

                    if consecutiveNones > 0:
                        startX = x

                    if self.lineMode == 'staircase':
                        if consecutiveNones > 0:
                            self.ctx.move_to(x, y)
                        else:
                            self.ctx.line_to(x, y)

                        x += series.xStep
                        self.ctx.line_to(x, y)

                    elif self.lineMode == 'slope':
                        if consecutiveNones > 0:
                            self.ctx.move_to(x, y)

                        self.ctx.line_to(x, y)
                        x += series.xStep

                    elif self.lineMode == 'connected':
                        # If if the gap is larger than the connectedLimit or
                        # if this is the first non-None datapoint in the
                        # series, start drawing from that datapoint.
                        if (
                            consecutiveNones > self.connectedLimit or
                            consecutiveNones == index
                        ):
                            self.ctx.move_to(x, y)

                        self.ctx.line_to(x, y)
                        x += series.xStep

                    consecutiveNones = 0

            if 'stacked' in series.options:
                if self.lineMode == 'staircase':
                    xPos = x
                else:
                    xPos = x-series.xStep
                if self.secondYAxis:
                    if 'secondYAxis' in series.options:
                        areaYFrom = self.getYCoord(0, "right")
                    else:
                        areaYFrom = self.getYCoord(0, "left")
                else:
                    areaYFrom = self.getYCoord(0)

                self.fillAreaAndClip(xPos, y, startX, areaYFrom)

            else:
                self.ctx.stroke()

            # return to the original line width
            self.ctx.set_line_width(originalWidth)
            if 'dash' in series.options:
                # if we changed the dash setting before, change it back now
                if dash:
                    self.ctx.set_dash(dash, 1)
                else:
                    self.ctx.set_dash([], 0)
dataset/ETHPy150Open brutasse/graphite-api/graphite_api/render/glyph.py/LineGraph.drawLines