-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell bindings to Plotly.js -- -- Generate web-based plots with the Plotly.js library. For examples, see -- https://glutamate.github.io/plotlyhs/ @package plotlyhs @version 0.2 -- | Helper functions for defining valid JSON instances module Graphics.Plotly.Utils unLens :: String -> String dropInitial :: String -> String -> String rename :: String -> String -> String -> String jsonOptions :: Options -- | This module defines datatypes that can be used to generate -- Plotly.js plots via their JSON values. The interface encourages -- the use of lenses. Every trace on a plot is defined by a Trace -- type value, the construction of which is the central goal of this -- module. -- -- Example scatter plot of the Iris dataset: -- --
-- import Graphics.Plotly -- import Numeric.Dataset.Iris -- -- tr :: Trace -- tr = scatter & x ?~ map sepalLength iris -- & y ?~ map sepalWidth iris -- & marker ?~ (defMarker & markercolor ?~ catColors (map irisClass irisd)) -- & mode ?~ [Markers] ---- -- Horizontal bars: -- --
-- hbarData :: [(Text, Double)]
-- hbarData = [("Simon", 14.5), ("Joe", 18.9), ("Dorothy", 16.2)]
--
-- hbarsTrace :: Trace
-- hbarsTrace = bars & ytext ?~ map fst hbarData
-- & x ?~ map snd hbarData
-- & orientation ?~ Horizontal
--
--
-- see Graphics.Plotly.Lucid for helper functions that turn traces into
-- HTML.
module Graphics.Plotly.Base
-- | How should traces be drawn? (lines or markers)
data Mode
Markers :: Mode
Lines :: Mode
-- | What kind of plot type are we building - scatter (inluding line plots)
-- or bars?
data TraceType
Scatter :: TraceType
Bar :: TraceType
-- | A color specification, either as a concrete RGB/RGBA value or a color
-- per point.
data Color
-- | use this RGBA color for every point in the trace
ColRGBA :: Int -> Int -> Int -> Int -> Color
-- | use this RGB color for every point in the trace
ColRGB :: Int -> Int -> Int -> Color
-- | use a different color index for each point
ColIx :: Int -> Color
-- | Assign colors based on any categorical value
catColors :: Eq a => [a] -> ListOrElem Value
-- | Different types of markers
data Symbol
Circle :: Symbol
Square :: Symbol
Diamond :: Symbol
Cross :: Symbol
data ListOrElem a
List :: [a] -> ListOrElem a
All :: a -> ListOrElem a
-- | Marker specification
data Marker
Marker :: Maybe (ListOrElem Value) -> Maybe (ListOrElem Value) -> Maybe Symbol -> Maybe Double -> Marker
[_size] :: Marker -> Maybe (ListOrElem Value)
[_markercolor] :: Marker -> Maybe (ListOrElem Value)
[_symbol] :: Marker -> Maybe Symbol
[_opacity] :: Marker -> Maybe Double
symbol :: Lens' Marker (Maybe Symbol)
size :: Lens' Marker (Maybe (ListOrElem Value))
opacity :: Lens' Marker (Maybe Double)
markercolor :: Lens' Marker (Maybe (ListOrElem Value))
-- | default marker specification
defMarker :: Marker
-- | Dash type specification
data Dash
Solid :: Dash
Dashdot :: Dash
Dot :: Dash
-- | Horizontal or Vertical orientation of bars
data Orientation
Horizontal :: Orientation
Vertical :: Orientation
-- | Are we filling area plots from the zero line or to the next Y value?
data Fill
ToZeroY :: Fill
ToNextY :: Fill
-- | line specification
data Line
Line :: Maybe Double -> Maybe Color -> Maybe Dash -> Line
[_linewidth] :: Line -> Maybe Double
[_linecolor] :: Line -> Maybe Color
[_dash] :: Line -> Maybe Dash
linewidth :: Lens' Line (Maybe Double)
linecolor :: Lens' Line (Maybe Color)
dash :: Lens' Line (Maybe Dash)
defLine :: Line
-- | A Trace is the component of a plot. Multiple traces can be
-- superimposed.
data Trace
Trace :: Maybe [Value] -> Maybe [Value] -> Maybe [Mode] -> Maybe Text -> Maybe [Text] -> TraceType -> Maybe Marker -> Maybe Line -> Maybe Fill -> Maybe Orientation -> Trace
-- | x values, as numbers
[_x] :: Trace -> Maybe [Value]
-- | y values, as numbers
[_y] :: Trace -> Maybe [Value]
-- | select one or two modes.
[_mode] :: Trace -> Maybe [Mode]
-- | name of this trace, for legend
[_name] :: Trace -> Maybe Text
[_text] :: Trace -> Maybe [Text]
[_tracetype] :: Trace -> TraceType
[_marker] :: Trace -> Maybe Marker
[_line] :: Trace -> Maybe Line
[_fill] :: Trace -> Maybe Fill
[_orientation] :: Trace -> Maybe Orientation
y :: Lens' Trace (Maybe [Value])
x :: Lens' Trace (Maybe [Value])
tracetype :: Lens' Trace TraceType
text :: Lens' Trace (Maybe [Text])
orientation :: Lens' Trace (Maybe Orientation)
name :: Lens' Trace (Maybe Text)
mode :: Lens' Trace (Maybe [Mode])
marker :: Lens' Trace (Maybe Marker)
line :: Lens' Trace (Maybe Line)
fill :: Lens' Trace (Maybe Fill)
-- | an empty scatter plot
scatter :: Trace
-- | an empty bar plot
bars :: Trace
-- | Options for axes
data Axis
Axis :: Maybe (Double, Double) -> Maybe Text -> Maybe Bool -> Maybe Bool -> Axis
[_range] :: Axis -> Maybe (Double, Double)
[_axistitle] :: Axis -> Maybe Text
[_showgrid] :: Axis -> Maybe Bool
[_zeroline] :: Axis -> Maybe Bool
zeroline :: Lens' Axis (Maybe Bool)
showgrid :: Lens' Axis (Maybe Bool)
range :: Lens' Axis (Maybe (Double, Double))
axistitle :: Lens' Axis (Maybe Text)
defAxis :: Axis
-- | How different bar traces be superimposed? By grouping or by stacking?
data Barmode
Stack :: Barmode
Group :: Barmode
-- | Options for Margins.
data Margin
Margin :: Int -> Int -> Int -> Int -> Int -> Margin
[_marginl] :: Margin -> Int
[_marginr] :: Margin -> Int
[_marginb] :: Margin -> Int
[_margint] :: Margin -> Int
[_marginpad] :: Margin -> Int
margint :: Lens' Margin Int
marginr :: Lens' Margin Int
marginpad :: Lens' Margin Int
marginl :: Lens' Margin Int
marginb :: Lens' Margin Int
-- | some good values for margins
thinMargins :: Margin
-- | some good values for margins
titleMargins :: Margin
-- | options for the layout of the whole plot
data Layout
Layout :: Maybe Axis -> Maybe Axis -> Maybe Text -> Maybe Bool -> Maybe Int -> Maybe Int -> Maybe Barmode -> Maybe Margin -> Layout
[_xaxis] :: Layout -> Maybe Axis
[_yaxis] :: Layout -> Maybe Axis
[_title] :: Layout -> Maybe Text
[_showlegend] :: Layout -> Maybe Bool
[_height] :: Layout -> Maybe Int
[_width] :: Layout -> Maybe Int
[_barmode] :: Layout -> Maybe Barmode
[_margin] :: Layout -> Maybe Margin
yaxis :: Lens' Layout (Maybe Axis)
xaxis :: Lens' Layout (Maybe Axis)
width :: Lens' Layout (Maybe Int)
title :: Lens' Layout (Maybe Text)
showlegend :: Lens' Layout (Maybe Bool)
margin :: Lens' Layout (Maybe Margin)
height :: Lens' Layout (Maybe Int)
barmode :: Lens' Layout (Maybe Barmode)
-- | a defaultlayout
defLayout :: Layout
-- | A helper record which represents the whole plot
data Plotly
Plotly :: Text -> [Trace] -> Layout -> Plotly
[_elemid] :: Plotly -> Text
[_traces] :: Plotly -> [Trace]
[_layout] :: Plotly -> Layout
traces :: Lens' Plotly [Trace]
layout :: Lens' Plotly Layout
elemid :: Lens' Plotly Text
-- | helper function for building the plot.
plotly :: Text -> [Trace] -> Plotly
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Layout
instance GHC.Generics.Generic Graphics.Plotly.Base.Layout
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Margin
instance GHC.Generics.Generic Graphics.Plotly.Base.Margin
instance GHC.Show.Show Graphics.Plotly.Base.Barmode
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Axis
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Barmode
instance GHC.Generics.Generic Graphics.Plotly.Base.Axis
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Trace
instance GHC.Generics.Generic Graphics.Plotly.Base.Trace
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Line
instance GHC.Generics.Generic Graphics.Plotly.Base.Line
instance GHC.Show.Show Graphics.Plotly.Base.Fill
instance GHC.Show.Show Graphics.Plotly.Base.Dash
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Marker
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Dash
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Orientation
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Fill
instance GHC.Classes.Eq Graphics.Plotly.Base.Marker
instance GHC.Generics.Generic Graphics.Plotly.Base.Marker
instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Plotly.Base.ListOrElem a)
instance GHC.Classes.Eq Graphics.Plotly.Base.Symbol
instance GHC.Show.Show Graphics.Plotly.Base.Symbol
instance GHC.Show.Show Graphics.Plotly.Base.TraceType
instance GHC.Show.Show Graphics.Plotly.Base.Mode
instance Data.Aeson.Types.ToJSON.ToJSON [Graphics.Plotly.Base.Mode]
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.TraceType
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Color
instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Symbol
instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.Base.ListOrElem a)
-- | Plot traces to html using blaze-html
--
-- Example code:
--
-- -- plotHtml :: Html () -- plotHtml = toHtml $ plotly "myDiv" [trace] & layout . title ?~ "my plot" -- & layout . width ?~ 300 ---- -- where trace is a value of type Trace module Graphics.Plotly.Blaze -- | script tag to go in the header to import the plotly.js -- javascript from the official CDN plotlyCDN :: Html -- | Activate a plot defined by a Plotly value plotlyJS :: Plotly -> Html -- | Create a div for a Plotly value plotlyDiv :: Plotly -> Html instance Text.Blaze.ToMarkup Graphics.Plotly.Base.Plotly -- | A limited Grammar of Graphics-like interface. -- --
-- myPts :: [(Double, Double)] -- myPts = [(1,2), (1.2, 3), (1.4,3.5)] -- -- -- -- myTrace :: Trace -- myTrace = points (aes & x .~ fst -- & y .~ snd) -- myPts --module Graphics.Plotly.GoG class ToJSON a => AxisValue a data RGB a RGB :: a -> a -> a -> RGB a data RGBA a RGBA :: a -> a -> a -> a -> RGBA a class ToJSON a => IsColor a data Aes t a Aes :: (a -> XVal t) -> (a -> YVal t) -> Maybe (a -> CVal t) -> Maybe (a -> SVal t) -> Aes t a [_x] :: Aes t a -> (a -> XVal t) [_y] :: Aes t a -> (a -> YVal t) [_color] :: Aes t a -> Maybe (a -> CVal t) [_size] :: Aes t a -> Maybe (a -> SVal t) aes :: Aes ((), (), (), ()) a setx :: AxisValue v => Aes (vx, vy, vc, vs) a -> (a -> v) -> Aes (v, vy, vc, vs) a x :: AxisValue v => Lens (Aes (vx, vy, vc, vs) a) (Aes (v, vy, vc, vs) a) (a -> vx) (a -> v) sety :: AxisValue v => Aes (vx, vy, vc, vs) a -> (a -> v) -> Aes (vx, v, vc, vs) a y :: AxisValue v => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, v, vc, vs) a) (a -> vy) (a -> v) setcol :: IsColor v => Aes (vx, vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, v, vs) a color :: IsColor v => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, vy, v, vs) a) (Maybe (a -> vc)) (Maybe (a -> v)) setsize :: (AxisValue v, Num v) => Aes (vx, vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, vc, v) a size :: (AxisValue v, Num v) => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, vy, vc, v) a) (Maybe (a -> vs)) (Maybe (a -> v)) points :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t), ToJSON (CVal t), ToJSON (SVal t)) => Aes t a -> [a] -> Trace line :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t)) => Aes t a -> [a] -> Trace hbars :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t)) => Aes t a -> [a] -> Trace instance Graphics.Plotly.GoG.AxisValue GHC.Types.Double instance Graphics.Plotly.GoG.AxisValue GHC.Types.Float instance Graphics.Plotly.GoG.AxisValue Data.Text.Internal.Text instance Graphics.Plotly.GoG.AxisValue GHC.Base.String instance Graphics.Plotly.GoG.AxisValue GHC.Types.Int instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGB GHC.Types.Int) instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGB GHC.Types.Double) instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGBA GHC.Types.Int) instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGBA GHC.Types.Double) instance Graphics.Plotly.GoG.IsColor GHC.Types.Int instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGB GHC.Types.Int) instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGB GHC.Types.Double) instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGBA GHC.Types.Int) instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGBA GHC.Types.Double) -- | Simple histograms module Graphics.Plotly.Histogram -- | build a histogram with a given binsize histogram :: Int -> [Double] -> Trace -- | Plot traces to html using lucid -- -- Example code: -- --
-- plotHtml :: Html () -- plotHtml = toHtml $ plotly "myDiv" [trace] & layout . title ?~ "my plot" -- & layout . width ?~ 300 ---- -- where trace is a value of type Trace module Graphics.Plotly.Lucid -- | script tag to go in the header to import the plotly.js -- javascript from the official CDN plotlyCDN :: Monad m => HtmlT m () -- | Activate a plot defined by a Plotly value plotlyJS :: Monad m => Plotly -> HtmlT m () -- | Create a div for a Plotly value plotlyDiv :: Monad m => Plotly -> HtmlT m () instance Lucid.Base.ToHtml Graphics.Plotly.Base.Plotly -- | Functions to build Traces from standard data. Generated traces can -- still be customized with lenses module Graphics.Plotly.Simple -- | Generate a scatterplot from pairs scatterPlot :: [(Double, Double)] -> Trace -- | Generate a line plot from pairs linePlot :: [(Double, Double)] -> Trace -- | Generate a horizontal bar chart from pairs of text and value. hbarChart :: [(Text, Double)] -> Trace -- | Generate a fan plot with a given width in standard deviations and -- (x,(y,sd)) data fanPlot :: Double -> [(Double, (Double, Double))] -> Trace -- | Re-exports the Simple interface, the grammar of grpahics interface and -- parts of the base interface. module Graphics.Plotly