Skip to content

Commit

Permalink
[freqtbl] base histogram width on column width #1807
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Jun 4, 2023
1 parent 58e362e commit 0540697
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions visidata/freqtbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


vd.option('disp_histogram', '*', 'histogram element character')
vd.option('disp_histolen', 50, 'width of histogram column')
vd.option('histogram_bins', 0, 'number of bins for histogram of numeric columns')
vd.option('numeric_binning', False, 'bin numeric columns into ranges', replay=True)

Expand All @@ -22,7 +21,7 @@ def valueNames(vd, discrete_vals, numeric_vals):
class HistogramColumn(Column):
def calcValue(col, row):
histogram = col.sheet.options.disp_histogram
histolen = col.sheet.options.disp_histolen
histolen = col.width-2
return histogram*(histolen*len(row.sourcerows)//col.sheet.largest)


Expand Down Expand Up @@ -77,8 +76,8 @@ def reload(self):
]:
self.addColumn(c)

if self.options.disp_histolen and self.options.disp_histogram:
c = HistogramColumn('histogram', type=str, width=self.options.disp_histolen+2)
if self.options.disp_histogram:
c = HistogramColumn('histogram', type=str, width=self.options.default_width*2)
self.addColumn(c)

# two more threads
Expand Down
3 changes: 2 additions & 1 deletion visidata/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def groupRows(self, rowfunc=None):

# automatically add cache to all columns now that everything is binned
for c in self.nonKeyVisibleCols:
c.setCache(True)
if isinstance(c, AggrColumn):
c.setCache(True)


@PivotSheet.api
Expand Down

0 comments on commit 0540697

Please sign in to comment.