Skip to content

Commit

Permalink
Fix for gaps in segments causing unfilled pie chart plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Goetz committed Jan 18, 2024
1 parent b007282 commit 5aed97a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions gwsumm/plot/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,31 @@ def draw(self, outputfile=None):
data.append(float(abs(segs.active)))

# handle missing or future data
# TODO: There is something messed up about "labels" and
# "label" that should be cleaned up
total = float(sum(data))
if future or (total < alltime):
data.append(alltime - total)
current_alltime = globalv.NOW - self.span[0]
future_time = self.span[1] - globalv.NOW # <0 if runtime is after span
if ((future_time > 0 and total < current_alltime) or

Check warning on line 1037 in gwsumm/plot/segments.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/plot/segments.py#L1035-L1037

Added lines #L1035 - L1037 were not covered by tests
(future_time <= 0 and total < alltime)):
if future_time > 0 and total < current_alltime:
data.append(current_alltime - total)

Check warning on line 1040 in gwsumm/plot/segments.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/plot/segments.py#L1039-L1040

Added lines #L1039 - L1040 were not covered by tests
else:
data.append(alltime - total)
if 'labels' in plotargs:
plotargs['labels'] = list(plotargs['labels']).extend('Missing')
elif 'label' in plotargs:
plotargs['label'] = list(plotargs['label']).extend('Missing')
if 'colors' in plotargs:
plotargs['colors'] = list(plotargs['colors']).extend('red')
if future:
data.append(future_time)

Check warning on line 1050 in gwsumm/plot/segments.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/plot/segments.py#L1042-L1050

Added lines #L1042 - L1050 were not covered by tests
if 'labels' in plotargs:
plotargs['labels'] = list(plotargs['labels']) + [' ']
plotargs['labels'] = list(plotargs['labels']).extend(' ')
elif 'label' in plotargs:
plotargs['labels'] = list(plotargs['label']).extend(' ')

Check warning on line 1054 in gwsumm/plot/segments.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/plot/segments.py#L1052-L1054

Added lines #L1052 - L1054 were not covered by tests
if 'colors' in plotargs:
plotargs['colors'] = list(plotargs['colors']) + ['white']
plotargs['colors'] = list(plotargs['colors']).extend('white')

Check warning on line 1056 in gwsumm/plot/segments.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/plot/segments.py#L1056

Added line #L1056 was not covered by tests

# make pie
labels = plotargs.pop('label')
Expand Down

0 comments on commit 5aed97a

Please sign in to comment.