From 02dbbd651c64623eb4f6d808ede0b938ca8787ed Mon Sep 17 00:00:00 2001 From: Patrice Buriez Date: Fri, 30 Nov 2018 12:16:43 +0100 Subject: Use Chart.js for graphs in HTML reports This JavaScript library is available under MIT license. Also adjusted version for jQuery and jsTree, and added fallback font-family names. JIRA: YARDSTICK-1367 Topic: report/html_table (6 of 12) Change-Id: Ibe8b7e3d1f1365d2cbc019bfc22762aaa365a4e1 Signed-off-by: Patrice Buriez --- .../user/userguide/10-yardstick-user-interface.rst | 4 +- yardstick/benchmark/core/report.py | 11 +- yardstick/common/nsb_report.css | 2 +- yardstick/common/nsb_report.html.j2 | 153 ++++++++++++--------- yardstick/common/report.html.j2 | 133 +++++++++++++----- 5 files changed, 196 insertions(+), 107 deletions(-) diff --git a/docs/testing/user/userguide/10-yardstick-user-interface.rst b/docs/testing/user/userguide/10-yardstick-user-interface.rst index 76890b29a..5f9414974 100644 --- a/docs/testing/user/userguide/10-yardstick-user-interface.rst +++ b/docs/testing/user/userguide/10-yardstick-user-interface.rst @@ -27,8 +27,8 @@ Description The graph is framed with Timestamp on x-axis and output values (differ from testcase to testcase) on y-axis with the help of -`Highcharts`_. +`Chart.js`_. .. _InfluxDB: https://www.influxdata.com/time-series-platform/influxdb/ .. _Jinja2: http://jinja.pocoo.org/docs/2.10/ -.. _Highcharts: https://www.highcharts.com/products/highcharts/ +.. _Chart.js: https://www.chartjs.org/ diff --git a/yardstick/benchmark/core/report.py b/yardstick/benchmark/core/report.py index a484a49f3..530fbf165 100644 --- a/yardstick/benchmark/core/report.py +++ b/yardstick/benchmark/core/report.py @@ -135,7 +135,7 @@ class Report(object): self.db_task = self._get_tasks() field_keys = [] - temp_series = [] + datasets = [] table_vals = {} field_keys = [encodeutils.to_utf8(field['fieldKey']) @@ -143,7 +143,6 @@ class Report(object): for key in field_keys: self.Timestamp = [] - series = {} values = [] for task in self.db_task: task_time = encodeutils.to_utf8(task['time']) @@ -155,16 +154,14 @@ class Report(object): task_time = head + "." + tail[:6] self.Timestamp.append(task_time) if task[key] is None: - values.append('') + values.append(None) elif isinstance(task[key], (int, float)) is True: values.append(task[key]) else: values.append(ast.literal_eval(task[key])) + datasets.append({'label': key, 'data': values}) table_vals['Timestamp'] = self.Timestamp table_vals[key] = values - series['name'] = key - series['data'] = values - temp_series.append(series) template_dir = consts.YARDSTICK_ROOT_PATH + "yardstick/common" template_environment = jinja2.Environment( @@ -173,7 +170,7 @@ class Report(object): trim_blocks=False) context = { - "series": temp_series, + "datasets": datasets, "Timestamps": self.Timestamp, "task_id": self.task_id, "table": table_vals, diff --git a/yardstick/common/nsb_report.css b/yardstick/common/nsb_report.css index 0c47791e2..2beb91c53 100644 --- a/yardstick/common/nsb_report.css +++ b/yardstick/common/nsb_report.css @@ -19,7 +19,7 @@ table { } header { - font-family: Frutiger; + font-family: Frutiger, "Helvetica Neue", Helvetica, Arial, sans-serif; clear: left; text-align: center; } diff --git a/yardstick/common/nsb_report.html.j2 b/yardstick/common/nsb_report.html.j2 index f1b4ae1c2..0b4719b09 100644 --- a/yardstick/common/nsb_report.html.j2 +++ b/yardstick/common/nsb_report.html.j2 @@ -15,12 +15,12 @@ - + - + - - + + @@ -31,12 +31,12 @@

Report of {{task_id}} Generated

-
+
-
+
@@ -47,7 +47,8 @@
diff --git a/yardstick/common/report.html.j2 b/yardstick/common/report.html.j2 index ab76510ca..1dc7b1db1 100644 --- a/yardstick/common/report.html.j2 +++ b/yardstick/common/report.html.j2 @@ -15,9 +15,9 @@ - + - +