packages feed

chart-svg 0.8.0.3 → 0.8.1.0

raw patch · 5 files changed

+168/−79 lines, 5 filesdep ~containersdep ~doctest-paralleldep ~markup-parsePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: containers, doctest-parallel, markup-parse

API changes (from Hackage documentation)

- Chart.Data: type family Base a;
- Chart.Hud: [$sel:adjustments:AxisOptions] :: AxisOptions -> Maybe Adjustments
- Chart.Hud: [$sel:alignCharts:LegendOptions] :: LegendOptions -> Align
- Chart.Hud: [$sel:allowDiagonal:Adjustments] :: Adjustments -> Bool
- Chart.Hud: [$sel:anchorTo:AxisBar] :: AxisBar -> HudChartSection
- Chart.Hud: [$sel:anchorTo:FrameOptions] :: FrameOptions -> HudChartSection
- Chart.Hud: [$sel:anchorTo:LegendOptions] :: LegendOptions -> HudChartSection
- Chart.Hud: [$sel:anchorTo:TickStyle] :: TickStyle -> HudChartSection
- Chart.Hud: [$sel:anchoring:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:anchoring:TitleOptions] :: TitleOptions -> Double
- Chart.Hud: [$sel:angledRatio:Adjustments] :: Adjustments -> Double
- Chart.Hud: [$sel:axes:HudOptions] :: HudOptions -> [Priority AxisOptions]
- Chart.Hud: [$sel:axisBar:AxisOptions] :: AxisOptions -> Maybe AxisBar
- Chart.Hud: [$sel:buffer:AxisBar] :: AxisBar -> Double
- Chart.Hud: [$sel:buffer:FrameOptions] :: FrameOptions -> Double
- Chart.Hud: [$sel:buffer:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:buffer:TickStyle] :: TickStyle -> Double
- Chart.Hud: [$sel:buffer:TitleOptions] :: TitleOptions -> Double
- Chart.Hud: [$sel:chartSection:HudChart] :: HudChart -> ChartTree
- Chart.Hud: [$sel:frame:FrameOptions] :: FrameOptions -> Maybe Style
- Chart.Hud: [$sel:frame:LegendOptions] :: LegendOptions -> Maybe Style
- Chart.Hud: [$sel:frames:HudOptions] :: HudOptions -> [Priority FrameOptions]
- Chart.Hud: [$sel:glyphTick:Ticks] :: Ticks -> Maybe TickStyle
- Chart.Hud: [$sel:hgap:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:hudSection:HudChart] :: HudChart -> ChartTree
- Chart.Hud: [$sel:innerPad:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:item:Priority] :: Priority a -> a
- Chart.Hud: [$sel:legendCharts:LegendOptions] :: LegendOptions -> [(Text, [Chart])]
- Chart.Hud: [$sel:legendSize:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:legends:HudOptions] :: HudOptions -> [Priority LegendOptions]
- Chart.Hud: [$sel:lineTick:Ticks] :: Ticks -> Maybe TickStyle
- Chart.Hud: [$sel:maxXRatio:Adjustments] :: Adjustments -> Double
- Chart.Hud: [$sel:maxYRatio:Adjustments] :: Adjustments -> Double
- Chart.Hud: [$sel:numStacks:LegendOptions] :: LegendOptions -> Int
- Chart.Hud: [$sel:outerPad:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:overhang:AxisBar] :: AxisBar -> Double
- Chart.Hud: [$sel:phud:Hud] :: Hud -> Priority (HudChart -> ChartTree)
- Chart.Hud: [$sel:place:AxisOptions] :: AxisOptions -> Place
- Chart.Hud: [$sel:place:LegendOptions] :: LegendOptions -> Place
- Chart.Hud: [$sel:place:TitleOptions] :: TitleOptions -> Place
- Chart.Hud: [$sel:priority:Priority] :: Priority a -> Double
- Chart.Hud: [$sel:scaleChartsBy:LegendOptions] :: LegendOptions -> Double
- Chart.Hud: [$sel:scaleP:LegendOptions] :: LegendOptions -> ScaleP
- Chart.Hud: [$sel:size:AxisBar] :: AxisBar -> Double
- Chart.Hud: [$sel:style:AxisBar] :: AxisBar -> Style
- Chart.Hud: [$sel:style:TickStyle] :: TickStyle -> Style
- Chart.Hud: [$sel:style:TitleOptions] :: TitleOptions -> Style
- Chart.Hud: [$sel:text:TitleOptions] :: TitleOptions -> Text
- Chart.Hud: [$sel:textStyle:LegendOptions] :: LegendOptions -> Style
- Chart.Hud: [$sel:textTick:Ticks] :: Ticks -> Maybe TickStyle
- Chart.Hud: [$sel:tick:Ticks] :: Ticks -> Tick
- Chart.Hud: [$sel:ticks:AxisOptions] :: AxisOptions -> Ticks
- Chart.Hud: [$sel:titles:HudOptions] :: HudOptions -> [Priority TitleOptions]
- Chart.Hud: [$sel:vgap:LegendOptions] :: LegendOptions -> Double
- Chart.Style: [$sel:borderColor:Style] :: Style -> Colour
- Chart.Style: [$sel:borderSize:Style] :: Style -> Double
- Chart.Style: [$sel:color:Style] :: Style -> Colour
- Chart.Style: [$sel:dasharray:Style] :: Style -> Maybe [Double]
- Chart.Style: [$sel:dashoffset:Style] :: Style -> Maybe Double
- Chart.Style: [$sel:escapeText:Style] :: Style -> EscapeText
- Chart.Style: [$sel:frame:Style] :: Style -> Maybe Style
- Chart.Style: [$sel:glyphShape:Style] :: Style -> GlyphShape
- Chart.Style: [$sel:hsize:Style] :: Style -> Double
- Chart.Style: [$sel:lineCap:Style] :: Style -> Maybe LineCap
- Chart.Style: [$sel:lineJoin:Style] :: Style -> Maybe LineJoin
- Chart.Style: [$sel:rotation:Style] :: Style -> Maybe Double
- Chart.Style: [$sel:scaleP:Style] :: Style -> ScaleP
- Chart.Style: [$sel:size:Style] :: Style -> Double
- Chart.Style: [$sel:textAnchor:Style] :: Style -> TextAnchor
- Chart.Style: [$sel:translate:Style] :: Style -> Maybe (Point Double)
- Chart.Style: [$sel:vshift:Style] :: Style -> Double
- Chart.Style: [$sel:vsize:Style] :: Style -> Double
- Data.Path.Parser: manyComma :: Parser e a -> Parser e [a]
+ Chart.Data: type Base a;
+ Chart.Data: type Dir coord;
+ Chart.Data: type Mag a;
+ Chart.Hud: [adjustments] :: AxisOptions -> Maybe Adjustments
+ Chart.Hud: [alignCharts] :: LegendOptions -> Align
+ Chart.Hud: [allowDiagonal] :: Adjustments -> Bool
+ Chart.Hud: [anchorTo] :: LegendOptions -> HudChartSection
+ Chart.Hud: [anchoring] :: LegendOptions -> Double
+ Chart.Hud: [angledRatio] :: Adjustments -> Double
+ Chart.Hud: [axes] :: HudOptions -> [Priority AxisOptions]
+ Chart.Hud: [axisBar] :: AxisOptions -> Maybe AxisBar
+ Chart.Hud: [buffer] :: LegendOptions -> Double
+ Chart.Hud: [chartSection] :: HudChart -> ChartTree
+ Chart.Hud: [frame] :: LegendOptions -> Maybe Style
+ Chart.Hud: [frames] :: HudOptions -> [Priority FrameOptions]
+ Chart.Hud: [glyphTick] :: Ticks -> Maybe TickStyle
+ Chart.Hud: [hgap] :: LegendOptions -> Double
+ Chart.Hud: [hudSection] :: HudChart -> ChartTree
+ Chart.Hud: [innerPad] :: LegendOptions -> Double
+ Chart.Hud: [item] :: Priority a -> a
+ Chart.Hud: [legendCharts] :: LegendOptions -> [(Text, [Chart])]
+ Chart.Hud: [legendSize] :: LegendOptions -> Double
+ Chart.Hud: [legends] :: HudOptions -> [Priority LegendOptions]
+ Chart.Hud: [lineTick] :: Ticks -> Maybe TickStyle
+ Chart.Hud: [maxXRatio] :: Adjustments -> Double
+ Chart.Hud: [maxYRatio] :: Adjustments -> Double
+ Chart.Hud: [numStacks] :: LegendOptions -> Int
+ Chart.Hud: [outerPad] :: LegendOptions -> Double
+ Chart.Hud: [overhang] :: AxisBar -> Double
+ Chart.Hud: [phud] :: Hud -> Priority (HudChart -> ChartTree)
+ Chart.Hud: [place] :: LegendOptions -> Place
+ Chart.Hud: [priority] :: Priority a -> Double
+ Chart.Hud: [scaleChartsBy] :: LegendOptions -> Double
+ Chart.Hud: [scaleP] :: LegendOptions -> ScaleP
+ Chart.Hud: [size] :: AxisBar -> Double
+ Chart.Hud: [style] :: TickStyle -> Style
+ Chart.Hud: [textStyle] :: LegendOptions -> Style
+ Chart.Hud: [textTick] :: Ticks -> Maybe TickStyle
+ Chart.Hud: [text] :: TitleOptions -> Text
+ Chart.Hud: [tick] :: Ticks -> Tick
+ Chart.Hud: [ticks] :: AxisOptions -> Ticks
+ Chart.Hud: [titles] :: HudOptions -> [Priority TitleOptions]
+ Chart.Hud: [vgap] :: LegendOptions -> Double
+ Chart.Style: [borderColor] :: Style -> Colour
+ Chart.Style: [borderSize] :: Style -> Double
+ Chart.Style: [color] :: Style -> Colour
+ Chart.Style: [dasharray] :: Style -> Maybe [Double]
+ Chart.Style: [dashoffset] :: Style -> Maybe Double
+ Chart.Style: [escapeText] :: Style -> EscapeText
+ Chart.Style: [frame] :: Style -> Maybe Style
+ Chart.Style: [glyphShape] :: Style -> GlyphShape
+ Chart.Style: [hsize] :: Style -> Double
+ Chart.Style: [lineCap] :: Style -> Maybe LineCap
+ Chart.Style: [lineJoin] :: Style -> Maybe LineJoin
+ Chart.Style: [rotation] :: Style -> Maybe Double
+ Chart.Style: [scaleP] :: Style -> ScaleP
+ Chart.Style: [size] :: Style -> Double
+ Chart.Style: [textAnchor] :: Style -> TextAnchor
+ Chart.Style: [translate] :: Style -> Maybe (Point Double)
+ Chart.Style: [vshift] :: Style -> Double
+ Chart.Style: [vsize] :: Style -> Double
- Chart.Data: class () => Additive a
+ Chart.Data: class Additive a
- Chart.Data: class () => Multiplicative a
+ Chart.Data: class Multiplicative a
- Chart.Data: data () => Point a
+ Chart.Data: data Point a
- Chart.Data: data () => Range a
+ Chart.Data: data Range a
- Chart.Data: newtype () => Rect a
+ Chart.Data: newtype Rect a
- Chart.Markup: newtype () => Markup
+ Chart.Markup: newtype Markup

