[GH-ISSUE #95] LineChart should limit the use of decimal digits on the Y axis #61

Open
opened 2026-03-03 16:22:03 +03:00 by kerem · 0 comments
Owner

Originally created by @mum4k on GitHub (Jan 27, 2019).
Original GitHub issue: https://github.com/mum4k/termdash/issues/95

The following screenshot demonstrates the issue:

screen shot 2019-01-26 at 20 30 23

All the values are integers in the range of 1600-1800, yet the LineChart shows floating point values. This is because when the LineChart calculates the value of each cell row (called the step) it ends up being a floating point number.

Step of the Y axis is calculated here:
github.com/mum4k/termdash@1e1dc15c47/widgets/linechart/axes/scale.go (L65)

The labels are determined here:
github.com/mum4k/termdash@1e1dc15c47/widgets/linechart/axes/label.go (L85)

We could add a conditional and if the step between two adjacent rows is larger than X (say 10 or 20?) the generated label will rounded to the nearest integer.

Originally created by @mum4k on GitHub (Jan 27, 2019). Original GitHub issue: https://github.com/mum4k/termdash/issues/95 The following screenshot demonstrates the issue: <img width="644" alt="screen shot 2019-01-26 at 20 30 23" src="https://user-images.githubusercontent.com/5315344/51794869-62a9de00-21a9-11e9-9240-1ff25385b22e.png"> All the values are integers in the range of 1600-1800, yet the LineChart shows floating point values. This is because when the LineChart calculates the value of each cell row (called the step) it ends up being a floating point number. Step of the Y axis is calculated here: https://github.com/mum4k/termdash/blob/1e1dc15c47adf691d0f5a698a19d0662f2b5ab14/widgets/linechart/axes/scale.go#L65 The labels are determined here: https://github.com/mum4k/termdash/blob/1e1dc15c47adf691d0f5a698a19d0662f2b5ab14/widgets/linechart/axes/label.go#L85 We could add a conditional and if the step between two adjacent rows is larger than X (say 10 or 20?) the generated label will rounded to the nearest integer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/termdash#61
No description provided.