module Simulation.Aivika.Experiment.Chart.Backend.Diagrams
(DiagramsRenderer(..)) where
import System.FilePath
import Data.Map
import Data.Colour
import Data.Colour.Names
import Control.Lens
import Graphics.Rendering.Chart
import Graphics.Rendering.Chart.Backend.Diagrams
import Simulation.Aivika.Experiment
import Simulation.Aivika.Experiment.Chart
data DiagramsRenderer =
DiagramsRenderer { rendererFileFormat :: FileFormat,
rendererCustomFonts :: IO (FontSelector Double)
}
instance ChartRendering DiagramsRenderer where
renderableChartExtension (DiagramsRenderer EPS _) = ".eps"
renderableChartExtension (DiagramsRenderer SVG _) = ".svg"
renderableChartExtension (DiagramsRenderer SVG_EMBEDDED _) = ".svg"
renderChart (DiagramsRenderer format fonts) (width, height) =
renderableToFile (FileOptions (fromIntegral width, fromIntegral height) format fonts)
renderingLayout (DiagramsRenderer _ _) = defaultLayout
renderingLayoutLR (DiagramsRenderer _ _) = defaultLayoutLR
defaultFontStyle :: FontStyle
defaultFontStyle =
FontStyle "serif" 16 FontSlantNormal FontWeightNormal (opaque black)
defaultTitleFontStyle :: FontStyle
defaultTitleFontStyle =
FontStyle "serif" 20 FontSlantNormal FontWeightBold (opaque black)
defaultLayoutLR :: LayoutLR Double Double Double -> LayoutLR Double Double Double
defaultLayoutLR layoutlr =
layoutlr_title_style .~ defaultTitleFontStyle $
layoutlr_all_font_styles .~ defaultFontStyle $
layoutlr
defaultLayout :: Layout Double Double -> Layout Double Double
defaultLayout layout =
layout_title_style .~ defaultTitleFontStyle $
layout_all_font_styles .~ defaultFontStyle $
layout