Skip to content

Commit

Permalink
Merge pull request #9 from gisce/add-suffix-indicator
Browse files Browse the repository at this point in the history
Add suffix to indicator
  • Loading branch information
ecarreras authored May 14, 2024
2 parents e395950 + 47ca178 commit 68ba20b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
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

0 comments on commit 68ba20b

Please sign in to comment.