hvega-theme 0.1.0.1 → 0.2.0.0
raw patch · 2 files changed
+39/−34 lines, 2 filesdep ~hvega
Dependency ranges changed: hvega
Files
- hvega-theme.cabal +3/−3
- src/Graphics/Vega/VegaLite/Theme.hs +36/−31
hvega-theme.cabal view
@@ -1,5 +1,5 @@ name: hvega-theme-version: 0.1.0.1+version: 0.2.0.0 synopsis: Theme for hvega. description: A professional theme for publication quality figures. homepage: http://github.com/GregorySchwartz/hvega-theme#readme@@ -7,7 +7,7 @@ license-file: LICENSE author: Gregory W. Schwartz maintainer: gsch@pennmedicine.upenn.edu-copyright: 2019 Gregory W. Schwartz+copyright: 2020 Gregory W. Schwartz category: Graphics build-type: Simple -- extra-source-files:@@ -17,7 +17,7 @@ hs-source-dirs: src exposed-modules: Graphics.Vega.VegaLite.Theme build-depends: base >= 4.7 && < 5- , hvega+ , hvega >= 0.7.0.1 , text ghc-options: -O2 default-language: Haskell2010
src/Graphics/Vega/VegaLite/Theme.hs view
@@ -12,63 +12,68 @@ ) where -- Remote+import Data.Maybe (catMaybes) import Graphics.Vega.VegaLite import qualified Data.Text as T -- Local -data Config = Config { configFontSize :: Double+data Config = Config { configFontSize :: Maybe Double , configFont :: T.Text , configLabelFont :: T.Text , configAxisColor :: T.Text- , configHeight :: Double- , configWidth :: Double+ , configHeight :: Maybe Double+ , configWidth :: Maybe Double } defaultConfig :: Config-defaultConfig = Config { configFontSize = 12+defaultConfig = Config { configFontSize = Nothing , configFont = "Arial" , configLabelFont = "Arial" , configAxisColor = "#000000"- , configHeight = 300- , configWidth = 400+ , configHeight = Nothing+ , configWidth = Nothing } -theme :: Config -> [LabelledSpec] -> (VLProperty, VLSpec)+theme :: Config -> [ConfigureSpec] -> (VLProperty, VLSpec) theme c = configure- . configuration (View $ viewConfig c)- . configuration (Legend $ legendConfig c)+ . configuration (ViewStyle $ viewConfig c)+ . configuration (LegendStyle $ legendConfig c) . configuration (TitleStyle $ titleConfig c) . configuration (Axis $ axisConfig c) . configuration (AxisX $ axisConfig c) . configuration (AxisY $ axisConfig c) viewConfig :: Config -> [ViewConfig]-viewConfig c = [ ViewHeight (configHeight c) -- 80 for publishing- , ViewWidth (configWidth c) -- 100 for publishing- , StrokeOpacity 0 -- Despine- ]+viewConfig c = catMaybes+ [ fmap ViewContinuousHeight (configHeight c) -- 80 for publishing+ , fmap ViewContinuousWidth (configWidth c) -- 100 for publishing+ , Just $ ViewStrokeOpacity 0 -- Despine+ ] legendConfig :: Config -> [LegendConfig]-legendConfig c = [ LeLabelFontSize (configFontSize c)- , LeTitleFontSize (configFontSize c)- ]+legendConfig c = catMaybes+ [ fmap LeLabelFontSize (configFontSize c)+ , fmap LeTitleFontSize (configFontSize c)+ ] titleConfig :: Config -> [TitleConfig]-titleConfig c = [ TFontSize (configFontSize c)- , TFont (configFont c)- , TColor "#000000"- , TFontWeight Normal- ]+titleConfig c = catMaybes+ [ fmap TFontSize (configFontSize c)+ , Just $ TFont (configFont c)+ , Just $ TColor "#000000"+ , Just $ TFontWeight Normal+ ] axisConfig :: Config -> [AxisConfig]-axisConfig c = [ Grid False- , DomainColor "#000000"- , LabelFont (configLabelFont c)- , LabelFontSize (configFontSize c)- , LabelAngle 0- , TickColor (configAxisColor c)- , TitleFont (configFont c)- , TitleFontSize (configFontSize c)- , TitleFontWeight Normal- ]+axisConfig c = catMaybes+ [ Just $ Grid False+ , Just $ DomainColor "#000000"+ , Just $ LabelFont (configLabelFont c)+ , fmap LabelFontSize (configFontSize c)+ , Just $ LabelAngle 0+ , Just $ TickColor (configAxisColor c)+ , Just $ TitleFont (configFont c)+ , fmap TitleFontSize (configFontSize c)+ , Just $ TitleFontWeight Normal+ ]