#NEWLINE# def drawLines( self , width = None , dash = None , linecap = 'butt' , linejoin = 'miter' ) : #NEWLINE# #INDENT# if ( not width ) : #NEWLINE# #INDENT# width = self . lineWidth #NEWLINE# #UNINDENT# self . ctx . set_line_width ( width ) #NEWLINE# originalWidth = width #NEWLINE# width = ( float ( ( int ( width ) % 2 ) ) / 2 ) #NEWLINE# if dash : #NEWLINE# #INDENT# self . ctx . set_dash ( dash , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . ctx . set_dash ( [ ] , 0 ) #NEWLINE# #UNINDENT# self . ctx . set_line_cap ( { #NEWLINE# #INDENT# 'butt' : cairo . LINE_CAP_BUTT , #NEWLINE# 'round' : cairo . LINE_CAP_ROUND , #NEWLINE# 'square' : cairo . LINE_CAP_SQUARE , #NEWLINE# #UNINDENT# } [ linecap ] ) #NEWLINE# self . ctx . set_line_join ( { #NEWLINE# #INDENT# 'miter' : cairo . LINE_JOIN_MITER , #NEWLINE# 'round' : cairo . LINE_JOIN_ROUND , #NEWLINE# 'bevel' : cairo . LINE_JOIN_BEVEL , #NEWLINE# #UNINDENT# } [ linejoin ] ) #NEWLINE# singleStacked = False #NEWLINE# for series in self . data : #NEWLINE# #INDENT# if ( 'stacked' in series . options ) : #NEWLINE# #INDENT# singleStacked = True #NEWLINE# #UNINDENT# #UNINDENT# if singleStacked : #NEWLINE# #INDENT# self . data = sort_stacked ( self . data ) #NEWLINE# #UNINDENT# if ( ( self . areaMode == 'stacked' ) and ( not self . secondYAxis ) ) : #NEWLINE# #INDENT# total = [ ] #NEWLINE# for series in self . data : #NEWLINE# #INDENT# if ( 'drawAsInfinite' in series . options ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# series . options [ 'stacked' ] = True #NEWLINE# for i in range ( len ( series ) ) : #NEWLINE# #INDENT# if ( len ( total ) <= i ) : #NEWLINE# #INDENT# total . append ( 0 ) #NEWLINE# #UNINDENT# if ( series [ i ] is not None ) : #NEWLINE# #INDENT# original = series [ i ] #NEWLINE# series [ i ] += total [ i ] #NEWLINE# total [ i ] += original #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . areaMode == 'first' ) : #NEWLINE# #INDENT# self . data [ 0 ] . options [ 'stacked' ] = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . areaMode == 'all' ) : #NEWLINE# #INDENT# for series in self . data : #NEWLINE# #INDENT# if ( 'drawAsInfinite' not in series . options ) : #NEWLINE# #INDENT# series . options [ 'stacked' ] = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if self . params . get ( 'areaAlpha' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# alpha = float ( self . params [ 'areaAlpha' ] ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# alpha = 0.5 #NEWLINE# #UNINDENT# strokeSeries = [ ] #NEWLINE# for series in self . data : #NEWLINE# #INDENT# if ( 'stacked' in series . options ) : #NEWLINE# #INDENT# series . options [ 'alpha' ] = alpha #NEWLINE# newSeries = TimeSeries ( series . name , series . start , series . end , ( series . step * series . valuesPerPoint ) , [ x for x in series ] ) #NEWLINE# newSeries . xStep = series . xStep #NEWLINE# newSeries . color = series . color #NEWLINE# if ( 'secondYAxis' in series . options ) : #NEWLINE# #INDENT# newSeries . options [ 'secondYAxis' ] = True #NEWLINE# #UNINDENT# strokeSeries . append ( newSeries ) #NEWLINE# #UNINDENT# #UNINDENT# self . data += areaYFrom #NEWLINE# #UNINDENT# self . ctx . set_line_width ( 1.0 ) #NEWLINE# self . ctx . rectangle ( self . area [ 'xmin' ] , self . area [ 'ymin' ] , ( self . area [ 'xmax' ] - self . area [ 'xmin' ] ) , ( self . area [ 'ymax' ] - self . area [ 'ymin' ] ) ) #NEWLINE# self . ctx . clip ( ) #NEWLINE# self . ctx . set_line_width ( originalWidth ) #NEWLINE# self . ctx . save ( ) #NEWLINE# clipRestored = False #NEWLINE# for series in self . data : #NEWLINE# #INDENT# if ( 'stacked' not in series . options ) : #NEWLINE# #INDENT# if ( not clipRestored ) : #NEWLINE# #INDENT# clipRestored = True #NEWLINE# self . ctx . restore ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'lineWidth' in series . options ) : #NEWLINE# #INDENT# self . ctx . set_line_width ( series . options [ 'lineWidth' ] ) #NEWLINE# #UNINDENT# if ( 'dashed' in series . options ) : #NEWLINE# #INDENT# self . ctx . set_dash ( [ series . options [ 'dashed' ] ] , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . ctx . set_dash ( [ ] , 0 ) #NEWLINE# #UNINDENT# missingPoints = ( ( series . start - self . startTime ) / series . step ) #NEWLINE# startShift = ( series . xStep * ( missingPoints / series . valuesPerPoint ) ) #NEWLINE# x = ( ( float ( self . area [ 'xmin' ] ) + startShift ) + ( self . lineWidth / 2.0 ) ) #NEWLINE# y = float ( self . area [ 'ymin' ] ) #NEWLINE# startX = x #NEWLINE# if series . options . get ( 'invisible' ) : #NEWLINE# #INDENT# self . setColor ( series . color , 0 , True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . setColor ( series . color , ( series . options . get ( 'alpha' ) or 1.0 ) ) #NEWLINE# #UNINDENT# consecutiveNones = 0 #NEWLINE# for ( index , value ) in enumerate ( series ) : #NEWLINE# #INDENT# if ( value != value ) : #NEWLINE# #INDENT# value = None #NEWLINE# #UNINDENT# if ( ( value is None ) and self . params . get ( 'drawNullAsZero' ) ) : #NEWLINE# #INDENT# value = 0.0 #NEWLINE# #UNINDENT# if ( value is None ) : #NEWLINE# #INDENT# if ( consecutiveNones == 0 ) : #NEWLINE# #INDENT# self . ctx . line_to ( x , y ) #NEWLINE# if ( 'stacked' in series . options ) : #NEWLINE# #INDENT# if self . secondYAxis : #NEWLINE# #INDENT# if ( 'secondYAxis' in series . options ) : #NEWLINE# #INDENT# self . fillAreaAndClip ( x , y , startX , self . getYCoord ( 0 , 'right' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . fillAreaAndClip ( x , y , startX , self . getYCoord ( 0 , 'left' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . fillAreaAndClip ( x , y , startX , self . getYCoord ( 0 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# x += series . xStep #NEWLINE# consecutiveNones += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . secondYAxis : #NEWLINE# #INDENT# if ( 'secondYAxis' in series . options ) : #NEWLINE# #INDENT# y = self . getYCoord ( value , 'right' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# y = self . getYCoord ( value , 'left' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# y = self . getYCoord ( value ) #NEWLINE# #UNINDENT# if ( y is None ) : #NEWLINE# #INDENT# value = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( y < 0 ) : #NEWLINE# #INDENT# y = 0 #NEWLINE# #UNINDENT# #UNINDENT# if ( ( 'drawAsInfinite' in series . options ) and ( value > 0 ) ) : #NEWLINE# #INDENT# self . ctx . move_to ( x , self . area [ 'ymax' ] ) #NEWLINE# self . ctx . line_to ( x , self . area [ 'ymin' ] ) #NEWLINE# self . ctx . stroke ( ) #NEWLINE# x += series . xStep #NEWLINE# continue #NEWLINE# #UNINDENT# if ( consecutiveNones > 0 ) : #NEWLINE# #INDENT# startX = x #NEWLINE# #UNINDENT# if ( self . lineMode == 'staircase' ) : #NEWLINE# #INDENT# if ( consecutiveNones > 0 ) : #NEWLINE# #INDENT# self . ctx . move_to ( x , y ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . ctx . line_to ( x , y ) #NEWLINE# #UNINDENT# x += series . xStep #NEWLINE# self . ctx . line_to ( x , y ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . lineMode == 'slope' ) : #NEWLINE# #INDENT# if ( consecutiveNones > 0 ) : #NEWLINE# #INDENT# self . ctx . move_to ( x , y ) #NEWLINE# #UNINDENT# self . ctx . line_to ( x , y ) #NEWLINE# x += series . xStep #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . lineMode == 'connected' ) : #NEWLINE# #INDENT# if ( ( consecutiveNones > self . connectedLimit ) or ( consecutiveNones == index ) ) : #NEWLINE# #INDENT# self . ctx . move_to ( x , y ) #NEWLINE# #UNINDENT# self . ctx . line_to ( x , y ) #NEWLINE# x += series . xStep #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# consecutiveNones = 0 #NEWLINE# #UNINDENT# #UNINDENT# if ( 'stacked' in series . options ) : #NEWLINE# #INDENT# if ( self . lineMode == 'staircase' ) : #NEWLINE# #INDENT# xPos = x #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# xPos = ( x - series . xStep ) #NEWLINE# #UNINDENT# if self . secondYAxis : #NEWLINE# #INDENT# if ( 'secondYAxis' in series . options ) : #NEWLINE# #INDENT# areaYFrom = self . getYCoord ( 0 , 'right' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# areaYFrom = self . getYCoord ( 0 , 'left' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# areaYFrom = self . getYCoord ( 0 ) #NEWLINE# #UNINDENT# self . fillAreaAndClip ( xPos , y , startX , areaYFrom ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . ctx . stroke ( ) #NEWLINE# #UNINDENT# self . ctx . set_line_width ( originalWidth ) #NEWLINE# if ( 'dash' in series . options ) : #NEWLINE# #INDENT# if dash : #NEWLINE# #INDENT# self . ctx . set_dash ( dash , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . ctx . set_dash ( [ ] , 0 )