cairoplot

python: open file, feed line to list, process list data

允我心安 提交于 2019-12-24 07:40:22
问题 I want to process the data in the file "output.log" and feed it to graphdata['eth0] I have done this but it process only the first line: logread = open("output.log", "r").readlines() for line in logread: print "line", line i = line.rstrip("\n") b = float(i) colors = [ (0.2, 03, .65), (0.5, 0.7, .1), (.35, .2, .45), ] graphData = {} graphData['eth0'] = [b] cairoplot.dot_line_plot("./blog", graphData, 500, 500, axis=True, grid=True, dots=True, series_colors=colors) 回答1: graphData = {} I believe

Django: How to render image with a template

余生颓废 提交于 2019-12-11 02:38:35
问题 Objective: I would like to display a generated .png image using a template. I worked with the example here. Here is the final snippet of code from that example: def gen_chart(request): ... pp = CairoPlot.PiePlot(surface, data, heigth, width, background = None, gradient = True, shadow = True, series_colors = colors ) pp.render() response = HttpResponse(mimetype="image/png") pp.surface.write_to_png(response) return response Accessing the gen_chart view shows a pretty pie chart. However, I'd