Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram legend is missing the first interval #23

Open
gsauthof opened this issue Feb 6, 2020 · 1 comment
Open

Histogram legend is missing the first interval #23

gsauthof opened this issue Feb 6, 2020 · 1 comment

Comments

@gsauthof
Copy link
Contributor

gsauthof commented Feb 6, 2020

Example:

seq 1000 1000000 | jp -input csv  -x '[*]' -type hist -bins 15

When my terminal is wide enough then the 15 intervals are correctly included below each bar.

But when the terminal to small for inline display, the then displayed legend just includes 14 intervals, i.e. the interval for the zeroth bar is missing.

That means the legend looks like this:

1  [67600,134200) 
2  [134200,200800)
3  [200800,267400)
4  [267400,334000)
5  [334000,400600)
6  [400600,467200)
7  [467200,533800)
8  [533800,600400)
9  [600400,667000)
10 [667000,733600)
11 [733600,800200)
12 [800200,866800)
13 [866800,933400)
14 [933400,1e+06]

The inline display:

[1000,67600)   [67600,134200)   [134200,200800) [200800,267400)  [267400,334000) [334000,400600)  [400600,467200) [467200,533800)  [533800,600400) [600400,667000)  [667000,733600) [733600,800200)  [800200,866800) [866800,933400)  [933400,1e+06]
@tberreis
Copy link

tberreis commented Apr 3, 2024

I had the same issue and got it working by subtracting the height of the runes.
Unfortunately it seems this project is no longer maintained so here's what I changed locally:

        if labelsRight {
                for i, group := range table.Columns {
-                       c.GetBuffer().WriteRight(c.GetBuffer().Height-i, paddingX+1+chartWidth/c.RuneSize().Width, []rune(Fi(i)))
-                       c.GetBuffer().WriteRight(c.GetBuffer().Height-i, paddingX+4+chartWidth/c.RuneSize().Width, []rune(group))
+                       c.GetBuffer().WriteRight(c.GetBuffer().Height-i-c.RuneSize().Height, paddingX+1+chartWidth/c.RuneSize().Width, []rune(Fi(i)))
+                       c.GetBuffer().WriteRight(c.GetBuffer().Height-i-c.RuneSize().Height, paddingX+4+chartWidth/c.RuneSize().Width, []rune(group))
                }
        }

image

Before
image

After
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants