From 5aed97a1ade09a7ffab61977d5f54768b196e844 Mon Sep 17 00:00:00 2001 From: Evan Goetz Date: Thu, 18 Jan 2024 15:20:21 -0800 Subject: [PATCH] Fix for gaps in segments causing unfilled pie chart plots --- gwsumm/plot/segments.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/gwsumm/plot/segments.py b/gwsumm/plot/segments.py index ba1172e1..f5dd9ce3 100644 --- a/gwsumm/plot/segments.py +++ b/gwsumm/plot/segments.py @@ -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 + (future_time <= 0 and total < alltime)): + if future_time > 0 and total < current_alltime: + data.append(current_alltime - total) + 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) 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(' ') if 'colors' in plotargs: - plotargs['colors'] = list(plotargs['colors']) + ['white'] + plotargs['colors'] = list(plotargs['colors']).extend('white') # make pie labels = plotargs.pop('label')