def test_xml_filters_round_trip(): plot = Bar() plot.add("A", [60, 75, 80, 78, 83, 90]) plot.add("B", [92, 87, 81, 73, 68, 55]) before = plot.render() plot.add_xml_filter(lambda T: T) after = plot.render() assert before == after
def static_pcap(): if request.method == 'POST': #temporarily store upload pcap file print request traceFile = request.files['file'] traceFile.save("temporary/temp_pcap_file.pcap") ft = filter_static.Static_Filter( fileName="temporary/temp_pcap_file.pcap") device_traffic_dict = ft.detect_Device() #line chart for individual device data sent historys pkt_line = XY(width=800, height=600, explicit_size=True) pkt_line.title = 'Device Package Curve' for key, list in device_traffic_dict.iteritems(): pkt_line.add(key, list) chart = pkt_line.render() # bar chart for device data sent summary pkt_Bar = Bar(width=800, height=600, explicit_size=True) pkt_Bar.title = 'Device Package Sum' for key, list in device_traffic_dict.iteritems(): zipped = map(sum, zip(*list)) pkt_Bar.add(key, zipped[1]) pkt_Bar = pkt_Bar.render() del ft html = """{} {}""".format(chart, pkt_Bar) return html else: return current_app.send_static_file('static.html')
def graph_records(record_files): chart = Bar(BaseConfig) max_len = max(map(len, record_files.values())) for name, record_list in sort_domains(record_files.items()): chart.add(name, [x[0].total_seconds()/86400 for x in record_list] + [None] * (max_len - len(record_list))) return chart.render()
def test_chart_renders(): line_chart = Bar(print_values=True, percent_values=True, print_values_position='top') line_chart.title = 'Browser usage evolution (in %)' line_chart.x_labels = map(str, range(2002, 2013)) line_chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1]) line_chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3]) line_chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1]) line_chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) assert line_chart.render()
def test_chart_renders(): """Tests that print values and percent values renders""" line_chart = Bar(print_values=True, percent_values=True, print_values_position='top') line_chart.title = 'Browser usage evolution (in %)' line_chart.x_labels = map(str, range(2002, 2013)) line_chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1]) line_chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3]) line_chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1]) line_chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) assert line_chart.render()
def bar_route(): projects = Project.select() bar_chart = Bar() bar_chart.title = 'Bar graphs (in %)' # instatiating two variables internal and external title = 0 amount = 0 for project in projects: if (project.type == 'title'): title += 1 else: amount += 1 bar_chart.add('title', title) bar_chart.add('amount', amount) bar_chart.render() chart = bar_chart.render_data_uri() return render_template('index.html', projects_to_send=projects, chart=chart)
xlab = [] items = [] begin = lb end = ub while count[begin] == 0: begin += 1 while count[end] == 0: end -= 1 for i in range(begin, end): xlab.append(i) dic = {"value": count[i], "label": f"Frequency: {count[i] / n:.2f}"} items.append(dic) # # Render barch = Bar() barch.title = f"Simulation for {n} rolls of the dice: {dice}" barch.x_labels = xlab barch.x_title = "Possible sums" barch.y_title = "Counts" barch.show_legend = False barch.force_uri_protocol = "http" barch.add('', items) barch.style = Style(colors=("#228B22",), label_font_size=12) barch.render() barch.render_to_file("dice_rolls.svg") # # Open browser window open_new_tab("file://" + path.realpath("dice_rolls.svg"))