Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chart/Graphics/Rendering/Chart/Axis/Floating.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ scaledAxis lap rs@(minV,maxV) ps0 = makeAxis' realToFrac realToFrac
ps = filter isValidNumber ps0
range [] = (0,1)
range _ | minV == maxV = if minV==0 then (-1,1) else
let d = abs (minV * 0.01) in (minV-d,maxV+d)
let d = max 1e-300 (abs (minV * 0.01)) in (minV-d,maxV+d)
| otherwise = rs
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure if this is the correct behavior. It seems to give me a range of (-1e-300, 1e-300) when rs = (0, 0) and the freeze came back. Could you check it for me?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 1e-300 is bad choice. Smallest normalized number 2.2250738585072014e-308 is 8 orders of magnitude away and underflow doesn't happen even for 1e-321. It's probably better to check whether maxV+d and minV-d are equal to maxV/minV.

range _   | minV == maxV = case minV of
             0                            -> (-1,1)
             _ | lo /= minV && hi /= maxV -> (lo,hi)
               | otherwise                -> (minV/2,maxV*2)
          | otherwise    = rs
d  = abs (minV * 0.01)
lo = minV - d
hi = maxV + d

labelvs = map fromRational $ steps (fromIntegral (_la_nLabels lap)) r
tickvs = map fromRational $ steps (fromIntegral (_la_nTicks lap))
Expand Down