From 04ccca370616fe561e474248c434cb2dabb1436d Mon Sep 17 00:00:00 2001 From: John Wang Date: Mon, 14 Jun 2021 16:18:23 -0700 Subject: [PATCH] enhance: data/statictimeseries: adjust report percentage for 0 --- data/statictimeseries/data_series_set_report.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/statictimeseries/data_series_set_report.go b/data/statictimeseries/data_series_set_report.go index 47ca350..106e5de 100644 --- a/data/statictimeseries/data_series_set_report.go +++ b/data/statictimeseries/data_series_set_report.go @@ -219,7 +219,11 @@ func (dss *DataSeriesSet) ToTable(opts *DssTableOpts) (table.Table, error) { } if opts.PercentInclude { for _, seriesValue := range seriesValues { - line = append(line, fmt.Sprintf("%.10f", seriesValue/lineTotal)) + if lineTotal == 0 { + line = append(line, fmt.Sprintf("%.10f", lineTotal)) + } else { + line = append(line, fmt.Sprintf("%.10f", seriesValue/lineTotal)) + } } } tbl.Rows = append(tbl.Rows, line)