def __init__(self, data, file_name, title, author=None, format="ps"): #定义图标格式theme.get_options()中定义众多默认值,也可以指定phonto name和 format #"d:co:f:", ["format=", "output=", "color=","scale=", "font-family=", "font-size=","line-width=", "debug-level=", #"title=", "author=", "creation_date=", "creator=", "bbox="] args = ["--title=%s" % title, "--color=yes", "--font-size=10", "--output=%s.%s" %(file_name, format), "--debug-level=0"] theme.get_options(argv=args) #canvas函数,定义canvas名称和格式, 读取theme中定义的环境变量如title self.can = canvas.init(fname=file_name+"."+format, format=format) self.data = data
def __init__(self, data, file_name, title, author=None, format="ps"): #定义图标格式theme.get_options()中定义众多默认值,也可以指定phonto name和 format #"d:co:f:", ["format=", "output=", "color=","scale=", "font-family=", "font-size=","line-width=", "debug-level=", #"title=", "author=", "creation_date=", "creator=", "bbox="] args = [ "--title=%s" % title, "--color=yes", "--font-size=10", "--output=%s.%s" % (file_name, format), "--debug-level=0" ] theme.get_options(argv=args) #canvas函数,定义canvas名称和格式, 读取theme中定义的环境变量如title self.can = canvas.init(fname=file_name + "." + format, format=format) self.data = data
def create_graph(label_x, label_y, data_x, alldata_y, filename, title, start_date, end_date, start_y, end_y): """ main func """ # alter file name (linpng do not seems to like spaces in filenames filename = filename.replace(' ', '_') # Graph style theme.get_options() theme.use_color = True theme.default_font_size = 12 theme.default_font_family = "AvantGarde-Book" theme.reinitialize() colors = [ color.blue, color.red, color.green, color.magenta, color.cyan1, color.orange, ] can = canvas.init("%s" % filename) # Draw graph title newtitle = "/hL/20%s" % title left = WIDTH / 2 - font.text_width(newtitle) / 2 can.show(left, HEIGHT + DELTA, newtitle) int_to_date = lambda x: '/a60{}' + time.strftime("%H:%M", time.localtime(x) ) xaxis = axis.X(format=int_to_date, label="/20%s" % label_x, label_offset=(0, -DELTA), minor_tic_interval=X_MINOR_TICK_INTERVAL, tic_interval=X_TICK_INTERVAL) yaxis = axis.Y( label="/20%s" % label_y, label_offset=(-DELTA, 0), minor_tic_interval=(end_y - start_y) / 20, tic_interval=(end_y - start_y) / 5, ) ar = area.T(size=(WIDTH, HEIGHT), x_axis=xaxis, y_axis=yaxis, x_grid_style=line_style.gray70_dash3, x_range=(start_date, end_date), y_range=(start_y, end_y), x_grid_interval=X_GRID_INTERVAL, y_grid_interval=(end_y - start_y) / 5) i = 0 # Draw a line for each columns for title, data_y in alldata_y.iteritems(): plot = line_plot.T(label=title, data=zip(data_x, data_y), line_style=line_style.T(color=colors[i], width=1)) ar.add_plot(plot) i += 1 ar.draw() can.close() return True
def create_graph(label_x, label_y, data_x, alldata_y, filename, title, start_date, end_date): # alter file name (linpng do not seems to like spaces in filenames filename = filename.replace(' ', '_') # Graph style theme.get_options() theme.use_color = True theme.default_font_size = 12 theme.default_font_family = "AvantGarde-Book" theme.reinitialize() colors = [ color.blue, color.red, color.green, color.magenta, color.cyan1, color.orange, ] can = canvas.init("%s"%filename) # Draw graph title newtitle = "/hL/20%s"%title left = WIDTH / 2 - font.text_width(newtitle)/2 can.show(left, HEIGHT + DELTA, newtitle) zip(data_x) int_to_date = lambda x: '/a60{}' + time.strftime("%H:%M", time.localtime(x)) xaxis = axis.X( format = int_to_date, label = "/20%s" % label_x, label_offset = (0, -DELTA), minor_tic_interval = X_MINOR_TICK_INTERVAL, tic_interval = X_TICK_INTERVAL ) yaxis = axis.Y( label = "/20%s" % label_y, label_offset = (-DELTA, 0), minor_tic_interval = Y_MINOR_TICK_INTERVAL, tic_interval = Y_TICK_INTERVAL ) ar = area.T( size = (WIDTH, HEIGHT), x_axis = xaxis, y_axis = yaxis, x_grid_style = line_style.gray70_dash3, x_range = (start_date, end_date), y_range = (0, Y_MAX), x_grid_interval = X_GRID_INTERVAL, y_grid_interval = Y_GRID_INTERVAL ) i = 0 # Draw a line for each columns for title, data_y in alldata_y.iteritems(): plot = line_plot.T( label = title, data = zip(data_x,data_y), line_style = line_style.T( color = colors[i], width = 1 ) ) ar.add_plot(plot) i += 1 ar.draw() can.close() return True
import sys import time from pychart import theme from pychart import canvas from pychart import axis from pychart import area from pychart import line_plot from pychart import legend from pychart import text_box from BTrees.IFBTree import IFSet from repoze.catalog.indexes.field import fwscan_wins from repoze.catalog.indexes.field import nbest_ascending_wins theme.get_options() theme.use_color = True theme.scale_factor = 2 # db keys: # 64 # 512 # 1024 # 2048 # 4096 # 8192 # 16384 # 32768 # 65536 class FieldIndexForwardSort:
import sys import time from pychart import theme from pychart import canvas from pychart import axis from pychart import area from pychart import line_plot from pychart import legend from pychart import text_box from BTrees.IFBTree import IFSet from repoze.catalog.indexes.field import fwscan_wins from repoze.catalog.indexes.field import nbest_ascending_wins theme.get_options() theme.use_color = True theme.scale_factor = 2 # db keys: # 64 # 512 # 1024 # 2048 # 4096 # 8192 # 16384 # 32768 # 65536
def create_graph(label_x, label_y, data_x, alldata_y, filename, title, start_date, end_date, start_y, end_y): """ main func """ # alter file name (linpng do not seems to like spaces in filenames filename = filename.replace(" ", "_") # Graph style theme.get_options() theme.use_color = True theme.default_font_size = 12 theme.default_font_family = "AvantGarde-Book" theme.reinitialize() colors = [ color.blue, color.red, color.green, color.magenta, color.cyan1, color.orange, color.darkblue, color.darkred, color.darkgreen, color.darkmagenta, color.darkcyan, color.gold, color.lightblue1, color.orangered, color.lightgreen, color.pink, color.lightcyan, color.goldenrod, color.mistyrose, color.honeydew, color.gainsboro, color.yellow, color.peachpuff, color.turquoise, color.chartreuse1, color.pink, color.brown, color.blue, color.red, color.green, color.magenta, color.cyan1, color.orange, color.darkblue, color.darkred, color.darkgreen, color.darkmagenta, color.darkcyan, color.gold, color.lightblue1, color.orangered, color.lightgreen, color.pink, color.lightcyan, color.goldenrod, color.mistyrose, color.honeydew, color.gainsboro, color.yellow, color.peachpuff, color.turquoise, color.chartreuse1, color.pink, color.brown, ] can = canvas.init("%s" % filename) # Draw graph title newtitle = "/hL/20%s" % title left = WIDTH / 2 - font.text_width(newtitle) / 2 can.show(left, HEIGHT + DELTA, newtitle) int_to_date = lambda x: "/a60{}" + time.strftime("%H:%M", time.localtime(x)) xaxis = axis.X( format=int_to_date, label="/20%s" % label_x, label_offset=(0, -DELTA), minor_tic_interval=X_MINOR_TICK_INTERVAL, tic_interval=X_TICK_INTERVAL, ) yaxis = axis.Y( label="/20%s" % label_y, label_offset=(-DELTA, 0), minor_tic_interval=(end_y - start_y) / 20, tic_interval=(end_y - start_y) / 5, ) ar = area.T( size=(WIDTH, HEIGHT), x_axis=xaxis, y_axis=yaxis, x_grid_style=line_style.gray70_dash3, x_range=(start_date, end_date), y_range=(start_y, end_y), x_grid_interval=X_GRID_INTERVAL, y_grid_interval=(end_y - start_y) / 5, ) i = 0 # Draw a line for each columns for title, data_y in alldata_y.iteritems(): plot = line_plot.T(label=title, data=zip(data_x, data_y), line_style=line_style.T(color=colors[i], width=1)) ar.add_plot(plot) i += 1 ar.draw() can.close() return True