module Graphics.Rendering.Plot.Figure (
module Data.Colour.Names
, Figure(), FigureState()
, withTextDefaults
, withLineDefaults
, withPointDefaults
, withBarDefaults
, newFigure
, setBackgroundColour
, setFigurePadding
, withTitle
, withSubTitle
, setPlots
, withPlot, withPlots
, Plot()
, setPlotBackgroundColour
, Border
, setBorder
, setPlotPadding
, withHeading
, Function(), VectorFunction(), Series(), MinMaxSeries(), ErrorSeries()
, Surface()
, SeriesLabel()
, Abscissa(), Ordinate(), Dataset()
, FormattedSeries(), SeriesType(..)
, line, point, linepoint
, impulse, step
, area
, bar
, hist
, candle, whisker
, setDataset
, Location, Head, Fill
, Annote()
, arrow
, oval
, rect
, glyph
, text
, cairo
, withAnnotations
, setSeriesType
, setAllSeriesTypes
, PlotFormats()
, withSeriesFormat
, withAllSeriesFormats
, Scale(..)
, setRange
, setRangeFromData
, Axis
, AxisType(..),AxisSide(..),AxisPosn(..)
, clearAxes
, clearAxis
, addAxis
, withAxis
, BarSetting(..)
, barSetting
, SampleData
, sampleData
, Legend
, LegendBorder
, LegendLocation(..), LegendOrientation(..)
, clearLegend
, setLegend
, withLegendFormat
, Tick(..), TickValues(..), GridLines
, TickFormat(..)
, setTicks
, setGridlines
, setTickLabelFormat
, setTickLabels
, withTickLabelsFormat
, withAxisLabel
, withAxisLine
, withGridLine
, Line(), LineFormat()
, DashStyle,Dash(..),LineWidth
, clearLineFormat
, setDashStyle
, setLineWidth
, setLineColour
, Point(), PointFormat()
, Glyph(..)
, PointSize
, setGlyph
, setPointSize
, setPointColour
, Bar(), BarFormat()
, clearBarFormat
, setBarWidth
, setBarColour
, setBarBorderWidth
, setBarBorderColour
, Text()
, FontFamily,FontSize,Color
, clearText
, clearTextFormat
, setText
, setFontFamily
, setFontStyle
, setFontVariant
, setFontWeight
, setFontStretch
, setFontSize
, setFontColour
) where
import Data.Colour.Names
import qualified Data.Array.IArray as A
import Prelude hiding(min,max)
import Graphics.Rendering.Plot.Figure.Text
import Graphics.Rendering.Plot.Figure.Line
import Graphics.Rendering.Plot.Figure.Point
import Graphics.Rendering.Plot.Figure.Bar
import Graphics.Rendering.Plot.Figure.Plot
import Graphics.Rendering.Plot.Types
import Graphics.Rendering.Plot.Defaults
withTextDefaults :: Text () -> Figure ()
withTextDefaults m = do
o <- getDefaults
let to' = _textoptions o
let (FontText to _) = execText m to' (FontText to' "")
modifyDefaults $ \s -> s { _textoptions = to }
withLineDefaults :: Line () -> Figure ()
withLineDefaults m = do
o <- getDefaults
let lo' = _lineoptions o
let (TypeLine lo _) = execLine m lo' (TypeLine lo' black)
modifyDefaults $ \s -> s { _lineoptions = lo }
withPointDefaults :: Point () -> Figure ()
withPointDefaults m = do
o <- getDefaults
let po' = _pointoptions o
let (FullPoint po _) = execPoint m po' (FullPoint po' defaultGlyph)
modifyDefaults $ \s -> s { _pointoptions = po }
withBarDefaults :: Bar () -> Figure ()
withBarDefaults m = do
o <- getDefaults
let bo' = _baroptions o
let (TypeBar bo _) = execBar m bo' (TypeBar bo' black)
modifyDefaults $ \s -> s { _baroptions = bo }
newFigure :: Figure ()
newFigure = putFigure $ Figure defaultFigureBackgroundColour
defaultFigurePadding NoText NoText
(A.listArray ((1,1),(1,1)) [Nothing])
setBackgroundColour :: Color -> Figure ()
setBackgroundColour c = modifyFigure $ \s -> s { _back_clr = c }
setFigurePadding :: Double -> Double -> Double -> Double -> Figure ()
setFigurePadding l r b t = modifyFigure $ \s ->
s { _fig_pads = Padding l r b t }
withTitle :: Text () -> Figure ()
withTitle m = do
o <- getDefaults
modifyFigure $ \s ->
s { _title = execText m (_textoptions o) (_title s) }
withSubTitle :: Text () -> Figure ()
withSubTitle m = do
o <- getDefaults
modifyFigure $ \s ->
s { _subtitle = execText m (_textoptions o) (_title s) }
setPlots :: Int
-> Int
-> Figure ()
setPlots r c = modifyFigure $ \s ->
s { _plots = A.listArray ((1,1),(r,c))
(replicate (r*c) Nothing) }
withPlot :: (Int,Int) -> Plot () -> Figure ()
withPlot i m = do
o <- getDefaults
s <- getSupplies
modifyFigure $ \p ->
p { _plots = let plots = _plots p
plot' = plots A.! i
plot = case plot' of
Nothing -> emptyPlot
Just p' -> p'
in plots A.// [(i,Just $ execPlot m s o plot)] }
withPlots :: Plot () -> Figure ()
withPlots m = do
o <- getDefaults
s <- getSupplies
modifyFigure $ \p ->
p { _plots = let plots = _plots p
plot p' = case p' of
Nothing -> emptyPlot
Just p'' -> p''
in plots A.// map (\(i,e) ->
(i,Just $ execPlot m s o (plot e))) (A.assocs plots) }