mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 20:27:54 +00:00
Added method for objective and change the image name banner.png
added bar chart for multiple category
This commit is contained in:
@@ -5,6 +5,7 @@ import matplotlib as mpl
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pdfkit
|
import pdfkit
|
||||||
|
import math
|
||||||
|
|
||||||
# internal candela references included during intial phases, to be deleted at future date
|
# internal candela references included during intial phases, to be deleted at future date
|
||||||
# https://candelatech.atlassian.net/wiki/spaces/LANFORGE/pages/372703360/Scripting+Data+Collection+March+2021
|
# https://candelatech.atlassian.net/wiki/spaces/LANFORGE/pages/372703360/Scripting+Data+Collection+March+2021
|
||||||
@@ -15,6 +16,7 @@ class report_library():
|
|||||||
_title="LANForge Test Run Heading",
|
_title="LANForge Test Run Heading",
|
||||||
_table_title="LANForge Table Heading",
|
_table_title="LANForge Table Heading",
|
||||||
_obj = "",
|
_obj = "",
|
||||||
|
_obj_title = "",
|
||||||
_date="1/1/2-21 00:00(UTC)",
|
_date="1/1/2-21 00:00(UTC)",
|
||||||
_output_html="outfile.html",
|
_output_html="outfile.html",
|
||||||
_output_pdf="outfile.pdf"):
|
_output_pdf="outfile.pdf"):
|
||||||
@@ -30,6 +32,7 @@ class report_library():
|
|||||||
self.html = ""
|
self.html = ""
|
||||||
self.custom_html = ""
|
self.custom_html = ""
|
||||||
self.objective = _obj
|
self.objective = _obj
|
||||||
|
self.obj_title = _obj_title
|
||||||
|
|
||||||
|
|
||||||
def set_title(self,_title):
|
def set_title(self,_title):
|
||||||
@@ -47,8 +50,9 @@ class report_library():
|
|||||||
def set_custom_html(self,_custom_html):
|
def set_custom_html(self,_custom_html):
|
||||||
self.custom_html = _custom_html
|
self.custom_html = _custom_html
|
||||||
|
|
||||||
def set_obj_html(self,_obj):
|
def set_obj_html(self,_obj_title, _obj ):
|
||||||
self.objective = _obj
|
self.objective = _obj
|
||||||
|
self.obj_title = _obj_title
|
||||||
|
|
||||||
def write_html(self):
|
def write_html(self):
|
||||||
# dataframe_html = self.dataframe.to_html(index=False) # have the index be able to be passed in.
|
# dataframe_html = self.dataframe.to_html(index=False) # have the index be able to be passed in.
|
||||||
@@ -86,7 +90,7 @@ class report_library():
|
|||||||
|
|
||||||
<title>BANNER </title></head>
|
<title>BANNER </title></head>
|
||||||
<body>
|
<body>
|
||||||
<div class='Section report_banner-1000x205' style='background-image:url(banner.png");background-repeat:no-repeat;padding:0;margin:0;min-width:1000px; min-height:205px;width:1000px; height:205px;max-width:1000px; max-height:205px;'>
|
<div class='Section report_banner-1000x205' style='background-image:url("banner.png");background-repeat:no-repeat;padding:0;margin:0;min-width:1000px; min-height:205px;width:1000px; height:205px;max-width:1000px; max-height:205px;'>
|
||||||
<br>
|
<br>
|
||||||
<img align='right' style='padding:25;margin:5;width:200px;' src="CandelaLogo2-90dpi-200x90-trans.png" border='0' />
|
<img align='right' style='padding:25;margin:5;width:200px;' src="CandelaLogo2-90dpi-200x90-trans.png" border='0' />
|
||||||
|
|
||||||
@@ -108,9 +112,8 @@ class report_library():
|
|||||||
<meta charset='UTF-8'>
|
<meta charset='UTF-8'>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
||||||
<div class='HeaderStyle'>
|
<div class='HeaderStyle'>
|
||||||
<br>
|
|
||||||
<h2 class='TitleFontPrint' style='color:darkgreen;'>""" + str(self.table_title) + """</h2>
|
<h2 class='TitleFontPrint' style='color:darkgreen;'>""" + str(self.table_title) + """</h2>
|
||||||
<br>"""
|
"""
|
||||||
self.html += self.table_title_html
|
self.html += self.table_title_html
|
||||||
|
|
||||||
# right now from data frame
|
# right now from data frame
|
||||||
@@ -124,12 +127,52 @@ class report_library():
|
|||||||
def build_objective(self):
|
def build_objective(self):
|
||||||
self.obj_html = """
|
self.obj_html = """
|
||||||
<!-- Test Objective -->
|
<!-- Test Objective -->
|
||||||
<h3 align='left'>Objective</h3>
|
<h3 align='left'>""" + str(self.obj_title) + """</h3>
|
||||||
<p align='left' width='900'>""" + str(self.objective) + """</p>
|
<p align='left' width='900'>""" + str(self.objective) + """</p>
|
||||||
<br>
|
|
||||||
"""
|
"""
|
||||||
self.html += self.obj_html
|
self.html += self.obj_html
|
||||||
|
|
||||||
|
def build_bar_graph(self, data_set, xaxis_name, yaxis_name, xaxis_categories, graph_image_name, label,color=None):
|
||||||
|
barWidth = 0.25
|
||||||
|
color_name = ['lightcoral','darkgrey','r','g','b','y']
|
||||||
|
if color is None:
|
||||||
|
i = 0
|
||||||
|
color = []
|
||||||
|
for col in data_set:
|
||||||
|
color.append(color_name[i])
|
||||||
|
i = i+1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fig = plt.subplots(figsize=(12, 8))
|
||||||
|
i = 0
|
||||||
|
for set in data_set:
|
||||||
|
if i > 0:
|
||||||
|
br = br1
|
||||||
|
br2 = [x + barWidth for x in br]
|
||||||
|
plt.bar(br2, data_set[i], color=color[i], width=barWidth,
|
||||||
|
edgecolor='grey', label=label[i])
|
||||||
|
br1 = br2
|
||||||
|
i = i+1
|
||||||
|
else:
|
||||||
|
br1 = np.arange(len(data_set[i]))
|
||||||
|
plt.bar(br1, data_set[i], color=color[i], width=barWidth,
|
||||||
|
edgecolor='grey', label=label[i])
|
||||||
|
i=i+1
|
||||||
|
plt.xlabel(xaxis_name, fontweight='bold', fontsize=15)
|
||||||
|
plt.ylabel(yaxis_name, fontweight='bold', fontsize=15)
|
||||||
|
plt.xticks([r + barWidth for r in range(len(data_set[0]))],
|
||||||
|
xaxis_categories)
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
fig = plt.gcf()
|
||||||
|
plt.savefig("%s.png"% (graph_image_name), dpi=96)
|
||||||
|
self.graph_html_obj = """
|
||||||
|
<img align='center' style='padding:15;margin:5;width:1000px;' src=""" + "%s.png" % (graph_image_name) + """ border='1' />
|
||||||
|
<br><br>
|
||||||
|
"""
|
||||||
|
self.html +=self.graph_html_obj
|
||||||
|
|
||||||
|
|
||||||
# Unit Test
|
# Unit Test
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -170,6 +213,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
report.set_dataframe(dataframe2)
|
report.set_dataframe(dataframe2)
|
||||||
report.build_table()
|
report.build_table()
|
||||||
|
dataset = [[30,55,69,37],[45,67,34,22],[22,45,12,34]]
|
||||||
|
x_axis_values = [1,2,3,4]
|
||||||
|
report.build_bar_graph(dataset, "stations", "Throughput (Mbps)", x_axis_values,
|
||||||
|
"Bi-single_radio_2.4GHz",
|
||||||
|
["bi-downlink", "bi-uplink",'uplink'], None)
|
||||||
|
|
||||||
|
|
||||||
#report.build_all()
|
#report.build_all()
|
||||||
|
|||||||
Reference in New Issue
Block a user