Skip to content
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: 1 addition & 1 deletion ooui/graph/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def process(self, values, fields, options=None):
if ((self.type == 'line' and self.y_range)
or (self.type == 'bar' and self.y_range == 'slider')):
y_axis_opts = {'mode': self.y_range}
if self.y_range == 'auto':
if self.y_range == 'auto' and final_data:
y_axis_opts['valueOpts'] = get_min_max(final_data)
result['yAxisOpts'] = y_axis_opts

Expand Down
14 changes: 14 additions & 0 deletions spec/graph/graph_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@
'max': 32
}
}))

with it("should return empty data without value limits when there are no values"):
xml = """<?xml version="1.0"?>
<graph type="line" y_range="auto" timerange="day">
<field name="date" axis="x"/>
<field name="v" operator="+" axis="y"/>
</graph>
"""
graph = parse_graph(xml)
fields = {'date': {'type': 'date'}, 'v': {'type': 'integer'}}
result = graph.process([], fields)
expect(result['data']).to(equal([]))
expect(result['yAxisOpts']).to(equal({'mode': 'auto'}))

with description("A line graph with y_range to full"):
with it("should return yAxisOpts to the result with mode full"):
xml = """<?xml version="1.0"?>
Expand Down
Loading