本文整理汇总了Python中pygooglechart.SimpleLineChart.fill_linear_stripes方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart.fill_linear_stripes方法的具体用法?Python SimpleLineChart.fill_linear_stripes怎么用?Python SimpleLineChart.fill_linear_stripes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygooglechart.SimpleLineChart
的用法示例。
在下文中一共展示了SimpleLineChart.fill_linear_stripes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: simpleChart3
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def simpleChart3(bottom_labels, data1, data2):
datamin, datamax = min(min(data1, data2)), max(max(data1, data2))
datamin = int(datamin - 0.5)
datamax = int(datamax + 0.5)
chart = SimpleLineChart(200, 125, y_range=[datamin, datamax])
chart.add_data(data1)
chart.add_data(data2)
left_axis = [datamin,0,datamax]
left_axis[0] = '' # no label at 0
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.set_axis_labels(Axis.BOTTOM, bottom_labels)
chart.set_axis_labels(Axis.BOTTOM, ['X Axis']) # second label below first one
chart.set_axis_positions(2, [50.0]) # position, left is 0., right is 100., 50. is center
# Set the line colour
chart.set_colours(['0000FF', 'FF0000'])
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# Set vertical stripes
stripes = ['CCCCCC', 0.2, 'FFFFFF', 0.2]
chart.fill_linear_stripes(Chart.CHART, 0, *stripes)
return chart
示例2: RenderGoogleChart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def RenderGoogleChart(data, filename):
"""
create a GoogleChart from decoded data under filename (.png)
"""
print "Rendering GoogleChart [%s]" % filename
# Retrieve chart data
elements=[]
max_y = 0
min_y = 9999
for i in range(len(data["time"])):
if data["cps"][i] > max_y: max_y = data["cps"][i]
if data["cps"][i] < min_y: min_y = data["cps"][i]
elements.append(data["cps"][i])
# Chart size of 600x375 pixels and specifying the range for the Y axis
chart = SimpleLineChart(600, 375, y_range=[min_y-0.1, max_y+0.1])
# Add the chart data
chart.add_data(elements)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# Define the Y axis labels
left_axis = [x * 0.1 for x in range(0, int(max_y/0.1))]
left_axis[0] = 'CPS'
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.download(filename)
示例3: get
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def get(self):
list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep']
list2 = []
for title in list:
list2.append( int(getdata(title,'funds').custom['amount'].text))
max_y = 10000
chart = SimpleLineChart(200, 125, y_range=[0, max_y])
chart.add_data([2000,3000,5000,1200,5000,4000,1000,3000,5900])
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, list)
url2 = chart.get_url()
self.response.out.write(template.render('template/donate.html',{
'url2' :url2, }))
示例4: queryData
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def queryData(ID=1):
# connect
# create a cursor
cursor = db.cursor()
#cursor.execute("SELECT available, readtime FROM occupancy WHERE site='%s'" % ID)
cursor.execute("SELECT available, readtime FROM occupancy WHERE site='%s'" % ID)
query = cursor.fetchall()
log(query)
# Set the vertical range from 0 to 100
max_y = 50
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(800, 300, y_range=[0, max_y])
data, y_axis = ([[x[i] for x in query] for i in [0, 1]])
length = len(y_axis)
if length > 20:
step = abs(len(y_axis)/20)
y_axis = y_axis[0:length:step]
chart.add_data(data)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
# chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = range(0, max_y + 1, 2)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, y_axis)
return chart
示例5: stripes
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def stripes():
# Set the vertical range from 0 to 100
max_y = 100
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(600, 500, y_range=[0, max_y])
# Add the chart data
# data = [
# 32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37,
# 37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55,
# 55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32
# ]
# data2 = [
# 55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32, 62, 60, 55,
# 32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37,
# 37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62
# ]
data = xrange(0, 100, 20)
data2 = [0, 20, 20, 40, 40, 80, 80, 100, 100]
chart.add_data(data)
chart.add_data(data2)
# Set the line colour to blue
chart.set_colours(['0000FF','00CC00'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, \
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])
chart.download('line-stripes.png')
示例6: ShowChartByGoogle
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def ShowChartByGoogle(handler, data, book, ups):
oneday = datetime.timedelta(days=1)
date = ups[0].date
xlabel = [str(date.day)]
ylabel = range(0, book.pages + 1, ((book.pages / 8) / 50 + 1) * 50)
for (i, up) in enumerate(ups):
if i == 0: continue
days = (up.date - ups[i-1].date).days
for j in range(days):
date += oneday
if date.weekday() == 0: # only records sunday
if date.day < 7:
xlabel.append(str(date.month))
else:
xlabel.append('.')
chart = SimpleLineChart(600, 320, y_range=[0, ylabel[-1]])
chart.add_data(data)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = ylabel
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, xlabel)
doRender(handler, 'progress.html', {
'book': book,
'imgurl': chart.get_url(),
'method': 'google'})
示例7: generateGraph
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def generateGraph(fMesureGlobalPerCent, nbComparison, resPath):
max_y = 100#Fmesure à 100%
chart = SimpleLineChart(500, 500, y_range=[0, max_y])
chart.add_data(fMesureGlobalPerCent)
chart.set_colours(['0000FF'])
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
chart.set_grid(0, 25, 5, 5)
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
y_axis = []
for x in range(nbComparison):
if x%5 == 0:
y_axis.append(x)
chart.set_axis_labels(Axis.BOTTOM, y_axis)
chart.download(resPath)
示例8: get_chart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def get_chart(self, data, date_start, date_end, colours=None):
# Set the vertical range from max_value plus 10
if not data:
return None
max_y = max([max(l) for l in data])
if max_y < 10:
mult = 1
else:
y_scale = max_y
mult = 1
while y_scale/10 > 1:
mult = mult*10
y_scale = y_scale/10
max_y = max_y + mult
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(600, 300, y_range=[0, max_y])
for i in data:
chart.add_data(i)
if not colours:
chart.set_colours(['0000FF']) # Set the line colour to blue
else:
chart.set_colours(colours)
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'F2F2F2', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
left_axis = range(0, max_y + 1, mult)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, \
self.get_chart_x_axis_label(date_start, date_end))
return chart.get_url()
示例9: _plot_timeseries
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def _plot_timeseries(self, options, args, fh):
"""Plot a timeseries graph"""
from pygooglechart import Chart, SimpleLineChart, Axis
delimiter = options.delimiter
field = options.field-1
datefield = options.datefield-1
pts = []
for l in imap(lambda x: x.strip(), fh):
splitted_line = l.split(delimiter)
v = float(splitted_line[field])
t = datetime.strptime(splitted_line[datefield], options.dateformat)
pts.append((t, v))
if options.get('limit', None):
# Only wanna use top (earliest) N samples by key, sort and truncate
pts = sorted(pts, key=itemgetter(0), reverse=True)[:options.limit]
if not pts:
raise ValueError("No data to plot")
max_y = int(max((v for t, v in pts)))
chart = SimpleLineChart(options.width, options.height,y_range=[0, max_y])
# Styling
chart.set_colours(['0000FF'])
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
chart.set_grid(0, 25, 5, 5)
ts, vals = zip(*pts)
chart.add_data(vals)
# Axis labels
chart.set_axis_labels(Axis.BOTTOM, ts)
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
return chart
示例10: linegraph
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def linegraph(self,days,bars,output,title = ""):
data = []
min_count = 0
max_count = 0
date = lambda i:datetime.date.today() + datetime.timedelta(-days + i)
for i in range(0,days+1):
count = bars[date(i)]
max_count = max(count,max_count)
min_count = min(count,min_count)
data.append(count)
chart = SimpleLineChart(800,350,y_range=[min_count, 60000])
chart.add_data(data)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
d = max(1/float(days),round(7/float(days),2))
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', d, 'FFFFFF', d)
fmt="%d/%m"
chart.set_axis_labels(Axis.BOTTOM, \
[date(i).strftime(fmt) for i in range(0,days,7)])
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
delta = float(max_count-min_count) / 100
skip = int(delta) / 5 * 100
left_axis = range(0, 60000 + 1, skip)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
if len(title) > 0:
chart.set_title(title % days)
chart.download(output)
示例11: makeChart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def makeChart():
# Set the vertical range from 0 to 100
max_y = 100
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(400, 250, y_range=[0, max_y])
# Add the chart data
# Aggregate data into array before adding to chart
data = [
32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37,
37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55,
55, 52, 47, 44, 44, 40, 40, 37, 34, 34, 32, 32, 32, 31, 32
]
#for i in data:
# chart.add_data(i)
chart.add_data(data)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, \
['9 am', '6 pm', '12 am'])
return chart
示例12: _plot_line
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def _plot_line(self, options, args, fh):
"""Plot a line chart"""
from pygooglechart import Chart, SimpleLineChart, Axis
delimiter = options.delimiter
field = options.field
pts = []
for l in imap(lambda x: x.strip(), fh):
splitted_line = l.split(delimiter)
k = int(splitted_line.pop(field-1))
pts.append((k, ' '.join(splitted_line)))
if options.get('limit', None):
# Only wanna use top N samples by key, sort and truncate
pts = sorted(pts, key=itemgetter(0), reverse=True)[:options.limit]
if not pts:
raise ValueError("No data to plot")
max_y = max((v for v, label in pts))
chart = SimpleLineChart(options.width, options.height,y_range=[0, max_y])
# Styling
chart.set_colours(['0000FF'])
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
chart.set_grid(0, 25, 5, 5)
data, labels = zip(*pts)
chart.add_data(data)
# Axis labels
chart.set_axis_labels(Axis.BOTTOM, labels)
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
return chart
示例13: simpleChart2
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def simpleChart2(bottom_labels, data):
# round min and max to nearest integers
datamin = int(min(data) - 0.5)
datamax = int(max(data) + 0.5)
chart = SimpleLineChart(200, 125, y_range=[datamin, datamax])
chart.add_data(data)
left_axis = ['min',0,'max']
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.set_axis_labels(Axis.BOTTOM, bottom_labels)
chart.set_axis_labels(Axis.BOTTOM, ['X Axis']) # second label below first one
chart.set_axis_positions(2, [50.0]) # position, left is 0., right is 100., 50. is center
# Set the line colour
chart.set_colours(['0000FF'])
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# Set vertical stripes
stripes = ['CCCCCC', 0.2, 'FFFFFF', 0.2]
chart.fill_linear_stripes(Chart.CHART, 0, *stripes)
return chart
示例14: draw_plot
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
def draw_plot(data, generation):
# Set the vertical range from 0 to 100
max_y = data[0]
# Chart size of 200x125 pixels and specifying the range for the Y axis
chart = SimpleLineChart(600, 325, y_range=[0, max_y])
# Add the chart data
"""
data = [
32, 34, 34, 32, 34, 34, 32, 32, 32, 34, 34, 32, 29, 29, 34, 34, 34, 37,
37, 39, 42, 47, 50, 54, 57, 60, 60, 60, 60, 60, 60, 60, 62, 62, 60, 55,
55, 52, 47, 44, 44, 40, 40, 37, 0,0,0,0,0,0,0
]
"""
chart.add_data(data)
# Set the line colour to blue
chart.set_colours(['0000FF'])
# Set the vertical stripes
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
# The Y axis labels contains 0 to 100 skipping every 25, but remove the
# first number because it's obvious and gets in the way of the first X
# label.
left_axis = range(0, max_y + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, [str(x) for x in xrange(1, generation+1)][::14])
chart.download('plot.png')
示例15: generateGraphs
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import fill_linear_stripes [as 别名]
#.........这里部分代码省略.........
chart.download('popular_malware.png')
#Connections per Day Dionaea and Glastopf - 7 Days - Dionaea
querySQL = "SELECT strftime('%Y', connection_timestamp,'unixepoch') as 'year', strftime('%m', connection_timestamp,'unixepoch') as 'month', strftime('%d', connection_timestamp,'unixepoch') as 'day', count(strftime('%m', connection_timestamp,'unixepoch')) as 'num' FROM connections GROUP BY strftime('%Y', connection_timestamp,'unixepoch'), strftime('%m', connection_timestamp,'unixepoch'), strftime('%d', connection_timestamp,'unixepoch') ORDER BY strftime('%Y', connection_timestamp,'unixepoch') DESC, strftime('%m', connection_timestamp,'unixepoch') DESC, strftime('%d', connection_timestamp,'unixepoch') DESC LIMIT 7"
print querySQL
c.execute(querySQL)
#Connections per Day Dionaea and Glastopf - 7 Days - Glastopf
querySQL = "SELECT COUNT(time), SUBSTR(time,-20,12) AS stripped FROM events GROUP BY stripped ORDER BY stripped DESC LIMIT 7"
print querySQL
x.execute(querySQL)
chart = SimpleLineChart(pieChartWidth, pieChartHeight, y_range=[0, 5000])
flist = []
seclist = []
for (row,rowx) in zip(c,x):
print(row)
print(rowx)
l = list(row)
l[3]=row[3]+rowx[0]
flist.append(l[3])
date = '%s-%s-%s' % (str(row[0]),str(row[1]),str(row[2]))
seclist.append(date)
flist.reverse()
seclist.reverse()
chart.add_data(flist)
chart.set_axis_labels(Axis.BOTTOM,seclist)
chart.set_colours(['0000FF'])
chart.fill_linear_stripes(Chart.CHART, 0, 'CCCCCC', 0.2, 'FFFFFF', 0.2)
chart.set_grid(0, 20, 5, 5)
left_axis = range(0, 5001, 1000)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.download('connections_per_day.png')
#
#
# Glastopf Queries starting here!
#
#
#Top15 intext requests
querySQL = 'SELECT count, content FROM intext ORDER BY count DESC LIMIT 15'
print querySQL
x.execute(querySQL)
chart = PieChart2D(pieChartWidth, pieChartHeight, colours=pieColours)
flist = []
seclist = []
for row in x:
print(row)
flist.append(row[0])
seclist.append(str(row[1]))
chart.add_data(flist)
chart.set_legend(seclist)