[Reports] Add new OutputTextArea chart plugin

New chart plugin can show arbitrary textual data on
"Scenario Stata -> Per iteration" tab.

This finally allows to show non-numeric data like IP addresses,
notes and even long comments.

Plugin Dummy.output is also updated to provide demonstration.

Change-Id: Id8d245788f230842bfdb596706a07a8789ace0db
This commit is contained in:
Alexander Maretskiy 2016-09-07 14:38:10 +03:00
parent b6bedc5b78
commit 2cb9aeba4d
5 changed files with 30 additions and 0 deletions

View File

@ -166,6 +166,13 @@ class DummyOutput(scenario.Scenario):
"label": "Yet another measurement units", "label": "Yet another measurement units",
"axis_label": ("This is a custom " "axis_label": ("This is a custom "
"X-axis label")}) "X-axis label")})
self.add_output(
complete={"title": "Arbitrary Text",
"chart_plugin": "TextArea",
"data": ["Lorem ipsum dolor sit amet, consectetur "
"adipiscing elit, sed do eiusmod tempor "
"incididunt ut labore et dolore magna "
"aliqua." * 2] * 4})
self.add_output( self.add_output(
complete={"title": "Complete Pie (no description)", complete={"title": "Complete Pie (no description)",
"chart_plugin": "Pie", "chart_plugin": "Pie",

View File

@ -573,6 +573,13 @@ class OutputStatsTable(OutputTable):
self._data[name][idx][0].add(value) self._data[name][idx][0].add(value)
@plugin.configure(name="TextArea")
class OutputTextArea(OutputChart):
"""Arbitrary text."""
widget = "TextArea"
_OUTPUT_SCHEMA = { _OUTPUT_SCHEMA = {
"key_types": { "key_types": {
"title": six.string_types, "title": six.string_types,

View File

@ -138,6 +138,9 @@ var widgetDirective = function($compile) {
"<tr>" + "<tr>" +
"</tbody></table>"; "</tbody></table>";
var el = element.empty().append($compile(template)(scope)).children()[0] var el = element.empty().append($compile(template)(scope)).children()[0]
} else if (attrs.widget === "TextArea") {
var template = "<div style='padding:0 0 5px' ng-repeat='str in data track by $index'>{{str}}</div><div style='height:10px'></div>";
var el = element.empty().append($compile(template)(scope)).children()[0]
} else { } else {
var el_chart = element.addClass("chart").css({display:"block"}); var el_chart = element.addClass("chart").css({display:"block"});

View File

@ -139,6 +139,12 @@ class DummyTestCase(test.TestCase):
"description": desc % "Complete StackedArea", "description": desc % "Complete StackedArea",
"label": "Yet another measurement units", "label": "Yet another measurement units",
"title": "Complete StackedArea"}, "title": "Complete StackedArea"},
{"title": "Arbitrary Text",
"chart_plugin": "TextArea",
"data": ["Lorem ipsum dolor sit amet, consectetur "
"adipiscing elit, sed do eiusmod tempor "
"incididunt ut labore et dolore magna "
"aliqua." * 2] * 4},
{"chart_plugin": "Pie", {"chart_plugin": "Pie",
"data": [[s, exp] for s in ("delta", "epsilon", "zeta", "data": [[s, exp] for s in ("delta", "epsilon", "zeta",
"theta", "lambda", "omega")], "theta", "lambda", "omega")],

View File

@ -644,6 +644,13 @@ class OutputStatsTableTestCase(test.TestCase):
table.render()) table.render())
class OutputTextAreaTestCase(test.TestCase):
def test_class(self):
self.assertTrue(issubclass(charts.OutputTextArea, charts.OutputChart))
self.assertEqual("TextArea", charts.OutputTextArea.widget)
@ddt.ddt @ddt.ddt
class ModuleTestCase(test.TestCase): class ModuleTestCase(test.TestCase):