granite 0.5.0.0 → 0.6.0.0
raw patch · 12 files changed
+24/−29 lines, 12 filesdep ~basedep ~granite
Dependency ranges changed: base, granite
Files
- granite.cabal +4/−4
- src/Granite/Chart.hs +0/−1
- src/Granite/Data/Frame.hs +0/−1
- src/Granite/Internal/LegacyChart.hs +1/−2
- src/Granite/Render/Chrome.hs +1/−3
- src/Granite/Render/Pipeline.hs +12/−11
- src/Granite/Render/Scene.hs +0/−1
- src/Granite/Render/Svg.hs +1/−1
- src/Granite/Render/Terminal.hs +1/−0
- src/Granite/Scale.hs +1/−2
- src/Granite/Stat.hs +2/−2
- test/Golden.hs +1/−1
granite.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: granite-version: 0.5.0.0+version: 0.6.0.0 synopsis: Easy terminal plotting. description: A terminal plotting library for quick and easy visualisation. license: MIT@@ -69,7 +69,7 @@ main-is: Main.hs build-depends: base >=4 && <5,- granite ^>= 0.5,+ granite ^>= 0.6, text >= 1 && < 3 hs-source-dirs: app default-language: GHC2021@@ -81,7 +81,7 @@ base >=4 && <5, directory >= 1.3 && < 1.4, filepath >= 1.4 && < 1.6,- granite ^>= 0.5,+ granite ^>= 0.6, text >= 1 && < 3 hs-source-dirs: app default-language: GHC2021@@ -106,7 +106,7 @@ build-depends: base >= 4.14 && < 5- , granite ^>= 0.5+ , granite ^>= 0.6 , text >= 1.2 && < 3 , hspec >= 2.7 && < 2.12 , QuickCheck >= 2.14 && < 3
src/Granite/Chart.hs view
@@ -32,7 +32,6 @@ import Data.Text (Text) -import Granite.Data.Frame (Column (..), fromColumns) import Granite.Spec {- | Build an IR scatter chart from N series, each with its own (x, y)
src/Granite/Data/Frame.hs view
@@ -1,4 +1,3 @@- {-# LANGUAGE Strict #-} {- |
src/Granite/Internal/LegacyChart.hs view
@@ -7,7 +7,7 @@ License : MIT Maintainer : mschavinda@gmail.com -Chart builders shared between 'Granite' and 'Granite.Svg' for the+Chart builders shared between "Granite" and "Granite.Svg" for the plotly-express-style helpers (area, ribbon, density, errorBars, funnel, polarLine, waterfall, distPlot). -}@@ -27,7 +27,6 @@ import Data.Text (Text) import Data.Text qualified as Text -import Granite.Data.Frame (Column (..), fromColumns) import Granite.Spec plotChart :: Int -> Int -> Text -> Chart -> Chart
src/Granite/Render/Chrome.hs view
@@ -1,4 +1,3 @@- {-# LANGUAGE Strict #-} {- |@@ -18,6 +17,7 @@ legendMarks, ) where +import Data.Char (isDigit) import Data.Text (Text) import Data.Text qualified as Text @@ -31,8 +31,6 @@ TextStyle (..), defaultStyle, defaultTextStyle,- pxPerChar,- pxPerLine, ) import Granite.Scale (TrainedScale (..)) import Granite.Spec (
src/Granite/Render/Pipeline.hs view
@@ -19,6 +19,7 @@ ) where import Data.List qualified as List+import Data.Maybe (fromMaybe) import Data.Text (Text) import Data.Text qualified as Text @@ -409,7 +410,7 @@ Layer -> [Mark] runLayer theme box proj palette ix globalFrame layer =- let frame0 = Data.Maybe.fromMaybe globalFrame (layerData layer)+ let frame0 = fromMaybe globalFrame (layerData layer) framePostStat = applyStat (layerStat layer) (layerMapping layer) frame0 frame = applyPosition (layerPosition layer) (layerMapping layer) framePostStat m = layerMapping layer@@ -421,8 +422,8 @@ radius = case defSize defaults of Just r -> r Nothing -> pointSize theme layer- alpha = Data.Maybe.fromMaybe 1 (defAlpha defaults)- lineW = Data.Maybe.fromMaybe 2 (defLineWidth defaults)+ alpha = fromMaybe 1 (defAlpha defaults)+ lineW = fromMaybe 2 (defLineWidth defaults) in case layerGeom layer of GeomPoint -> drawPoints proj frame m colorSpec radius alpha GeomLine -> drawLine proj frame m colorSpec lineW@@ -670,7 +671,7 @@ cy = boxY box + boxH box / 2 r = min (boxW box) (boxH box) / 2 * 0.9 fracs = if total == 0 then map (const 0) vs else map (/ total) vs- starts = scanl (+) (- (pi / 2)) (map (* (2 * pi)) fracs)+ starts = scanl (+) (-(pi / 2)) (map (* (2 * pi)) fracs) ends = drop 1 starts colorAt i = palette !! (i `mod` max 1 (length palette)) in [ MArc@@ -710,7 +711,7 @@ folds @aesY@ + @aesYmin@ + @aesYmax@ + the conventional internal columns so ribbon / errorbar / boxplot layers (which leave 'aesY' unset) still get a sensible Y range. Stat and position are applied-so histogram-style 'count' columns appear.+so histogram-style @count@ columns appear. -} unionDataRange :: [Mapping -> Maybe ColumnRef] ->@@ -722,7 +723,7 @@ [ values | layer <- layers , let m = layerMapping layer- base = Data.Maybe.fromMaybe globalFrame (layerData layer)+ base = fromMaybe globalFrame (layerData layer) stat' = applyStat (layerStat layer) m base frame = applyPosition (layerPosition layer) m stat' , getRef <- getRefs@@ -791,7 +792,7 @@ let breaks = [fromIntegral i | i <- [0 .. length labels - 1 :: Int]] in ts{tsBreaks = breaks, tsLabels = labels} -{- | Read /pre-stat/ — a stat like 'StatBoxplot' consumes the+{- | Read /pre-stat/ — a stat like 'Granite.Spec.StatBoxplot' consumes the categorical X and emits numeric indices, but the labels we want are the user's original group names. -}@@ -805,7 +806,7 @@ findFirst [] = Nothing findFirst (layer : rest) = let m = layerMapping layer- frame = Data.Maybe.fromMaybe globalFrame (layerData layer)+ frame = fromMaybe globalFrame (layerData layer) in case getRef m of Just (ColumnRef n) -> case lookupColumn n frame of Just (ColCat xs) -> Just (List.nub xs)@@ -823,7 +824,7 @@ | not (needsPadding (layerGeom layer) isXAxis) = 0 | otherwise = let m = layerMapping layer- base = Data.Maybe.fromMaybe globalFrame (layerData layer)+ base = fromMaybe globalFrame (layerData layer) postStat = applyStat (layerStat layer) m base postPos = applyPosition (layerPosition layer) m postStat in case resolveNumColumn postPos (getRef m) of@@ -861,7 +862,7 @@ anchorFor layer = let m = layerMapping layer- base = Data.Maybe.fromMaybe globalFrame (layerData layer)+ base = fromMaybe globalFrame (layerData layer) postStat = applyStat (layerStat layer) m base postPos = applyPosition (layerPosition layer) m postStat in case lookupColumn "__ybase" postPos >>= columnAsNum of@@ -892,5 +893,5 @@ -} specToTerminal :: ColorSpec -> Color specToTerminal (NamedColor c) = c-specToTerminal (RGB {}) = BrightBlue+specToTerminal (RGB{}) = BrightBlue specToTerminal (Hex _) = BrightBlue
src/Granite/Render/Scene.hs view
@@ -1,4 +1,3 @@- {-# LANGUAGE Strict #-} {- |
src/Granite/Render/Svg.hs view
@@ -26,7 +26,7 @@ import Data.Text (Text) import Data.Text qualified as T -import Granite.Color (Color (..), colorHex)+import Granite.Color (colorHex) import Granite.Internal.Util (escXml, showD) import Granite.Render.Scene ( Mark (..),
src/Granite/Render/Terminal.hs view
@@ -27,6 +27,7 @@ import Data.Bits ((.|.)) import Data.Char (chr) import Data.List qualified as List+import Data.Maybe (isNothing) import Data.Text (Text) import Data.Text qualified as Text
src/Granite/Scale.hs view
@@ -1,4 +1,3 @@- {-# LANGUAGE Strict #-} {- |@@ -193,7 +192,7 @@ step = niceNum (range / fromIntegral (target - 1)) True gMin = (fromIntegral :: Int -> Double) (floor (lo / step)) * step gMax = (fromIntegral :: Int -> Double) (ceiling (hi / step)) * step- n = round ((gMax - gMin) / step) + 1+ n = round ((gMax - gMin) / step) + 1 :: Int in [gMin + step * fromIntegral i | i <- [0 .. n - 1]] where isValid x = not (isNaN x || isInfinite x)
src/Granite/Stat.hs view
@@ -9,7 +9,7 @@ Statistical transforms ('Stat'). Each runs on a layer's mapped X / Y columns and returns a new frame, generally with the same column names-holding the transformed values. 'StatBoxplot' additionally writes+holding the transformed values. 'Granite.Spec.StatBoxplot' additionally writes @__ymin@ / @__q1@ / @__median@ / @__q3@ / @__ymax@ for the boxplot geom to read. -}@@ -131,7 +131,7 @@ stepEdges w lo hi | lo == hi = [lo - w / 2, hi + w / 2] | otherwise =- let n = max 1 (ceiling ((hi - lo) / w))+ let n = max 1 (ceiling ((hi - lo) / w)) :: Int in [lo + w * fromIntegral i | i <- [0 .. n]] runDensity :: Mapping -> DataFrame -> DataFrame
test/Golden.hs view
@@ -62,7 +62,7 @@ <> "\n(Re-bless with GRANITE_BLESS_GOLDEN=1 if the change is intentional.)" firstDiff :: [Text] -> [Text] -> String-firstDiff as es = go 0 as es+firstDiff as es = go (0 :: Int) as es where go _ [] [] = "(unknown — file lengths match but bytes differ)" go i [] (e : _) = " (line " <> show i <> ": actual EOF, expected " <> Text.unpack e <> ")"