Skip to content

Commit

Permalink
Axis ranges (#106)
Browse files Browse the repository at this point in the history
* fixed out of bounds graphs

* format

* maintainability out you go

* maintainability out you go again

* removed logg import and line

* clarity improved

* fixed comments

* format

---------

Co-authored-by: FrederikRothe <[email protected]>
  • Loading branch information
FrederikRothe and FrederikRothe authored Apr 20, 2023
1 parent 8508cd3 commit 88935ee
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions figures/line.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from cmath import pi
from collections import defaultdict
import logging
from bokeh.plotting import figure
from modu.dashboard.figure import Figure
from bokeh.models import DatetimeTickFormatter
from bokeh.models import DatetimeTickFormatter, Range1d


class LineChart(Figure):
Expand All @@ -21,10 +22,22 @@ def _get_line(self, data, key):
y_axis_label="No. Violations",
)
p.line(x, y, legend_label="Progress", line_width=2)
try:
p.y_range = Range1d(0, (int(max(y)) * 1.1))
except ValueError:
logging.warning(("No data to plot created for", key))
return
return p

def get_figure(self):
result = [self._get_line(self._data, key) for key in self._data]
result = []
for key in self._data:
output = self._get_line(self._data, key)
if (
output is None
): # If output is None, the data is not suited for line graphs. Skip it.
continue
result.append(output)
return result


Expand Down

0 comments on commit 88935ee

Please sign in to comment.