本文整理汇总了Python中graphite.render.datalib.TimeSeries.color方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.color方法的具体用法?Python TimeSeries.color怎么用?Python TimeSeries.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphite.render.datalib.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.color方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_TimeSeries_equal_list_color
# 需要导入模块: from graphite.render.datalib import TimeSeries [as 别名]
# 或者: from graphite.render.datalib.TimeSeries import color [as 别名]
def test_TimeSeries_equal_list_color(self):
values = range(0,100)
series1 = TimeSeries("collectd.test-db.load.value", 0, len(values), 1, values)
series1.color = 'white'
series2 = TimeSeries("collectd.test-db.load.value", 0, len(values), 1, values)
series2.color = 'white'
self.assertEqual(series1, series2)
示例2: test_TimeSeries_equal_list_color_bad2
# 需要导入模块: from graphite.render.datalib import TimeSeries [as 别名]
# 或者: from graphite.render.datalib.TimeSeries import color [as 别名]
def test_TimeSeries_equal_list_color_bad2(self):
values = range(0,100)
series1 = TimeSeries("collectd.test-db.load.value", 0, len(values), 1, values)
series2 = TimeSeries("collectd.test-db.load.value", 0, len(values), 1, values)
series1.color = 'white'
with self.assertRaises(AssertionError):
self.assertEqual(series1, series2)
示例3: drawLines
# 需要导入模块: from graphite.render.datalib import TimeSeries [as 别名]
# 或者: from graphite.render.datalib.TimeSeries import color [as 别名]
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])
# stack the values
if self.areaMode == 'stacked':
total = []
for series in self.data:
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
self.data = reverse_sort(self.data)
# 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)
if self.params.get('areaAlpha') and self.areaMode == 'first':
alphaSeries = TimeSeries(None, self.data[0].start, self.data[0].end, self.data[0].step, [x for x in self.data[0]])
alphaSeries.xStep = self.data[0].xStep
alphaSeries.color = self.data[0].color
try:
alphaSeries.options['alpha'] = float(self.params['areaAlpha'])
except ValueError:
pass
self.data.insert(0, alphaSeries)
for series in self.data:
if series.options.has_key('lineWidth'): # adjusts the lineWidth of this line if option is set on the series
self.ctx.set_line_width(series.options['lineWidth'])
if series.options.has_key('dashed'): # turn on dashing if dashed option set
self.ctx.set_dash([ series.options['dashed'] ],1)
else:
self.ctx.set_dash([], 0)
x = float(self.area['xmin']) + (self.lineWidth / 2.0)
y = float(self.area['ymin'])
self.setColor( series.color, series.options.get('alpha') or 1.0)
fromNone = True
for value in series:
if value is None and self.params.get('drawNullAsZero'):
value = 0.0
if value is None:
if not fromNone and self.areaMode != 'none': #Close off and fill area before unknown interval
self.ctx.line_to(x, self.area['ymax'])
self.ctx.close_path()
self.ctx.fill()
x += series.xStep
fromNone = True
else:
y = self.area['ymax'] - ((float(value) - self.yBottom) * self.yScaleFactor)
if y < 0: y = 0
if series.options.has_key('drawAsInfinite') 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 self.lineMode == 'staircase':
if fromNone:
if self.areaMode != 'none':
self.ctx.move_to(x,self.area['ymax'])
self.ctx.line_to(x,y)
else:
self.ctx.move_to(x,y)
else:
#.........这里部分代码省略.........