本文整理汇总了Python中pygooglechart.SimpleLineChart.set_colours方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleLineChart.set_colours方法的具体用法?Python SimpleLineChart.set_colours怎么用?Python SimpleLineChart.set_colours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygooglechart.SimpleLineChart
的用法示例。
在下文中一共展示了SimpleLineChart.set_colours方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graph_entries
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def graph_entries(num_days=14):
# its a beautiful day
today = datetime.today().date()
# step for x axis
step = timedelta(days=1)
# empties to fill up with data
counts = []
dates = []
# only get last two weeks of entries
day_range = timedelta(days=num_days)
entries = Entry.objects.filter(
time__gt=(today - day_range))
# count entries per day
for day in range(num_days):
count = 0
d = today - (step * day)
for e in entries:
if e.time.day == d.day:
count += 1
dates.append(d.day)
counts.append(count)
line = SimpleLineChart(440, 100, y_range=(0, 100))
line.add_data(counts)
line.set_axis_labels(Axis.BOTTOM, dates)
line.set_axis_labels(Axis.BOTTOM, ['','Date', ''])
line.set_axis_labels(Axis.LEFT, ['', 50, 100])
line.set_colours(['0091C7'])
line.download('webui/graphs/entries.png')
return 'saved entries.png'
示例2: simpleChart3
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [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
示例3: get
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [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: get
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def get(self):
counters = tasks.Counter.all().fetch(10)
rows = [{'name':c.key().name(), 'count':c.count} for c in counters]
chart = SimpleLineChart(1000, 300)
for counter in counters:
query = counter.snapshots
query.order('-date')
snapshots = query.fetch(30)
counts = [s.count for s in snapshots]
dates = [s.date.strftime("%d/%m") for s in snapshots]
for i in xrange(len(counts) - 1):
counts[i] -= counts[i+1]
counts.reverse()
dates.reverse()
chart.add_data(counts[1:])
chart.set_axis_labels(pygooglechart.Axis.BOTTOM, dates[1:])
chart.set_axis_labels(pygooglechart.Axis.LEFT, range(0, chart.data_y_range()[1], 5))
hsv_colours = [(float(x) / 255, 1, 1) for x in range(0, 255, 255 / len(counters))]
rgb_colours = [colorsys.hsv_to_rgb(*x) for x in hsv_colours]
hex_colours = ['%02x%02x%02x' % (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)) for x in rgb_colours]
chart.set_colours(hex_colours)
chart.set_legend([c.key().name() for c in counters])
path = os.path.join(os.path.dirname(__file__), self.TEMPLATE)
self.response.out.write(template.render(path,
{ 'url': chart.get_url(),
'counters': rows }))
示例5: show
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def show(request, isa_id):
isa = get_object_or_404(ISA, pk=isa_id)
isafunds = isa.isafund_set.all()
start_date = isa.created
end_date = date.today()
current_date = start_date
data = []
while current_date <= end_date:
value = 0
for isafund in isafunds:
try:
fundprice = isafund.fund.fundprice_set.get(date=current_date)
value += fundprice.price * isafund.quantity
except FundPrice.DoesNotExist:
pass
data.append(value)
current_date += timedelta(1)
chart = SimpleLineChart(500, 200, y_range=[min(data), max(data)])
chart.add_data(data)
chart.add_data([data[0], data[0]])
chart.set_colours(['0000FF', 'AAAAAA'])
chart.fill_solid('bg', 'DDDDFF')
chart.set_axis_labels(Axis.LEFT, [int(min(data)), int(max(data))])
chart.set_axis_labels(Axis.BOTTOM, [start_date, end_date])
url = chart.get_url()
return render_to_response('isas/show.html', {'isa': isa, 'chart_url': url})
示例6: _partyline
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def _partyline(self, party_results):
if self.request.GET.get('percentages') == 'true':
key = 'percentage'
else:
key = 'count'
maxcount = 0
allcounts = []
granularity = self.request.GET.get('granularity')
months = []
for party, results in party_results.iteritems():
counts = [x.get(key) for x in results['results']]
allcounts.append(counts)
if max(counts) > maxcount:
maxcount = max(counts)
if granularity == 'month':
months = [x['month'] for x in results['results']]
januaries = [x for x in months if x.endswith('01')]
january_indexes = [months.index(x) for x in januaries]
january_percentages = [int((x / float(len(months))) * 100) for x in january_indexes]
#times = [x.get(granularity) for x in results['results']]
width = int(self.request.GET.get('width', 575))
height = int(self.request.GET.get('height', 318))
chart = SimpleLineChart(width, height, y_range=(0, max(counts)))
chart.fill_solid('bg', '00000000') # Make the background transparent
chart.set_grid(0, 50, 2, 5) # Set gridlines
if granularity == 'month':
index = chart.set_axis_labels(Axis.BOTTOM, [x[:4] for x in januaries[::2]])
chart.set_axis_positions(index, [x for x in january_percentages[::2]])
if key == 'percentage':
label = '%.4f' % maxcount
else:
label = int(maxcount)
index = chart.set_axis_labels(Axis.LEFT, [label, ])
chart.set_axis_positions(index, [100, ])
for n, counts in enumerate(allcounts):
chart.add_data(counts)
chart.set_line_style(n, thickness=2) # Set line thickness
colors = {'R': 'bb3110', 'D': '295e72', }
chart_colors = []
chart_legend = []
for k in party_results.keys():
chart_colors.append(colors.get(k, '000000'))
chart_legend.append(k)
chart.legend_position = 'b'
chart.set_colours(chart_colors)
if self.request.GET.get('legend', 'true') != 'false':
chart.set_legend(chart_legend)
return chart.get_url()
示例7: group
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def group(request, group_id):
group = get_object_or_404(GroupedMessage, pk=group_id)
message_list = group.message_set.all()
obj = message_list.order_by('-id')[0]
if '__sentry__' in obj.data:
module, args, frames = obj.data['__sentry__']['exc']
obj.class_name = str(obj.class_name)
# We fake the exception class due to many issues with imports/builtins/etc
exc_type = type(obj.class_name, (Exception,), {})
exc_value = exc_type(obj.message)
exc_value.args = args
reporter = ImprovedExceptionReporter(obj.request, exc_type, exc_value, frames, obj.data['__sentry__'].get('template'))
traceback = mark_safe(reporter.get_traceback_html())
elif group.traceback:
traceback = mark_safe('<pre>%s</pre>' % (group.traceback,))
unique_urls = message_list.filter(url__isnull=False).values_list('url', 'logger', 'view', 'checksum').annotate(times_seen=Count('url')).values('url', 'times_seen').order_by('-times_seen')
unique_servers = message_list.filter(server_name__isnull=False).values_list('server_name', 'logger', 'view', 'checksum').annotate(times_seen=Count('server_name')).values('server_name', 'times_seen').order_by('-times_seen')
def iter_data(obj):
for k, v in obj.data.iteritems():
if k.startswith('_') or k in ['url']:
continue
yield k, v
json_data = iter_data(obj)
# TODO: this should be a template tag
engine = get_db_engine()
if SimpleLineChart and not engine.startswith('sqlite'):
today = datetime.datetime.now()
chart_qs = message_list\
.filter(datetime__gte=today - datetime.timedelta(hours=24))\
.extra(select={'hour': 'extract(hour from datetime)'}).values('hour')\
.annotate(num=Count('id')).values_list('hour', 'num')
rows = dict(chart_qs)
if rows:
max_y = max(rows.values())
else:
max_y = 1
chart = SimpleLineChart(300, 80, y_range=[0, max_y])
chart.add_data([max_y]*30)
chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
chart.add_data([0]*30)
chart.fill_solid(chart.BACKGROUND, 'eeeeee')
chart.add_fill_range('eeeeee', 0, 1)
chart.add_fill_range('e0ebff', 1, 2)
chart.set_colours(['eeeeee', '999999', 'eeeeee'])
chart.set_line_style(1, 1)
chart_url = chart.get_url()
return render_to_response('sentry/group/details.html', locals())
示例8: velocity_chart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def velocity_chart(self):
graph_width = 600
graph_height = 300
x_max = self.total_iterations
y_max = max(max(self.estimate_stories_data()),
max(self.estimate_tasks_data()),
max(self.work_data()))
chart = SimpleLineChart(graph_width, graph_height,
x_range=(1, x_max + 1), y_range=(0, y_max + 1))
chart.add_data(self.estimate_stories_data())
chart.add_data(self.estimate_tasks_data())
chart.add_data(self.work_data())
chart.set_grid(0, 100.0 / y_max + 1, 5, 5)
chart.set_colours(['FF0000', '00FF00', '0000FF'])
chart.set_legend([_('rough story estimates'),
_('task estimates'), _('worked')])
chart.set_legend_position('b')
chart.set_axis_labels(Axis.LEFT, ['', '', _('days')])
chart.set_axis_labels(Axis.BOTTOM, range(1, x_max + 1))
chart.set_axis_range(Axis.LEFT, 0, y_max + 1)
return chart.get_url(data_class=ExtendedData)
示例9: enterprises_graph
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def enterprises_graph(num_days=14):
chart_name="enterprises.png"
# its a beautiful day
today = datetime.today().date()
# step for x axis
step = timedelta(days=1)
# empties to fill up with data
counts = []
dates = []
# only get last two weeks of entries
day_range = timedelta(days=num_days)
entries = Enterprise.objects.filter(
created_at__gt=(today - day_range))
# count entries per day
for day in range(num_days):
count = 0
d = today - (step * day)
for e in entries:
if e.created_at.day == d.day:
count += 1
dates.append(d.day)
counts.append(count)
line = SimpleLineChart(440, 100, y_range=(0, 100))
line.add_data(counts)
line.set_axis_labels(Axis.BOTTOM, dates)
line.set_axis_labels(Axis.BOTTOM, ['','Date', ''])
line.set_axis_labels(Axis.LEFT, ['', 5, 10])
line.set_colours(['0091C7'])
line.download('apps/shabaa/static/graphs/' + chart_name)
return chart_name
示例10: makeChartOfDay
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
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()
示例11: __init__
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
class DiceChart:
chart = None
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)
def download(self, name="dicechart.png"):
self.chart.download(name)
示例12: getLineGraph
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def getLineGraph(data,line1color,line2color):
# Set the vertical range based on data values
tweets = [d[0] for d in data]
retweets = [d[1] for d in data]
ratio = [str(int(d[1]/d[0]*100))+'%' for d in data]
hours = [d[2] for d in data]
mx = max(tweets)
mn = min(retweets)
buffer = (mx - mn)/100 # average retweets have consitently been less
min_y = mn - buffer
max_y = mx + buffer
# Chart size of 750x400 pixels and specifying the range for the Y axis
chart = SimpleLineChart(750, 400, y_range=[min_y, max_y])
chart.set_legend(['Tweets','Retweets'])
chart.set_legend_position('t')
# Add the chart data
chart.add_data(tweets)
chart.add_data(retweets)
# Set the line colour to blue
chart.set_colours([line1color,line2color])
# Set the horizontal dotted lines
chart.set_grid(0, 25, 5, 5)
#set left axis to values range
left_axis = range(min_y, max_y, (max_y-min_y)/10)
chart.set_axis_labels(Axis.BOTTOM, hours)
chart.set_axis_labels(Axis.BOTTOM, ratio)
chart.set_axis_labels(Axis.LEFT, left_axis)
return chart.get_url()
示例13: RenderGoogleChart
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [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)
示例14: get_chart_image
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def get_chart_image(self, data, **kw):
"""Return a image file path
Arguments::
data -- a list containing the X,Y data representation
"""
from pygooglechart import SimpleLineChart, Axis
# Set the vertical range from 0 to 100
try:
max_y = max(data['y'])
min_y = min(data['y'])
except:
min_y = 0
max_y = 100
width = int(kw.get('width', 600))
height = int(kw.get('height', 250))
# Chart size of widthxheight pixels and specifying the range for the Y axis
chart = SimpleLineChart(width, height, y_range=[0, max_y])
# Add the chart data
chart.add_data(data['y'])
# Set the line colour to blue
chart.set_colours(['0000FF'])
try:
step_x = int(100/(len(data['x'])-1))
except:
step_x = 0
chart.set_grid(step_x, 10, 5, 5)
# The Y axis labels contains min_y to max_y spling it into 10 equal parts,
#but remove the first number because it's obvious and gets in the way
#of the first X label.
left_axis = [utils.intcomma(x) for x in range(0, max_y + 1, (max_y)/10)]
left_axis[0] = ''
chart.set_axis_labels(Axis.LEFT, left_axis)
# X axis labels
chart.set_axis_labels(Axis.BOTTOM, data['x'])
#Generate an hash from arguments
kw_hash = hash(tuple(sorted(kw.items())))
data_hash = hash(tuple(sorted([(k, tuple(v))
for k, v in data.iteritems()])))
args_hash = str(kw_hash) + str(data_hash)
image_path = os.path.join(TARGET_DIR, "%s.png" % args_hash)
if bool(kw.get('refresh', False)) or args_hash not in self.charts:
#Get image from google chart api
chart.download(image_path)
if args_hash not in self.charts:
self.charts.append(args_hash)
self._p_changed = True
return image_path
示例15: simple_line
# 需要导入模块: from pygooglechart import SimpleLineChart [as 别名]
# 或者: from pygooglechart.SimpleLineChart import set_colours [as 别名]
def simple_line():
chart = SimpleLineChart(settings.width, settings.height,
x_range=(0, 35))
chart.set_colours(['00ff00', 'ff0000','ACff0C','B0ffE0','C0ffFF'])
chart.add_data([1,2,3,4,5])
chart.add_data([1,4,9,16,25])
chart.set_title('This is title')
chart.set_axis_labels('r', 'str')
chart.set_legend( ['a','b','c','d','e'])
chart.download('simple-line.png')