Skip to content

Commit

Permalink
create simple pie-plot when only one value is present and pie-first-i…
Browse files Browse the repository at this point in the history
…s-total is set
  • Loading branch information
AndreasHeger committed Jan 11, 2016
1 parent 2e1e895 commit 5fded92
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CGATReportPlugins/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,12 @@ def __init__(self, *args, **kwargs):

def plot(self, keys, values, path):

# If there is only a single column, keys will be
# the sample, not the category
if len(keys) == 1:
if self.mFirstIsTotal:
keys = [self.mFirstIsTotal]

for x in keys:
if x not in self.sorted_keys:
self.sorted_keys[x] = len(self.sorted_keys)
Expand All @@ -2175,7 +2181,7 @@ def plot(self, keys, values, path):
return self.endPlot(None, None, path)

# subtract others from total - rest
if self.mFirstIsTotal:
if self.mFirstIsTotal and len(sorted_vals) > 1:
sorted_vals[0] -= sum(sorted_vals[1:])
if sorted_vals[0] < 0:
raise ValueError(
Expand Down

0 comments on commit 5fded92

Please sign in to comment.