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

How to avoid rounding when data points are of the same value #61

Open
echarrod opened this issue Jan 2, 2025 · 0 comments
Open

How to avoid rounding when data points are of the same value #61

echarrod opened this issue Jan 2, 2025 · 0 comments

Comments

@echarrod
Copy link

echarrod commented Jan 2, 2025

If I have data points that are the same value, e.g. with:

func Test_AsciiGraph(t *testing.T) {
	coverageGraphPoints := []float64{49.51, 49.51, 49.51}
	asciiGraph := fmt.Sprintf("\n\n%s", asciigraph.Plot(coverageGraphPoints,
		asciigraph.Precision(2),
		asciigraph.Caption("Code Coverage (excluding generated)")))
	fmt.Println(asciiGraph)
}

Then I get a rounded y axis value of 50.00, rather than 49.51:

=== RUN   Test_AsciiGraph


 50.00 ┼──
        Code Coverage (excluding generated)
--- PASS: Test_AsciiGraph (0.00s)
PASS

But if I have one value different, I get the graph that I expect (with coverageGraphPoints := []float64{49.51, 49.51, 49.52}:

=== RUN   Test_AsciiGraph


 49.52 ┤ ╭
 49.52 ┤ │
 49.51 ┼─╯
        Code Coverage (excluding generated)
--- PASS: Test_AsciiGraph (0.00s)
PASS

I do not want this rounding, and I instead want something like this:

=== RUN   Test_AsciiGraph


 49.51 ┼──
        Code Coverage (excluding generated)
--- PASS: Test_AsciiGraph (0.00s)
PASS

Was this a design decision to round when the values are the same? I see we are using a rounded "max2" at pkg/mod/github.com/guptarohit/[email protected]/asciigraph.go:82

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

1 participant