def sample_Line(cls): g = line.Line() options = dict( scale_integers=False, scale_divisions=0.1, area_fill=True, width=640, height=480, fields=SampleBar.fields, x_title='Value of a', y_title='Average degree of precision', graph_title='', show_graph_title=True, show_x_title=True, show_y_title=True, no_css=False, ) g.__dict__.update(options) g.add_data({ 'data': [ 0.621, 0.614, 0.617, 0.618, 0.618, 0.619, 0.619, 0.619, 0.620, 0.618, 0.619 ], 'title': '100 Nodes' }) g.add_data({ 'data': [ 0.602, 0.602, 0.603, 0.603, 0.603, 0.601, 0.603, 0.601, 0.603, 0.604, 0.603 ], 'title': '1000 Nodes' }) g.add_data({ 'data': [ 0.583, 0.583, 0.581, 0.581, 0.581, 0.582, 0.582, 0.581, 0.582, 0.582, 0.582 ], 'title': '10000 Nodes' }) g.add_data({ 'data': [ 0.566, 0.567, 0.566, 0.567, 0.566, 0.566, 0.566, 0.566, 0.567, 0.566, 0.566 ], 'title': '100000 Nodes' }) g.add_data({'data': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'title': ''}) return g
def sample_Line(): g = line.Line() options = dict( scale_integers=True, area_fill=True, width=640, height=480, fields=SampleBar.fields, graph_title='Question 7', show_graph_title=True, no_css=False, ) g.__dict__.update(options) g.add_data({'data': [-2, 3, 1, 3, 1], 'title': 'Female'}) g.add_data({'data': [0, 2, 1, 5, 4], 'title': 'Male'}) return g
def my_sample_Line(): g = line.Line() options = dict( scale_integers=True, area_fill=True, width=1280, height=960, fields=['0', '1', '2', '3', '4'], graph_title='Docker', show_graph_title=True, no_css=False, ) g.__dict__.update(options) g.add_data({'data': [-2, 3, 1, 3, 1], 'title': 'Female'}) # g.add_data({'data': [0, 2, 1, 5, 4], 'title': 'Male'}) return g
def line_builder(): ln = line.Line() options = dict( scale_integers=True, area_fill=True, width=1280, height=480, fields=[graph_collection['_docker_ps'].return_t()], graph_title='Docker Line', show_graph_title=True, no_css=False, right_align=False, show_x_labels=False, ) ln.__dict__.update(options) ln.add_data(graph_collection['_docker_ps'].return_data_line()) return ln
def sample_line(): form = cgi.FieldStorage() sensor_name = form.getvalue("sensor") width = form.getvalue("width") if width is None: width = 500. # Measured widths: phones=980, Mc=1440 else: width = float(width) height = width * 2. / 5. scale_hours = int(2700. / width) if width < 350: tiny_graph = True else: tiny_graph = False maxepoch = form.getvalue("maxepoch") if maxepoch is None: maxepoch = 2000000000 maxepoch = int(maxepoch) minepoch = maxepoch - SECONDS_IN_ONE_DAY conn = db_module.get_conn() curs = conn.cursor() curs.execute(" SELECT epochtimestamp, measure" " FROM raw_measures" " WHERE epochtimestamp<" + str(maxepoch) + " AND epochtimestamp>" + str(minepoch) + " AND sensor='" + sensor_name + "' ORDER BY epochtimestamp ASC;") date_and_value = curs.fetchall() epochdates = list() values = list() for i in list(range(len(date_and_value))): epoch = date_and_value[i][0] epoch_minutes = round(epoch / 60.) if (epoch_minutes % (60 * scale_hours)) == 0: epoch_hours = epoch_minutes / 60 hour_in_day = int(epoch_hours % 24) epochdates.append(str(hour_in_day) + ":00") else: epochdates.append('') # epochdates.append(date_and_value[i][0]) values.append(date_and_value[i][1]) g = line.Line() options = dict( scale_integers=True, area_fill=True, width=int( width ), # calculations done with width and height, must be integer in pixel ('em' not accepted...) height=int(height), fields=epochdates, # fields=['18:00', '', '0:00', '', '6:00', '', '12:00', '', '18:00'], graph_title=sensor_name, # right_align=False, # no effect?! right_font=False, scale_divisions=2, show_graph_title=False, show_y_labels=not tiny_graph, show_x_labels=not tiny_graph, # Hours below # show_x_title=not(tiny_graph), # Default False, "X Field names" below # show_y_title=not(tiny_graph), # Default False, "Y Scale" on left show_graph_subtitle=False, show_x_guidelines=False, # vertical dot lines: One per *value* show_y_guidelines=not tiny_graph, # horizontal dot lines stagger_y_labels= False, # Default False (shift values for readability if too many) step_include_first_y_label=False, show_legend=False, top_font=False, no_css=False, ) g.__dict__.update(options) # g.add_data({'data': [-2, 3, 1, 3, 1], 'title': 'Female'}) # , 'title': 'Female' # g.add_data({'data': [11, 10, 9, 9, 9, 9, 10, 11, 14], 'title': 'Temperature'}) # , 'title': 'Female' g.add_data({'data': values, 'title': ''}) # g.add_data({'data': [11.6, 10.4, 9.6, 9.0, 9.3, 9.7, 10.3, 11.7, 14.0], 'title': ''}) # g.add_data({'data': [0, 2, 1, 5, 4], 'title': 'Male'}) return g
# read csv df = pd.read_csv(csv_fname) # convert it to a list df = df.transpose() print 'KEY: %s' % df.keys() ll = df[0].values.tolist() print ll # prepare writing coordinates data_name = ll[0] ll = ll[1:-4] item_cnt = len(ll) fields = ['%d' % (x + 1) for x in xrange(item_cnt)] lc = line.Line( dict( height=800, width=800, fields=fields, step_x_labels=2, #min_scale_value = 20 )) lc.add_data({'data': ll, 'title': data_name}) out_fname = 'out2.svg' f = open(out_fname, 'w') f.write(lc.burn()) f.close() print('#### check output file: %s' % out_fname)