Repository navigation
feat(pulse): add a logarithmic Y scale with WithLogScale - #38
Merged
Merged
Conversation
Values map to rows by log10; values at or below zero are gaps. Ticks go at the powers of ten (scale.LogTicks), auto range widens to whole decades (scale.LogRange), and thresholds follow the same mapping. Renderers get a plot-space Chart, so neither the Chart interface nor the renderers change. SetSymmetric after turning auto range off now mirrors the last drawn range instead of the range set before auto range. Closes #10
math.Log on amd64 reads the exponent from the bits, so Log10 of a subnormal value is off by many decades. decadeOf now corrects the guess in a loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a logarithmic Y scale for metrics that span orders of magnitude, such as latency, where a linear scale presses normal traffic against the bottom row.
WithLogScale,SetLogScaleandLogScale(). Values map to rows by log10; values at or below zero are drawn as gaps.Push,Last,SeriesDataand legends keep the real values.max / 10, both bounds non-positive give1..10.Min()andMax()keep the stored range.scale.LogTicks). Auto range widens to whole decades (scale.LogRange).Chart(range0..decades, valueslog10(v / lo)), so theChartinterface and the renderers do not change.docs/axes-and-grid.mdwith thelogscalescreenshot.Bugs found and fixed along the way:
SetSymmetric(true)after turning auto range off mirrored the range set before auto range, not the range last drawn.math.Logreads the exponent from the bits, soLog10of a subnormal value is off by many decades. The decade search now corrects the guess in a loop (CI on Ubuntu caught it).Left for later:
Issues
Closes #10
Type of Change
Checklist
gofmt,go vet).go test -race ./...) and everything builds (go build ./...andgo -C examples build ./...).