Files

ChangeLog.md view
@@ -1,3 +1,9 @@+0.8.1+===++- bumped upper bounds for markup-parse and containers.++ 0.8 === 
chart-svg.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: chart-svg-version: 0.8.0.3+version: 0.8.1.0 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2017@@ -11,94 +11,114 @@ bug-reports: https://github.com/tonyday567/chart-svg/issues synopsis: Charting library targetting SVGs. description:-    This package provides a charting library targetting SVG as the rendered output.+  This package provides a charting library targetting SVG as the rendered output. -    == Usage+  == Usage -    >>> :set -XOverloadedLabels-    >>> :set -XOverloadedStrings-    >>> import Chart-    >>> import Optics.Core-    >>> let lines = [[Point 0.0 1.0, Point 1.0 1.0, Point 2.0 5.0],[Point 0.0 0.0, Point 2.8 3.0],[Point 0.5 4.0, Point 0.5 0]]-    >>> let styles = (\c -> defaultLineStyle & set #color (palette c) & set #size 0.015) <$> [0..2]-    >>> let cs = zipWith (\s x -> LineChart s [x]) styles lines-    >>> let lineExample = mempty & set #chartTree (named "line" cs) & set #hudOptions defaultHudOptions :: ChartOptions-    >>> writeChartOptions "other/usage.svg" lineExample+  >>> :set -XOverloadedLabels+  >>> :set -XOverloadedStrings+  >>> import Chart+  >>> import Optics.Core+  >>> let lines = [[Point 0.0 1.0, Point 1.0 1.0, Point 2.0 5.0],[Point 0.0 0.0, Point 2.8 3.0],[Point 0.5 4.0, Point 0.5 0]]+  >>> let styles = (\c -> defaultLineStyle & set #color (palette c) & set #size 0.015) <$> [0..2]+  >>> let cs = zipWith (\s x -> LineChart s [x]) styles lines+  >>> let lineExample = mempty & set #chartTree (named "line" cs) & set #hudOptions defaultHudOptions :: ChartOptions+  >>> writeChartOptions "other/usage.svg" lineExample -    ![usage example](docs/other/usage.svg)+  ![usage example](docs/other/usage.svg) -    See "Chart" for concept design notes, and "Chart.Examples" for practical usage.+  See "Chart" for concept design notes, and "Chart.Examples" for practical usage.  build-type: Simple tested-with:-    , GHC == 9.10.1-    , GHC == 9.8.2-    , GHC == 9.6.5+  ghc ==9.8.4+  ghc ==9.10.2+  ghc ==9.12.2+ extra-doc-files:-    ChangeLog.md-    other/*.svg-    readme.md+  ChangeLog.md+  other/*.svg+  readme.md  source-repository head-    type: git-    location: https://github.com/tonyday567/chart-svg+  type: git+  location: https://github.com/tonyday567/chart-svg  common ghc-options-stanza-    ghc-options:-        -Wall-        -Wcompat-        -Widentities-        -Wincomplete-record-updates-        -Wincomplete-uni-patterns-        -Wpartial-fields-        -Wredundant-constraints+  ghc-options:+    -Wall+    -Wcompat+    -Widentities+    -Wincomplete-record-updates+    -Wincomplete-uni-patterns+    -Wpartial-fields+    -Wredundant-constraints -common ghc2021-stanza-    default-language: GHC2021+common ghc2024-additions+  default-extensions:+    DataKinds+    DerivingStrategies+    DisambiguateRecordFields+    ExplicitNamespaces+    GADTs+    LambdaCase+    MonoLocalBinds+    RoleAnnotations +common ghc2024-stanza+  if impl(ghc >=9.10)+    default-language:+      GHC2024+  else+    import: ghc2024-additions+    default-language:+      GHC2021+ library-    import: ghc-options-stanza-    import: ghc2021-stanza-    hs-source-dirs: src-    build-depends:-        , Color              >=0.3.2 && <0.5-        , base               >=4.14 && <5-        , bytestring         >=0.11.3 && <0.13-        , containers         >=0.6 && <0.8-        , cubicbezier        >=0.6 && <0.7-        , flatparse          >=0.5 && <0.6-        , formatn            >=0.3 && <0.4-        , harpie             >=0.1 && <0.2-        , markup-parse       >=0.1 && <0.2-        , mtl                >=2.2.2 && <2.4-        , numhask            >=0.11 && <0.13-        , numhask-space      >=0.10 && <0.14-        , optics-core        >=0.4 && <0.5-        , random             >=1.2 && <1.4-        , string-interpolate >=0.3 && <0.5-        , text               >=1.2 && <2.2-        , time               >=1.9 && <1.15-    exposed-modules:-        Chart-        Chart.Bar-        Chart.Compound-        Chart.Data-        Chart.Examples-        Chart.Hud-        Chart.Markup-        Chart.Primitive-        Chart.Style-        Chart.Surface-        Data.Colour-        Data.Path-        Data.Path.Parser+  import: ghc-options-stanza+  import: ghc2024-stanza+  hs-source-dirs: src+  build-depends:+    Color >=0.3.2 && <0.5,+    base >=4.14 && <5,+    bytestring >=0.11.3 && <0.13,+    containers >=0.6 && <0.9,+    cubicbezier >=0.6 && <0.7,+    flatparse >=0.5 && <0.6,+    formatn >=0.3 && <0.4,+    harpie >=0.1 && <0.2,+    markup-parse >=0.1 && <0.3,+    mtl >=2.2.2 && <2.4,+    numhask >=0.11 && <0.13,+    numhask-space >=0.10 && <0.14,+    optics-core >=0.4 && <0.5,+    random >=1.2 && <1.4,+    string-interpolate >=0.3 && <0.5,+    text >=1.2 && <2.2,+    time >=1.9 && <1.15, +  exposed-modules:+    Chart+    Chart.Bar+    Chart.Compound+    Chart.Data+    Chart.Examples+    Chart.Hud+    Chart.Markup+    Chart.Primitive+    Chart.Style+    Chart.Surface+    Data.Colour+    Data.Path+    Data.Path.Parser+ test-suite doctests-    import: ghc2021-stanza-    main-is: doctests.hs-    hs-source-dirs: test-    build-depends:-        , base             >=4.14 && <5-        , doctest-parallel >=0.3 && <0.4-    ghc-options: -threaded-    type: exitcode-stdio-1.0+  import: ghc2024-stanza+  main-is: doctests.hs+  hs-source-dirs: test+  build-depends:+    base >=4.14 && <5,+    doctest-parallel >=0.3 && <0.5,++  ghc-options: -threaded+  type: exitcode-stdio-1.0
src/Chart/Hud.hs view
@@ -1083,6 +1083,7 @@       )     _ -> blankChart1 (Rect 0 (view #legendSize l) 0 (view #legendSize l)) +-- | Takes legend options, a label and a list of charts and turns it into a form suitable for legend processing. legendEntry ::   LegendOptions ->   Text ->
src/Chart/Primitive.hs view
@@ -99,6 +99,7 @@ -- >>> import Chart -- >>> import Optics.Core -- >>> import NumHask.Prelude+-- >>> import Prelude qualified as P -- >>> let r = RectChart defaultRectStyle [one]  -- | A product type consisting of a 'Style', which is the stylistic manifestation of chart data, and 'ChartData' representing where data is located on the chart canvas (an xy-plane).
src/Data/Path/Parser.hs view
@@ -9,7 +9,6 @@     parsePath,     pathParser,     command,-    manyComma,     svgToPathData,     pathDataToSvg,     PathCommand (..),@@ -22,16 +21,41 @@ import Control.Applicative hiding (many, optional, some, (<|>)) import Control.Monad.State.Lazy import Data.ByteString (ByteString, intercalate)+import Data.Char hiding (isDigit) import Data.FormatN import Data.Path (ArcInfo (ArcInfo), PathData (..)) import Data.Text.Encoding (encodeUtf8)-import FlatParse.Basic (char, optional, (<|>))+import FlatParse.Basic import GHC.Generics import GHC.OverloadedLabels-import MarkupParse.FlatParse import NumHask.Prelude hiding (optional, (<|>)) import Optics.Core hiding ((<|)) +-- * parsing helpers++runParserMaybe :: Parser e a -> ByteString -> Maybe a+runParserMaybe p b = case runParser p b of+  OK r _ -> Just r+  Fail -> Nothing+  Err _ -> Nothing++comma_ :: Parser e ()+comma_ = $(char ',')++ws_ :: Parser e ()+ws_ =+  $( switch+       [|+         case _ of+           " " -> ws_+           "\n" -> ws_+           "\t" -> ws_+           "\r" -> ws_+           "\f" -> ws_+           _ -> pure ()+         |]+   )+ -- | Parse a raw path string. -- -- > :set -XOverloadedStrings@@ -42,7 +66,44 @@ parsePath = runParserMaybe pathParser  commaWsp :: Parser e (Maybe ())-commaWsp = ws_ *> optional MarkupParse.FlatParse.comma <* ws_+commaWsp = ws_ *> optional comma_ <* ws_++minus :: Parser e ()+minus = $(char '-') <|> byteString "¯"++digit :: Parser e Int+digit = (\c -> ord c - ord '0') <$> satisfyAscii isDigit++digits :: Parser e (Int, Int)+digits = do+  (place, n) <- chainr (\n (place, acc) -> (place * 10, acc + place * n)) digit (pure (1, 0))+  case place of+    1 -> empty+    _ -> pure (place, n)++-- A 'Double' parser. does not parse .1 as a double.+double :: Parser e Double+double = do+  (placel, nl) <- digits+  withOption+    ($(char '.') *> digits)+    ( \(placer, nr) ->+        case placel of+          1 -> empty+          _ -> pure $ fromIntegral nl + fromIntegral nr / fromIntegral placer+    )+    ( case placel of+        1 -> empty+        _ -> pure $ fromIntegral nl+    )++-- Parser for a signed prefix to a number. Unlike uiua, this parses '-' as a negative number prefix.+signed :: (Subtractive b) => Parser e b -> Parser e b+signed p = do+  m <- optional minus+  case m of+    Nothing -> p+    Just () -> negate <$> p  num :: Parser e Double num = signed double