class TestLineChartWriter(object): def setup(self): """Setup a worksheet with one column of data and a line chart""" wb = Workbook() ws = wb.get_active_sheet() ws.title = 'Line' for i in range(1, 5): ws.append([i]) self.piechart = LineChart() self.piechart.add_serie(Serie(Reference(ws, (0, 0), (4, 0)))) self.cw = LineChartWriter(self.piechart) self.root = Element('test') def test_write_chart(self): """check if some characteristic tags of LineChart are there""" self.cw._write_chart(self.root) tagnames = ['{%s}lineChart' % CHART_NS, '{%s}valAx' % CHART_NS, '{%s}catAx' % CHART_NS] root = safe_iterator(self.root) chart_tags = [e.tag for e in root] for tag in tagnames: assert_true(tag in chart_tags, tag) def test_serialised(self): """Check the serialised file against sample""" xml = self.cw.write() expected_file = os.path.join(DATADIR, "writer", "expected", "LineChart.xml") with open(expected_file) as expected: diff = compare_xml(xml, expected.read()) assert diff is None, diff
def line(wb): ws = wb.create_sheet(5, "Line") for i in range(1, 5): ws.append([i]) chart = LineChart() values = Reference(ws, (0, 0), (4,0)) series = Serie(values) chart.add_serie(series) ws.add_chart(chart)
for c,n in zip(ws2.range("B2:M2")[0], packetSizes): c.value = n c.style.font.bold = True ws3.cell('A3').style.font.bold = True for c, n in zip(ws3.range("B4:M4")[0], packetsDropped): c.value = n wb.save("emmaResults.xlsx") # Throughput and mem. efficiency charts throughputChart = LineChart() throughputChart.show_legend = False if(bwLatency == 1): throughputChart.x_axis.title = "No. of Flows" elif(bwLatency == 1): throughputChart.x_axis.title = "Input Throughput (in Gbps)" elif(bwLatency == 0): throughputChart.x_axis.title = "Packet Size (in Bytes)" throughputChart.y_axis.title = "Mem. Throughput (in Gbps)" throughputChart.add_serie(Serie(Reference(ws1, (2, 2), (2, 2 + counter)), labels=(Reference(ws1, (1, 1), (1, counter))))) ws1.add_chart(throughputChart) memEfficienyChart = LineChart() memEfficienyChart.y_axis.min = 0 memEfficienyChart.y_axis.max = 100 memEfficienyChart.add_serie(Serie(Reference(ws1, (3, 2), (3, 2 + counter)), labels=(Reference(ws1, (1, 1), (1, counter))))) memEfficienyChart.show_legend = False memEfficienyChart.y_axis.title = "Mem. Efficiency (in % of clock cycles used)" if(bwLatency == 2): memEfficienyChart.x_axis_title = "No. of Flows" elif(bwLatency == 1): memEfficienyChart.x_axis.title = "Input Throughput (in Gbps)" elif(bwLatency == 0): memEfficienyChart.x_axis.title = "Packet Size (in Bytes)" memEfficienyChart.x_axis.title = "Input Throughput (in Gbps)" ws1.add_chart(memEfficienyChart) #Latency Charts latencyChart = LineChart() # chart for the average Latency per access for all mem. accesses latencyChart.add_serie(Serie(Reference(ws2, (2, 2), (2, 2 + counter)), labels=(Reference(ws2, (1, 1), (1, counter)))))