Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suffix to indicator #9

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ooui/graph/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def process(self, value, total=0):
'value': value,
'total': total,
}
if self.suffix:
res['suffix'] = self.suffix
if self.show_percent:
res['percent'] = round_number(value / total * 100)
if self.color:
Expand Down
3 changes: 2 additions & 1 deletion spec/graph/graph_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

with it('should suport indicatorField graphs'):
xml = """<?xml version="1.0"?>
<graph string="My indicator" showPercent="1" type="indicatorField" color="red:debt>0;green:debt==0" icon="slack">
<graph string="My indicator" showPercent="1" type="indicatorField" color="red:debt>0;green:debt==0" icon="slack" suffix="kW">
<field name="potencia" operator="+" />
</graph>
"""
Expand All @@ -33,6 +33,7 @@
expect(graph.fields).to(contain_only('potencia'))
expect(graph.total_domain).to(be_none)
expect(graph.show_percent).to(be_true)
expect(graph.suffix).to(equal('kW'))

with it("should parse a chart graph XML with type line"):
xml = """<?xml version="1.0"?>
Expand Down
3 changes: 2 additions & 1 deletion spec/graph/processor_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_graph_data(xml, model):

with it('should process indicatorField graph'):
xml = """<?xml version="1.0"?>
<graph string="My indicator" showPercent="1" type="indicatorField" color="red:value>0;green:value==0" totalDomain="[]" icon="slack">
<graph string="My indicator" showPercent="1" type="indicatorField" color="red:value>0;green:value==0" totalDomain="[]" icon="slack" suffix="kW">
<field name="potencia" operator="+" />
</graph>
"""
Expand All @@ -66,6 +66,7 @@ def get_graph_data(xml, model):
total=275.72,
color='red',
icon='slack',
suffix='kW',
))

with it('should process indicator graph'):
Expand Down
Loading