本文整理汇总了Python中pygooglechart.SimpleLineChart类的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart类的具体用法?Python SimpleLineChart怎么用?Python SimpleLineChart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleLineChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeChartOfDay
def makeChartOfDay(data):
max_user = 150
chart = SimpleLineChart(400, 325, y_range=[0, max_user])
dataChart = []
for ore in range(24):
ore = str(ore)
if len(ore) == 1:
ore = '0'+ore
try:
dataChart.append(userList[data]['stats']['online'][ore])
except:
dataChart.append(0)
chart.add_data(dataChart)
chart.set_colours(['0000FF'])
left_axis = range(0, max_user + 1, 25)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# chart.set_axis_labels(Axis.BOTTOM, \
# ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])
chart.set_axis_labels(Axis.BOTTOM, \
range(0, 24))
return chart.get_url()
示例2: process
def process (name, date):
newdate = date[8:10] + "_" + date[5:7] + "_" + date[0:4]
url = r"http://www.lloydsbankinggroup.com/media/excel/2010/%s_historic_data.xls" % newdate
print url
url = r"http://www.lloydsbankinggroup.com/media/excel/2010/04_06_10_historic_data.xls"
book = xlrd.open_workbook(file_contents=scrape(url))
sheet = book.sheet_by_name (name)
months=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
data = []
i = 1
while i < 500:
try:
month = sheet.cell_value (i, 0)
year = sheet.cell_value (i, 1)
level = sheet.cell_value (i, 2)
except:
break
when= "%04d-%02d-01" % (int(year), months.index (month) + 1)
i = i + 1
data.append (level)
sqlite.save(unique_keys=["Date"], data={"Date":when, "Index":level})
chart = SimpleLineChart(500, 255, y_range=[0, 700])
chart.add_data (data)
metadata.save("chart", chart.get_url())
示例3: mk_chart
def mk_chart(self):
from pygooglechart import SimpleLineChart
chart = SimpleLineChart(self.width, self.height, colours=('91CF60', 'FC8D59'))
all_labels = [d[0] for d in self.cumulative]
chart.add_data([d[1] for d in self.cumulative])
chart.add_data([d[1] for d in self.newdata])
chart.set_axis_labels('y', range(0, self.cmax, (self.cmax / 4)))
chart.set_axis_labels('x', [all_labels[x] for x in
range(0, len(all_labels), (len(all_labels) / 4))])
return chart
示例4: __init__
def __init__(self, data, iter=0, width=300, height=300):
self.chart = SimpleLineChart(width, height, y_range=(0, 10))
legend = []
colors = ["cc0000", "00cc00", "0000cc", "990000", "009900", "000099", "0099ff", "FF9900", "9900ff", "ff0099"]
title = "die rolls per objective"
if iter > 0:
title = title + " (%s samples)" % iter
for i in data.keys():
self.chart.add_data(data[i])
legend.append(str(i))
logging.debug(legend)
logging.debug(colors)
self.chart.set_colours(colors)
self.chart.set_legend(legend)
grid_x_amount = 100 / (len(data[i]) - 1)
self.chart.set_grid(grid_x_amount, 10, 5, 5)
left_axis = range(0, 11, 1)
left_axis[0] = ""
self.chart.set_axis_labels(Axis.LEFT, left_axis)
bottom_len = len(data[i]) + 2
bottom_axis = range(2, bottom_len, 1)
self.chart.set_axis_labels(Axis.BOTTOM, bottom_axis)
self.chart.set_title(title)
示例5: taxonLineChart
def taxonLineChart(taxon, site, max_y=None, label_record=None):
min_y = 0
records = taxon.mean_densities.filter(site=site).order_by('year')
years = [ record.year for record in records ]
means = [ record.mean for record in records ]
# Set the vertical range from 0 to 100
max_y = max_y or max(means)
span = max_y - min_y
if span == 0:
max_y = 1
step = pow(10, round(math.log(max_y) / math.log(10)) - 1)
ticks = frange(min_y, max_y + (step * 1), step)
chart = SimpleLineChart(300, 100, y_range=[0, max_y])
# Add the chart data
chart.add_data(means)
# Set the line colour to blue
chart.set_colours(['76A4FB'])
# limit number of ticks to around 4
n = len(ticks) / 3
# 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.
ticks = ticks[::n]
ticks[0] = ''
chart.set_axis_labels(Axis.LEFT, ticks)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, years[::4])
url = chart.get_url()
url.replace('lc', 'ls')
url += '&chm=B,C3D9FF,0,0,0'
if label_record:
url += ('|@a,3366CC,0,%f:%f,4' % (float(years.index(label_record.year)) / float(len(years)), (label_record.mean+(max_y * 0.05))/max_y))
print url
return url
示例6: many_labels
def many_labels():
chart = SimpleLineChart(settings.width, settings.height)
for a in xrange(3):
for axis_type in (Axis.LEFT, Axis.RIGHT, Axis.BOTTOM):
index = chart.set_axis_range(axis_type, 0, random.random() * 100)
chart.set_axis_style(index, colour=helper.random_colour(), \
font_size=random.random() * 10 + 5)
chart.add_data(helper.random_data())
chart.download('label-many.png')
示例7: __init__
def __init__(self,data):
x_size=900
colours=['0000FF']
y_size=200
spacer=10
y_range=[min(data)-spacer, max(data)+spacer]
left_axis=range(y_range[0],y_range[1],5)
self.chart=SimpleLineChart(x_size,y_size,y_range=y_range)
self.chart.set_axis_labels(Axis.LEFT,left_axis)
self.chart.set_colours(colours)
self.chart.add_data(data)
示例8: gchart
def gchart(data, node, check, metric, start=datetime.now()-timedelta(days=1), end=datetime.now()):
d = []
ts = []
for p in data['metrics'][0]['data']:
d.append(float(p['avg']))
ts.append(p['ts'])
# Chart size of 200x125 pixels and specifying the range for the Y axis
max_y = int(max(d))
chart = SimpleLineChart(450, 250, y_range=[0,max_y])
chart.add_data(d)
left_axis = range(0, max_y + 1, max_y/5)
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
min_dt = datetime.fromtimestamp(min(ts))
max_dt = datetime.fromtimestamp(max(ts))
chart.set_axis_labels(Axis.BOTTOM, [ str(min_dt), str(max_dt) ])
title = '%s.%s.%s' % (node['name'], check['type'], metric)
chart.set_title(title)
return chart.get_url()
示例9: get_pace_chart_url
def get_pace_chart_url(self, width, height):
if len(self.positions()) == 0:
return ''
pace = []
int_dist = []
s = 0
last_p = None
for p in self.positions():
if last_p != None:
ds = distance.distance((p.latitude, p.longitude), \
(last_p.latitude, last_p.longitude)).kilometers
s = s + int(ds * 1000)
dt = (p.time - last_p.time).seconds
if ds > 0:
pace.append(dt / ds)
int_dist.append(s)
last_p = p
int_pace = [int(p) for p in ema(pace, 20)]
min_pace = int(min(int_pace) * 0.95)
max_pace = int(max(int_pace) / 0.95)
mid_pace = (max_pace + min_pace) / 2
min_pace_str = '%02d:%02d' % (min_pace / 60, min_pace % 60)
mid_pace_str = '%02d:%02d' % (mid_pace / 60, mid_pace % 60)
max_pace_str = '%02d:%02d' % (max_pace / 60, max_pace % 60)
chart = SimpleLineChart(width, height, y_range = (min_pace, max_pace))
chart.add_data(int_pace)
chart.set_axis_labels(Axis.LEFT, [min_pace_str, mid_pace_str, max_pace_str])
return chart.get_url()
示例10: simpleChart
def simpleChart(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 = [datamin,0,datamax]
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.set_axis_labels(Axis.BOTTOM, bottom_labels)
return chart
示例11: month_graph
def month_graph(data, start, end):
"""Helper for making graphy graph for a month's worth of data on something."""
from pygooglechart import SimpleLineChart, Axis
WIDTH, HEIGHT = 700, 200
y_range = (0, max(max(data), 1)) # todo: have extra room when I figure out how to do labels (set_axis_positions?)
x_range = (0, 30)
chart = SimpleLineChart(WIDTH, HEIGHT, y_range=y_range, x_range=x_range)
chart.add_data(data)
chart.set_axis_labels(Axis.LEFT, y_range)
#chart.left.labels = chart.left.label_positions = [0, max(data)]
chart.set_axis_labels(Axis.BOTTOM, [d.strftime('%D') for d in
date_range(start, end, datetime.timedelta(days=10))])
#chart.bottom.label_positions = [0, 10, 20, 30]
return chart.get_url()
示例12: getchart
def getchart(history):
data = []
created = []
for h in history:
data.append(float(h.average))
created.append(int(h.created.day))
max_y = int(math.ceil(max(data))) + 1
min_y = int(math.floor(min(data))) - 1
chart = SimpleLineChart(550, 225, y_range=[min_y, max_y])
chart.add_data(data)
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(min_y, max_y + 1, 2)
left_axis[0] = ""
chart.set_axis_labels(Axis.LEFT, left_axis)
chart.set_axis_labels(Axis.BOTTOM, created)
return chart
示例13: group_membership_activity
def group_membership_activity(request, group_slug):
group = get_object_or_404(BaseGroup, slug=group_slug)
listcount = []
listdate = []
currentcount = group.member_users.all().count()
thedate = date.today()
skip = False
while thedate.year != date.today().year - 1 or thedate.month != date.today().month:
if thedate.month == 1:
startdate = date(year=thedate.year - 1,
month=12, day=1)
else:
startdate = date(year=thedate.year,
month=thedate.month - 1,
day=1)
joins = GroupMemberRecord.objects.filter(group=group,
membership_start=True,
datetime__range=(startdate, thedate)).count()
unsubs = GroupMemberRecord.objects.filter(group=group,
membership_end=True,
datetime__range=(startdate, thedate)).count()
listcount.append(currentcount - joins + unsubs)
if not skip:
listdate.append(thedate.strftime("%B %y"))
else:
listdate.append("")
skip = not skip
thedate = startdate
listcount.reverse()
listdate.reverse()
activity = SimpleLineChart(600, 450, y_range=(min(listcount), max(listcount)))
activity.add_data(listcount)
yaxis = range(min(listcount), max(listcount) + 1, max(max(listcount)/10, 1)) # that last number should be 25 or 50. but for testing...
if len(yaxis) < 2: # only for testing...
yaxis.append(1)
yaxis[0] = ''
activity.set_axis_labels(Axis.LEFT, yaxis)
activity.set_axis_labels(Axis.BOTTOM, listdate)
return activity.get_url()
示例14: get_elevation_chart_url
def get_elevation_chart_url(self, width, height):
if len(self.positions) == 0:
return ''
int_elevations = [int(elevation) for elevation in ema([p.altitude for p in self.positions], 30)]
max_elev = int(max(int_elevations) / 0.95)
min_elev = int(min(int_elevations) * 0.95)
chart = SimpleLineChart(width, height, y_range = (min_elev, max_elev))
chart.add_data(int_elevations)
chart.set_axis_range(Axis.LEFT, min_elev, max_elev)
return chart.get_url()
示例15: get_pace_chart_url
def get_pace_chart_url(self, width, height):
def calc_pace_and_dist_from_previous(acc, p):
last_p = acc[0]
s = acc[1]
pace = acc[2]
int_dist = acc[3]
ds = distance.distance((p.latitude, p.longitude), \
(last_p.latitude, last_p.longitude)).kilometers
s = s + int(ds * 1000)
dt = (p.time - last_p.time).seconds
if ds > 0:
pace.append(dt / ds)
int_dist.append(s)
acc[0] = p
acc[1] = s
return acc
if len(self.positions) == 0:
return ''
pace = []
int_dist = []
s = 0
last_p = None
r = reduce(calc_pace_and_dist_from_previous,
self.positions[1:len(self.positions)],
[self.positions[0], 0, [], []])
pace = r[2]
int_dist = r[3]
int_pace = [int(p) for p in ema(pace, 30)]
min_pace = int(min(int_pace) * 0.95)
max_pace = int(max(int_pace) / 0.95)
mid_pace = (max_pace + min_pace) / 2
min_pace_str = '%02d:%02d' % (min_pace / 60, min_pace % 60)
mid_pace_str = '%02d:%02d' % (mid_pace / 60, mid_pace % 60)
max_pace_str = '%02d:%02d' % (max_pace / 60, max_pace % 60)
chart = SimpleLineChart(width, height, y_range = (min_pace, max_pace))
chart.add_data(int_pace)
chart.set_axis_labels(Axis.LEFT, [min_pace_str, mid_pace_str, max_pace_str])
return chart.get_url()