plotlyhs 0.1.0 → 0.2
raw patch · 10 files changed
+462/−286 lines, 10 filesdep −plotlyhsdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies removed: plotlyhs
Dependency ranges changed: base
API changes (from Hackage documentation)
- Graphics.Plotly: Axis :: Maybe (Double, Double) -> Maybe Text -> Maybe Bool -> Maybe Bool -> Axis
- Graphics.Plotly: Bar :: TraceType
- Graphics.Plotly: Circle :: Symbol
- Graphics.Plotly: ColIxs :: [Int] -> Color
- Graphics.Plotly: Cols :: [Color] -> Color
- Graphics.Plotly: Cross :: Symbol
- Graphics.Plotly: Dashdot :: Dash
- Graphics.Plotly: Diamond :: Symbol
- Graphics.Plotly: Dot :: Dash
- Graphics.Plotly: Group :: Barmode
- Graphics.Plotly: Horizontal :: Orientation
- Graphics.Plotly: Layout :: Maybe Axis -> Maybe Axis -> Maybe Text -> Maybe Bool -> Maybe Int -> Maybe Int -> Maybe Barmode -> Maybe Margin -> Layout
- Graphics.Plotly: Line :: Maybe Double -> Maybe Color -> Maybe Dash -> Line
- Graphics.Plotly: Lines :: Mode
- Graphics.Plotly: Margin :: Int -> Int -> Int -> Int -> Int -> Margin
- Graphics.Plotly: Marker :: Maybe Int -> Maybe Color -> Maybe Symbol -> Maybe Double -> Marker
- Graphics.Plotly: Markers :: Mode
- Graphics.Plotly: Plotly :: Text -> [Trace] -> Layout -> Plotly
- Graphics.Plotly: RGB :: Int -> Int -> Int -> Color
- Graphics.Plotly: RGBA :: Int -> Int -> Int -> Int -> Color
- Graphics.Plotly: Scatter :: TraceType
- Graphics.Plotly: Solid :: Dash
- Graphics.Plotly: Square :: Symbol
- Graphics.Plotly: Stack :: Barmode
- Graphics.Plotly: ToNextY :: Fill
- Graphics.Plotly: ToZeroY :: Fill
- Graphics.Plotly: Trace :: Maybe [Double] -> Maybe [Double] -> Maybe [Text] -> Maybe [Text] -> Maybe [Mode] -> Maybe Text -> Maybe [Text] -> TraceType -> Maybe Marker -> Maybe Line -> Maybe Fill -> Maybe Orientation -> Trace
- Graphics.Plotly: Vertical :: Orientation
- Graphics.Plotly: [_axistitle] :: Axis -> Maybe Text
- Graphics.Plotly: [_barmode] :: Layout -> Maybe Barmode
- Graphics.Plotly: [_dash] :: Line -> Maybe Dash
- Graphics.Plotly: [_elemid] :: Plotly -> Text
- Graphics.Plotly: [_fill] :: Trace -> Maybe Fill
- Graphics.Plotly: [_height] :: Layout -> Maybe Int
- Graphics.Plotly: [_layout] :: Plotly -> Layout
- Graphics.Plotly: [_line] :: Trace -> Maybe Line
- Graphics.Plotly: [_linecolor] :: Line -> Maybe Color
- Graphics.Plotly: [_linewidth] :: Line -> Maybe Double
- Graphics.Plotly: [_margin] :: Layout -> Maybe Margin
- Graphics.Plotly: [_marginb] :: Margin -> Int
- Graphics.Plotly: [_marginl] :: Margin -> Int
- Graphics.Plotly: [_marginpad] :: Margin -> Int
- Graphics.Plotly: [_marginr] :: Margin -> Int
- Graphics.Plotly: [_margint] :: Margin -> Int
- Graphics.Plotly: [_marker] :: Trace -> Maybe Marker
- Graphics.Plotly: [_markercolor] :: Marker -> Maybe Color
- Graphics.Plotly: [_mode] :: Trace -> Maybe [Mode]
- Graphics.Plotly: [_name] :: Trace -> Maybe Text
- Graphics.Plotly: [_opacity] :: Marker -> Maybe Double
- Graphics.Plotly: [_orientation] :: Trace -> Maybe Orientation
- Graphics.Plotly: [_range] :: Axis -> Maybe (Double, Double)
- Graphics.Plotly: [_showgrid] :: Axis -> Maybe Bool
- Graphics.Plotly: [_showlegend] :: Layout -> Maybe Bool
- Graphics.Plotly: [_size] :: Marker -> Maybe Int
- Graphics.Plotly: [_symbol] :: Marker -> Maybe Symbol
- Graphics.Plotly: [_text] :: Trace -> Maybe [Text]
- Graphics.Plotly: [_title] :: Layout -> Maybe Text
- Graphics.Plotly: [_traces] :: Plotly -> [Trace]
- Graphics.Plotly: [_tracetype] :: Trace -> TraceType
- Graphics.Plotly: [_width] :: Layout -> Maybe Int
- Graphics.Plotly: [_x] :: Trace -> Maybe [Double]
- Graphics.Plotly: [_xaxis] :: Layout -> Maybe Axis
- Graphics.Plotly: [_xtext] :: Trace -> Maybe [Text]
- Graphics.Plotly: [_y] :: Trace -> Maybe [Double]
- Graphics.Plotly: [_yaxis] :: Layout -> Maybe Axis
- Graphics.Plotly: [_ytext] :: Trace -> Maybe [Text]
- Graphics.Plotly: [_zeroline] :: Axis -> Maybe Bool
- Graphics.Plotly: axistitle :: Lens' Axis (Maybe Text)
- Graphics.Plotly: barmode :: Lens' Layout (Maybe Barmode)
- Graphics.Plotly: bars :: Trace
- Graphics.Plotly: catColors :: Eq a => [a] -> Color
- Graphics.Plotly: dash :: Lens' Line (Maybe Dash)
- Graphics.Plotly: data Axis
- Graphics.Plotly: data Barmode
- Graphics.Plotly: data Color
- Graphics.Plotly: data Dash
- Graphics.Plotly: data Fill
- Graphics.Plotly: data Layout
- Graphics.Plotly: data Line
- Graphics.Plotly: data Margin
- Graphics.Plotly: data Marker
- Graphics.Plotly: data Mode
- Graphics.Plotly: data Orientation
- Graphics.Plotly: data Plotly
- Graphics.Plotly: data Symbol
- Graphics.Plotly: data Trace
- Graphics.Plotly: data TraceType
- Graphics.Plotly: defAxis :: Axis
- Graphics.Plotly: defLayout :: Layout
- Graphics.Plotly: defLine :: Line
- Graphics.Plotly: defMarker :: Marker
- Graphics.Plotly: elemid :: Lens' Plotly Text
- Graphics.Plotly: fill :: Lens' Trace (Maybe Fill)
- Graphics.Plotly: height :: Lens' Layout (Maybe Int)
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Axis
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Barmode
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Color
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Dash
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Fill
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Layout
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Line
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Margin
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Marker
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Orientation
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Symbol
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Trace
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.TraceType
- Graphics.Plotly: instance Data.Aeson.Types.ToJSON.ToJSON [Graphics.Plotly.Mode]
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Axis
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Layout
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Line
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Margin
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Marker
- Graphics.Plotly: instance GHC.Generics.Generic Graphics.Plotly.Trace
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.Barmode
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.Dash
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.Fill
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.Mode
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.Symbol
- Graphics.Plotly: instance GHC.Show.Show Graphics.Plotly.TraceType
- Graphics.Plotly: layout :: Lens' Plotly Layout
- Graphics.Plotly: line :: Lens' Trace (Maybe Line)
- Graphics.Plotly: linecolor :: Lens' Line (Maybe Color)
- Graphics.Plotly: linewidth :: Lens' Line (Maybe Double)
- Graphics.Plotly: margin :: Lens' Layout (Maybe Margin)
- Graphics.Plotly: marginb :: Lens' Margin Int
- Graphics.Plotly: marginl :: Lens' Margin Int
- Graphics.Plotly: marginpad :: Lens' Margin Int
- Graphics.Plotly: marginr :: Lens' Margin Int
- Graphics.Plotly: margint :: Lens' Margin Int
- Graphics.Plotly: marker :: Lens' Trace (Maybe Marker)
- Graphics.Plotly: markercolor :: Lens' Marker (Maybe Color)
- Graphics.Plotly: mode :: Lens' Trace (Maybe [Mode])
- Graphics.Plotly: name :: Lens' Trace (Maybe Text)
- Graphics.Plotly: opacity :: Lens' Marker (Maybe Double)
- Graphics.Plotly: orientation :: Lens' Trace (Maybe Orientation)
- Graphics.Plotly: plotly :: Text -> [Trace] -> Plotly
- Graphics.Plotly: range :: Lens' Axis (Maybe (Double, Double))
- Graphics.Plotly: scatter :: Trace
- Graphics.Plotly: showgrid :: Lens' Axis (Maybe Bool)
- Graphics.Plotly: showlegend :: Lens' Layout (Maybe Bool)
- Graphics.Plotly: size :: Lens' Marker (Maybe Int)
- Graphics.Plotly: symbol :: Lens' Marker (Maybe Symbol)
- Graphics.Plotly: text :: Lens' Trace (Maybe [Text])
- Graphics.Plotly: thinMargins :: Margin
- Graphics.Plotly: title :: Lens' Layout (Maybe Text)
- Graphics.Plotly: titleMargins :: Margin
- Graphics.Plotly: traces :: Lens' Plotly [Trace]
- Graphics.Plotly: tracetype :: Lens' Trace TraceType
- Graphics.Plotly: width :: Lens' Layout (Maybe Int)
- Graphics.Plotly: x :: Lens' Trace (Maybe [Double])
- Graphics.Plotly: xaxis :: Lens' Layout (Maybe Axis)
- Graphics.Plotly: xtext :: Lens' Trace (Maybe [Text])
- Graphics.Plotly: y :: Lens' Trace (Maybe [Double])
- Graphics.Plotly: yaxis :: Lens' Layout (Maybe Axis)
- Graphics.Plotly: ytext :: Lens' Trace (Maybe [Text])
- Graphics.Plotly: zeroline :: Lens' Axis (Maybe Bool)
- Graphics.Plotly.Blaze: instance Text.Blaze.ToMarkup Graphics.Plotly.Plotly
- Graphics.Plotly.Lucid: instance Lucid.Base.ToHtml Graphics.Plotly.Plotly
+ Graphics.Plotly.Base: All :: a -> ListOrElem a
+ Graphics.Plotly.Base: Axis :: Maybe (Double, Double) -> Maybe Text -> Maybe Bool -> Maybe Bool -> Axis
+ Graphics.Plotly.Base: Bar :: TraceType
+ Graphics.Plotly.Base: Circle :: Symbol
+ Graphics.Plotly.Base: ColIx :: Int -> Color
+ Graphics.Plotly.Base: ColRGB :: Int -> Int -> Int -> Color
+ Graphics.Plotly.Base: ColRGBA :: Int -> Int -> Int -> Int -> Color
+ Graphics.Plotly.Base: Cross :: Symbol
+ Graphics.Plotly.Base: Dashdot :: Dash
+ Graphics.Plotly.Base: Diamond :: Symbol
+ Graphics.Plotly.Base: Dot :: Dash
+ Graphics.Plotly.Base: Group :: Barmode
+ Graphics.Plotly.Base: Horizontal :: Orientation
+ Graphics.Plotly.Base: Layout :: Maybe Axis -> Maybe Axis -> Maybe Text -> Maybe Bool -> Maybe Int -> Maybe Int -> Maybe Barmode -> Maybe Margin -> Layout
+ Graphics.Plotly.Base: Line :: Maybe Double -> Maybe Color -> Maybe Dash -> Line
+ Graphics.Plotly.Base: Lines :: Mode
+ Graphics.Plotly.Base: List :: [a] -> ListOrElem a
+ Graphics.Plotly.Base: Margin :: Int -> Int -> Int -> Int -> Int -> Margin
+ Graphics.Plotly.Base: Marker :: Maybe (ListOrElem Value) -> Maybe (ListOrElem Value) -> Maybe Symbol -> Maybe Double -> Marker
+ Graphics.Plotly.Base: Markers :: Mode
+ Graphics.Plotly.Base: Plotly :: Text -> [Trace] -> Layout -> Plotly
+ Graphics.Plotly.Base: Scatter :: TraceType
+ Graphics.Plotly.Base: Solid :: Dash
+ Graphics.Plotly.Base: Square :: Symbol
+ Graphics.Plotly.Base: Stack :: Barmode
+ Graphics.Plotly.Base: ToNextY :: Fill
+ Graphics.Plotly.Base: ToZeroY :: Fill
+ Graphics.Plotly.Base: Trace :: Maybe [Value] -> Maybe [Value] -> Maybe [Mode] -> Maybe Text -> Maybe [Text] -> TraceType -> Maybe Marker -> Maybe Line -> Maybe Fill -> Maybe Orientation -> Trace
+ Graphics.Plotly.Base: Vertical :: Orientation
+ Graphics.Plotly.Base: [_axistitle] :: Axis -> Maybe Text
+ Graphics.Plotly.Base: [_barmode] :: Layout -> Maybe Barmode
+ Graphics.Plotly.Base: [_dash] :: Line -> Maybe Dash
+ Graphics.Plotly.Base: [_elemid] :: Plotly -> Text
+ Graphics.Plotly.Base: [_fill] :: Trace -> Maybe Fill
+ Graphics.Plotly.Base: [_height] :: Layout -> Maybe Int
+ Graphics.Plotly.Base: [_layout] :: Plotly -> Layout
+ Graphics.Plotly.Base: [_line] :: Trace -> Maybe Line
+ Graphics.Plotly.Base: [_linecolor] :: Line -> Maybe Color
+ Graphics.Plotly.Base: [_linewidth] :: Line -> Maybe Double
+ Graphics.Plotly.Base: [_margin] :: Layout -> Maybe Margin
+ Graphics.Plotly.Base: [_marginb] :: Margin -> Int
+ Graphics.Plotly.Base: [_marginl] :: Margin -> Int
+ Graphics.Plotly.Base: [_marginpad] :: Margin -> Int
+ Graphics.Plotly.Base: [_marginr] :: Margin -> Int
+ Graphics.Plotly.Base: [_margint] :: Margin -> Int
+ Graphics.Plotly.Base: [_marker] :: Trace -> Maybe Marker
+ Graphics.Plotly.Base: [_markercolor] :: Marker -> Maybe (ListOrElem Value)
+ Graphics.Plotly.Base: [_mode] :: Trace -> Maybe [Mode]
+ Graphics.Plotly.Base: [_name] :: Trace -> Maybe Text
+ Graphics.Plotly.Base: [_opacity] :: Marker -> Maybe Double
+ Graphics.Plotly.Base: [_orientation] :: Trace -> Maybe Orientation
+ Graphics.Plotly.Base: [_range] :: Axis -> Maybe (Double, Double)
+ Graphics.Plotly.Base: [_showgrid] :: Axis -> Maybe Bool
+ Graphics.Plotly.Base: [_showlegend] :: Layout -> Maybe Bool
+ Graphics.Plotly.Base: [_size] :: Marker -> Maybe (ListOrElem Value)
+ Graphics.Plotly.Base: [_symbol] :: Marker -> Maybe Symbol
+ Graphics.Plotly.Base: [_text] :: Trace -> Maybe [Text]
+ Graphics.Plotly.Base: [_title] :: Layout -> Maybe Text
+ Graphics.Plotly.Base: [_traces] :: Plotly -> [Trace]
+ Graphics.Plotly.Base: [_tracetype] :: Trace -> TraceType
+ Graphics.Plotly.Base: [_width] :: Layout -> Maybe Int
+ Graphics.Plotly.Base: [_x] :: Trace -> Maybe [Value]
+ Graphics.Plotly.Base: [_xaxis] :: Layout -> Maybe Axis
+ Graphics.Plotly.Base: [_y] :: Trace -> Maybe [Value]
+ Graphics.Plotly.Base: [_yaxis] :: Layout -> Maybe Axis
+ Graphics.Plotly.Base: [_zeroline] :: Axis -> Maybe Bool
+ Graphics.Plotly.Base: axistitle :: Lens' Axis (Maybe Text)
+ Graphics.Plotly.Base: barmode :: Lens' Layout (Maybe Barmode)
+ Graphics.Plotly.Base: bars :: Trace
+ Graphics.Plotly.Base: catColors :: Eq a => [a] -> ListOrElem Value
+ Graphics.Plotly.Base: dash :: Lens' Line (Maybe Dash)
+ Graphics.Plotly.Base: data Axis
+ Graphics.Plotly.Base: data Barmode
+ Graphics.Plotly.Base: data Color
+ Graphics.Plotly.Base: data Dash
+ Graphics.Plotly.Base: data Fill
+ Graphics.Plotly.Base: data Layout
+ Graphics.Plotly.Base: data Line
+ Graphics.Plotly.Base: data ListOrElem a
+ Graphics.Plotly.Base: data Margin
+ Graphics.Plotly.Base: data Marker
+ Graphics.Plotly.Base: data Mode
+ Graphics.Plotly.Base: data Orientation
+ Graphics.Plotly.Base: data Plotly
+ Graphics.Plotly.Base: data Symbol
+ Graphics.Plotly.Base: data Trace
+ Graphics.Plotly.Base: data TraceType
+ Graphics.Plotly.Base: defAxis :: Axis
+ Graphics.Plotly.Base: defLayout :: Layout
+ Graphics.Plotly.Base: defLine :: Line
+ Graphics.Plotly.Base: defMarker :: Marker
+ Graphics.Plotly.Base: elemid :: Lens' Plotly Text
+ Graphics.Plotly.Base: fill :: Lens' Trace (Maybe Fill)
+ Graphics.Plotly.Base: height :: Lens' Layout (Maybe Int)
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Axis
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Barmode
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Color
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Dash
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Fill
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Layout
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Line
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Margin
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Marker
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Orientation
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Symbol
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.Trace
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON Graphics.Plotly.Base.TraceType
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON [Graphics.Plotly.Base.Mode]
+ Graphics.Plotly.Base: instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.Base.ListOrElem a)
+ Graphics.Plotly.Base: instance GHC.Classes.Eq Graphics.Plotly.Base.Marker
+ Graphics.Plotly.Base: instance GHC.Classes.Eq Graphics.Plotly.Base.Symbol
+ Graphics.Plotly.Base: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Plotly.Base.ListOrElem a)
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Axis
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Layout
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Line
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Margin
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Marker
+ Graphics.Plotly.Base: instance GHC.Generics.Generic Graphics.Plotly.Base.Trace
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.Barmode
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.Dash
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.Fill
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.Mode
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.Symbol
+ Graphics.Plotly.Base: instance GHC.Show.Show Graphics.Plotly.Base.TraceType
+ Graphics.Plotly.Base: layout :: Lens' Plotly Layout
+ Graphics.Plotly.Base: line :: Lens' Trace (Maybe Line)
+ Graphics.Plotly.Base: linecolor :: Lens' Line (Maybe Color)
+ Graphics.Plotly.Base: linewidth :: Lens' Line (Maybe Double)
+ Graphics.Plotly.Base: margin :: Lens' Layout (Maybe Margin)
+ Graphics.Plotly.Base: marginb :: Lens' Margin Int
+ Graphics.Plotly.Base: marginl :: Lens' Margin Int
+ Graphics.Plotly.Base: marginpad :: Lens' Margin Int
+ Graphics.Plotly.Base: marginr :: Lens' Margin Int
+ Graphics.Plotly.Base: margint :: Lens' Margin Int
+ Graphics.Plotly.Base: marker :: Lens' Trace (Maybe Marker)
+ Graphics.Plotly.Base: markercolor :: Lens' Marker (Maybe (ListOrElem Value))
+ Graphics.Plotly.Base: mode :: Lens' Trace (Maybe [Mode])
+ Graphics.Plotly.Base: name :: Lens' Trace (Maybe Text)
+ Graphics.Plotly.Base: opacity :: Lens' Marker (Maybe Double)
+ Graphics.Plotly.Base: orientation :: Lens' Trace (Maybe Orientation)
+ Graphics.Plotly.Base: plotly :: Text -> [Trace] -> Plotly
+ Graphics.Plotly.Base: range :: Lens' Axis (Maybe (Double, Double))
+ Graphics.Plotly.Base: scatter :: Trace
+ Graphics.Plotly.Base: showgrid :: Lens' Axis (Maybe Bool)
+ Graphics.Plotly.Base: showlegend :: Lens' Layout (Maybe Bool)
+ Graphics.Plotly.Base: size :: Lens' Marker (Maybe (ListOrElem Value))
+ Graphics.Plotly.Base: symbol :: Lens' Marker (Maybe Symbol)
+ Graphics.Plotly.Base: text :: Lens' Trace (Maybe [Text])
+ Graphics.Plotly.Base: thinMargins :: Margin
+ Graphics.Plotly.Base: title :: Lens' Layout (Maybe Text)
+ Graphics.Plotly.Base: titleMargins :: Margin
+ Graphics.Plotly.Base: traces :: Lens' Plotly [Trace]
+ Graphics.Plotly.Base: tracetype :: Lens' Trace TraceType
+ Graphics.Plotly.Base: width :: Lens' Layout (Maybe Int)
+ Graphics.Plotly.Base: x :: Lens' Trace (Maybe [Value])
+ Graphics.Plotly.Base: xaxis :: Lens' Layout (Maybe Axis)
+ Graphics.Plotly.Base: y :: Lens' Trace (Maybe [Value])
+ Graphics.Plotly.Base: yaxis :: Lens' Layout (Maybe Axis)
+ Graphics.Plotly.Base: zeroline :: Lens' Axis (Maybe Bool)
+ Graphics.Plotly.Blaze: instance Text.Blaze.ToMarkup Graphics.Plotly.Base.Plotly
+ Graphics.Plotly.GoG: Aes :: (a -> XVal t) -> (a -> YVal t) -> Maybe (a -> CVal t) -> Maybe (a -> SVal t) -> Aes t a
+ Graphics.Plotly.GoG: RGB :: a -> a -> a -> RGB a
+ Graphics.Plotly.GoG: RGBA :: a -> a -> a -> a -> RGBA a
+ Graphics.Plotly.GoG: [_color] :: Aes t a -> Maybe (a -> CVal t)
+ Graphics.Plotly.GoG: [_size] :: Aes t a -> Maybe (a -> SVal t)
+ Graphics.Plotly.GoG: [_x] :: Aes t a -> (a -> XVal t)
+ Graphics.Plotly.GoG: [_y] :: Aes t a -> (a -> YVal t)
+ Graphics.Plotly.GoG: aes :: Aes ((), (), (), ()) a
+ Graphics.Plotly.GoG: class ToJSON a => AxisValue a
+ Graphics.Plotly.GoG: class ToJSON a => IsColor a
+ Graphics.Plotly.GoG: color :: IsColor v => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, vy, v, vs) a) (Maybe (a -> vc)) (Maybe (a -> v))
+ Graphics.Plotly.GoG: data Aes t a
+ Graphics.Plotly.GoG: data RGB a
+ Graphics.Plotly.GoG: data RGBA a
+ Graphics.Plotly.GoG: hbars :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t)) => Aes t a -> [a] -> Trace
+ Graphics.Plotly.GoG: instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGB GHC.Types.Double)
+ Graphics.Plotly.GoG: instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGB GHC.Types.Int)
+ Graphics.Plotly.GoG: instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGBA GHC.Types.Double)
+ Graphics.Plotly.GoG: instance Data.Aeson.Types.ToJSON.ToJSON (Graphics.Plotly.GoG.RGBA GHC.Types.Int)
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.AxisValue Data.Text.Internal.Text
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.AxisValue GHC.Base.String
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.AxisValue GHC.Types.Double
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.AxisValue GHC.Types.Float
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.AxisValue GHC.Types.Int
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGB GHC.Types.Double)
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGB GHC.Types.Int)
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGBA GHC.Types.Double)
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.IsColor (Graphics.Plotly.GoG.RGBA GHC.Types.Int)
+ Graphics.Plotly.GoG: instance Graphics.Plotly.GoG.IsColor GHC.Types.Int
+ Graphics.Plotly.GoG: line :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t)) => Aes t a -> [a] -> Trace
+ Graphics.Plotly.GoG: points :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t), ToJSON (CVal t), ToJSON (SVal t)) => Aes t a -> [a] -> Trace
+ Graphics.Plotly.GoG: setcol :: IsColor v => Aes (vx, vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, v, vs) a
+ Graphics.Plotly.GoG: setsize :: (AxisValue v, Num v) => Aes (vx, vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, vc, v) a
+ Graphics.Plotly.GoG: setx :: AxisValue v => Aes (vx, vy, vc, vs) a -> (a -> v) -> Aes (v, vy, vc, vs) a
+ Graphics.Plotly.GoG: sety :: AxisValue v => Aes (vx, vy, vc, vs) a -> (a -> v) -> Aes (vx, v, vc, vs) a
+ Graphics.Plotly.GoG: size :: (AxisValue v, Num v) => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, vy, vc, v) a) (Maybe (a -> vs)) (Maybe (a -> v))
+ Graphics.Plotly.GoG: x :: AxisValue v => Lens (Aes (vx, vy, vc, vs) a) (Aes (v, vy, vc, vs) a) (a -> vx) (a -> v)
+ Graphics.Plotly.GoG: y :: AxisValue v => Lens (Aes (vx, vy, vc, vs) a) (Aes (vx, v, vc, vs) a) (a -> vy) (a -> v)
+ Graphics.Plotly.Lucid: instance Lucid.Base.ToHtml Graphics.Plotly.Base.Plotly
+ Graphics.Plotly.Simple: fanPlot :: Double -> [(Double, (Double, Double))] -> Trace
+ Graphics.Plotly.Simple: hbarChart :: [(Text, Double)] -> Trace
+ Graphics.Plotly.Simple: linePlot :: [(Double, Double)] -> Trace
+ Graphics.Plotly.Simple: scatterPlot :: [(Double, Double)] -> Trace
Files
- TestPlotly.hs +0/−20
- changelog.md +7/−0
- plotlyhs.cabal +10/−15
- src/Graphics/Plotly.hs +11/−245
- src/Graphics/Plotly/Base.hs +256/−0
- src/Graphics/Plotly/Blaze.hs +1/−1
- src/Graphics/Plotly/GoG.hs +128/−0
- src/Graphics/Plotly/Histogram.hs +7/−4
- src/Graphics/Plotly/Lucid.hs +1/−1
- src/Graphics/Plotly/Simple.hs +41/−0
− TestPlotly.hs
@@ -1,20 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}--import Lucid-import Lucid.Html5-import Graphics.Plotly-import Graphics.Plotly.Lucid-import Lens.Micro--import qualified Data.Text.Lazy as T-import qualified Data.Text.Lazy.IO as T--main = - T.writeFile "test.html" $ renderText $ doctypehtml_ $ do- head_ $ do meta_ [charset_ "utf-8"]- plotlyCDN- body_ $ toHtml $ plotly "myDiv" [myTrace] --myTrace = scatter & x ?~ [1,2,3,4]- & y ?~ [500,3000,700,200]-
changelog.md view
@@ -1,3 +1,10 @@+0.1.1++* Simple module to help build traces++* remove test-plotly executable++ 0.1 * Initial release
plotlyhs.cabal view
@@ -1,5 +1,5 @@ Name: plotlyhs-Version: 0.1.0+Version: 0.2 Synopsis: Haskell bindings to Plotly.js Description: Generate web-based plots with the Plotly.js library.@@ -11,9 +11,9 @@ Author: Tom Nielsen Maintainer: tanielsen@gmail.com build-type: Simple-Cabal-Version: >= 1.8-homepage: https://github.com/glutamate/plotlyhs-bug-reports: https://github.com/glutamate/plotlyhs/issues+Cabal-Version: >= 1.10+homepage: https://github.com/filopodia/open/plotlyhs+bug-reports: https://github.com/filopodia/open/issues category: Graphics, Charts Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 7.10.3, GHC == 8.0.1 @@ -24,18 +24,22 @@ Library ghc-options: -Wall -fno-warn-type-defaults- ghc-prof-options: -auto-all hs-source-dirs: src+ default-language: Haskell2010 + Exposed-modules: Graphics.Plotly , Graphics.Plotly.Utils , Graphics.Plotly.Lucid+ , Graphics.Plotly.GoG+ , Graphics.Plotly.Base , Graphics.Plotly.Blaze , Graphics.Plotly.Histogram+ , Graphics.Plotly.Simple Build-depends:- base >= 4.7+ base >= 4.6 && <5 , aeson , lucid , blaze-html@@ -44,12 +48,3 @@ , bytestring , microlens-th , microlens--executable test-plotly- main-is: TestPlotly.hs- build-depends: base >=4.6 && <5- , plotlyhs- , lucid- , aeson- , text- , microlens
src/Graphics/Plotly.hs view
@@ -2,253 +2,19 @@ {-| -This module defines datatypes that can be used to generate [Plotly.js](https://plot.ly/javascript/)-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.+Re-exports the Simple interface, the grammar of grpahics +interface and parts of the base interface. -} -module Graphics.Plotly where--import Data.Aeson-import Data.Aeson.Types-import Data.Char (toLower)-import Data.List (intercalate, nub, findIndex)-import Data.Monoid ((<>))-import Data.Maybe (fromJust)-import Data.Text (Text)--import GHC.Generics-import Lens.Micro.TH--import Graphics.Plotly.Utils---- * Traces---- |How should traces be drawn? (lines or markers)-data Mode = Markers | Lines deriving Show--instance {-# OVERLAPS #-} ToJSON [Mode] where- toJSON = toJSON . intercalate "+" . map (map toLower . show)---- | What kind of plot type are we building - scatter (inluding line plots) or bars?-data TraceType = Scatter | Bar deriving Show--instance ToJSON TraceType where- toJSON = toJSON . map toLower . show----- | A color specification, either as a concrete RGB/RGBA value or a color per point.-data Color = RGBA Int Int Int Int -- ^ use this RGBA color for every point in the trace- | RGB Int Int Int -- ^ use this RGB color for every point in the trace- | ColIxs [Int] -- ^ use a different color index for each point- | Cols [Color] -- ^ use a different color for each point--instance ToJSON Color where- toJSON (RGB r g b) = toJSON $ "rgb("<>show r<>","<>show g<>","<>show b<>")"- toJSON (RGBA r g b a) = toJSON $ "rgba("<>show r<>","<>show g<>","<>show b<>","<> show a<>")"- toJSON (ColIxs cs) = toJSON cs- toJSON (Cols cs) = toJSON cs---- | Assign colors based on any categorical value-catColors :: Eq a => [a] -> Color-catColors xs =- let vals = nub xs- f x = fromJust $ findIndex (==x) vals- in ColIxs $ map f xs---- | Different types of markers-data Symbol = Circle | Square | Diamond | Cross deriving Show--instance ToJSON Symbol where- toJSON = toJSON . map toLower . show---- | Marker specification-data Marker = Marker- { _size :: Maybe Int- , _markercolor :: Maybe Color- , _symbol :: Maybe Symbol- , _opacity :: Maybe Double- } deriving Generic--makeLenses ''Marker--instance ToJSON Marker where- toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "markercolor" "color" . unLens}---- | default marker specification-defMarker :: Marker-defMarker = Marker Nothing Nothing Nothing Nothing----- | Dash type specification-data Dash = Solid | Dashdot | Dot deriving Show--instance ToJSON Dash where- toJSON = toJSON . map toLower . show---- | Horizontal or Vertical orientation of bars-data Orientation = Horizontal | Vertical--instance ToJSON Orientation where- toJSON Horizontal = "h"- toJSON Vertical = "v"---- | Are we filling area plots from the zero line or to the next Y value?-data Fill = ToZeroY | ToNextY deriving Show--instance ToJSON Fill where- toJSON = toJSON . map toLower . show---- | line specification-data Line = Line- { _linewidth :: Maybe Double- , _linecolor :: Maybe Color- , _dash :: Maybe Dash- } deriving Generic--makeLenses ''Line--instance ToJSON Line where- toJSON = genericToJSON jsonOptions { fieldLabelModifier = dropInitial "line" . unLens}--defLine :: Line-defLine = Line Nothing Nothing Nothing---- | A `Trace` is the component of a plot. Multiple traces can be superimposed.-data Trace = Trace- { _x :: Maybe [Double] -- ^ x values, as numbers- , _y :: Maybe [Double] -- ^ y values, as numbers- , _xtext :: Maybe [Text] -- ^ x values, as Text- , _ytext :: Maybe [Text] -- ^ y values, as Text- , _mode :: Maybe [Mode] -- ^ select one or two modes.- , _name :: Maybe Text -- ^ name of this trace, for legend- , _text :: Maybe [Text]- , _tracetype :: TraceType- , _marker :: Maybe Marker- , _line :: Maybe Line- , _fill :: Maybe Fill- , _orientation :: Maybe Orientation- } deriving Generic--makeLenses ''Trace---- |an empty scatter plot-scatter :: Trace-scatter = Trace Nothing Nothing Nothing Nothing Nothing Nothing Nothing Scatter Nothing Nothing Nothing Nothing---- |an empty bar plot-bars :: Trace-bars = Trace Nothing Nothing Nothing Nothing Nothing Nothing Nothing Bar Nothing Nothing Nothing Nothing---instance ToJSON Trace where- toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "tracetype" "type" . rename "xtext" "x" . rename "ytext" "y" . unLens}---- |Options for axes-data Axis = Axis- { _range :: Maybe (Double,Double)- , _axistitle :: Maybe Text- , _showgrid :: Maybe Bool- , _zeroline :: Maybe Bool- } deriving Generic--makeLenses ''Axis--instance ToJSON Axis where- toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "axistitle" "axis" . unLens}--defAxis :: Axis-defAxis = Axis Nothing Nothing Nothing Nothing---- * Layouts---- | How different bar traces be superimposed? By grouping or by stacking?-data Barmode = Stack | Group deriving Show--instance ToJSON Barmode where- toJSON = toJSON . map toLower . show---- |Options for Margins.-data Margin = Margin- { _marginl :: Int- , _marginr :: Int- , _marginb :: Int- , _margint :: Int- , _marginpad :: Int- } deriving Generic--makeLenses ''Margin--instance ToJSON Margin where- toJSON = genericToJSON jsonOptions { fieldLabelModifier = dropInitial "margin" . unLens}---- | some good values for margins-thinMargins, titleMargins :: Margin-thinMargins = Margin 50 25 30 10 4-titleMargins = Margin 50 25 30 40 4----- |options for the layout of the whole plot-data Layout = Layout- { _xaxis :: Maybe Axis- , _yaxis :: Maybe Axis- , _title :: Maybe Text- , _showlegend :: Maybe Bool- , _height :: Maybe Int- , _width :: Maybe Int- , _barmode :: Maybe Barmode- , _margin :: Maybe Margin- } deriving Generic--makeLenses ''Layout---- |a defaultlayout-defLayout :: Layout-defLayout = Layout Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing--instance ToJSON Layout where- toJSON = genericToJSON jsonOptions---- * Plotly---- | A helper record which represents the whole plot-data Plotly = Plotly- { _elemid :: Text- , _traces :: [Trace]- , _layout :: Layout- }+module Graphics.Plotly (+ module Base,+ module Simple,+ module GoG+) where -makeLenses ''Plotly+import Graphics.Plotly.Base as Base + hiding (x,y, _x, _y, _size, _line, size, line)+import Graphics.Plotly.Simple as Simple+import Graphics.Plotly.GoG as GoG --- | helper function for building the plot.-plotly :: Text -> [Trace] -> Plotly-plotly idnm trs = Plotly idnm trs defLayout
+ src/Graphics/Plotly/Base.hs view
@@ -0,0 +1,256 @@+{-# LANGUAGE DeriveGeneric, OverloadedStrings,FlexibleInstances, TemplateHaskell #-}++{-|++This module defines datatypes that can be used to generate [Plotly.js](https://plot.ly/javascript/)+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 where++import Data.Aeson+import Data.Aeson.Types+import Data.Char (toLower)+import Data.List (intercalate, nub, findIndex)+import Data.Monoid ((<>))+import Data.Maybe (fromJust)+import Data.Text (Text)++import GHC.Generics+import Lens.Micro.TH++import Graphics.Plotly.Utils++-- * Traces++-- |How should traces be drawn? (lines or markers)+data Mode = Markers | Lines deriving Show++instance {-# OVERLAPS #-} ToJSON [Mode] where+ toJSON = toJSON . intercalate "+" . map (map toLower . show)++-- | What kind of plot type are we building - scatter (inluding line plots) or bars?+data TraceType = Scatter | Bar deriving Show++instance ToJSON TraceType where+ toJSON = toJSON . map toLower . show+++-- | A color specification, either as a concrete RGB/RGBA value or a color per point.+data Color = ColRGBA Int Int Int Int -- ^ use this RGBA color for every point in the trace+ | ColRGB Int Int Int -- ^ use this RGB color for every point in the trace+ | ColIx Int -- ^ use a different color index for each point++instance ToJSON Color where+ toJSON (ColRGB r g b) = toJSON $ "rgb("<>show r<>","<>show g<>","<>show b<>")"+ toJSON (ColRGBA r g b a) = toJSON $ "rgba("<>show r<>","<>show g<>","<>show b<>","<> show a<>")"+ toJSON (ColIx cs) = toJSON cs++-- | Assign colors based on any categorical value+catColors :: Eq a => [a] -> ListOrElem Value+catColors xs =+ let vals = nub xs+ f x = fromJust $ findIndex (==x) vals+ in List $ map (toJSON . ColIx . f) xs++-- | Different types of markers+data Symbol = Circle | Square | Diamond | Cross deriving (Show, Eq)++instance ToJSON Symbol where+ toJSON = toJSON . map toLower . show++data ListOrElem a = List [a] | All a deriving Eq++instance ToJSON a => ToJSON (ListOrElem a) where+ toJSON (List xs) = toJSON xs+ toJSON (All x) = toJSON x++-- | Marker specification+data Marker = Marker+ { _size :: Maybe (ListOrElem Value)+ , _markercolor :: Maybe (ListOrElem Value)+ , _symbol :: Maybe Symbol+ , _opacity :: Maybe Double+ } deriving (Generic, Eq)++makeLenses ''Marker++instance ToJSON Marker where+ toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "markercolor" "color" . unLens}++-- | default marker specification+defMarker :: Marker+defMarker = Marker Nothing Nothing Nothing Nothing+++-- | Dash type specification+data Dash = Solid | Dashdot | Dot deriving Show++instance ToJSON Dash where+ toJSON = toJSON . map toLower . show++-- | Horizontal or Vertical orientation of bars+data Orientation = Horizontal | Vertical++instance ToJSON Orientation where+ toJSON Horizontal = "h"+ toJSON Vertical = "v"++-- | Are we filling area plots from the zero line or to the next Y value?+data Fill = ToZeroY | ToNextY deriving Show++instance ToJSON Fill where+ toJSON = toJSON . map toLower . show++-- | line specification+data Line = Line+ { _linewidth :: Maybe Double+ , _linecolor :: Maybe Color+ , _dash :: Maybe Dash+ } deriving Generic++makeLenses ''Line++instance ToJSON Line where+ toJSON = genericToJSON jsonOptions { fieldLabelModifier = dropInitial "line" . unLens}++defLine :: Line+defLine = Line Nothing Nothing Nothing++-- | A `Trace` is the component of a plot. Multiple traces can be superimposed.+data Trace = Trace+ { _x :: Maybe [Value] -- ^ x values, as numbers+ , _y :: Maybe [Value] -- ^ y values, as numbers+ , _mode :: Maybe [Mode] -- ^ select one or two modes.+ , _name :: Maybe Text -- ^ name of this trace, for legend+ , _text :: Maybe [Text]+ , _tracetype :: TraceType+ , _marker :: Maybe Marker+ , _line :: Maybe Line+ , _fill :: Maybe Fill+ , _orientation :: Maybe Orientation+ } deriving Generic++makeLenses ''Trace++-- |an empty scatter plot+scatter :: Trace+scatter = Trace Nothing Nothing Nothing Nothing Nothing Scatter Nothing Nothing Nothing Nothing++-- |an empty bar plot+bars :: Trace+bars = Trace Nothing Nothing Nothing Nothing Nothing Bar Nothing Nothing Nothing Nothing+++instance ToJSON Trace where+ toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "tracetype" "type" . unLens}++-- |Options for axes+data Axis = Axis+ { _range :: Maybe (Double,Double)+ , _axistitle :: Maybe Text+ , _showgrid :: Maybe Bool+ , _zeroline :: Maybe Bool+ } deriving Generic++makeLenses ''Axis++instance ToJSON Axis where+ toJSON = genericToJSON jsonOptions {fieldLabelModifier = rename "axistitle" "axis" . unLens}++defAxis :: Axis+defAxis = Axis Nothing Nothing Nothing Nothing++-- * Layouts++-- | How different bar traces be superimposed? By grouping or by stacking?+data Barmode = Stack | Group deriving Show++instance ToJSON Barmode where+ toJSON = toJSON . map toLower . show++-- |Options for Margins.+data Margin = Margin+ { _marginl :: Int+ , _marginr :: Int+ , _marginb :: Int+ , _margint :: Int+ , _marginpad :: Int+ } deriving Generic++makeLenses ''Margin++instance ToJSON Margin where+ toJSON = genericToJSON jsonOptions { fieldLabelModifier = dropInitial "margin" . unLens}++-- | some good values for margins+thinMargins, titleMargins :: Margin+thinMargins = Margin 50 25 30 10 4+titleMargins = Margin 50 25 30 40 4+++-- |options for the layout of the whole plot+data Layout = Layout+ { _xaxis :: Maybe Axis+ , _yaxis :: Maybe Axis+ , _title :: Maybe Text+ , _showlegend :: Maybe Bool+ , _height :: Maybe Int+ , _width :: Maybe Int+ , _barmode :: Maybe Barmode+ , _margin :: Maybe Margin+ } deriving Generic++makeLenses ''Layout++-- |a defaultlayout+defLayout :: Layout+defLayout = Layout Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing++instance ToJSON Layout where+ toJSON = genericToJSON jsonOptions++-- * Plotly++-- | A helper record which represents the whole plot+data Plotly = Plotly+ { _elemid :: Text+ , _traces :: [Trace]+ , _layout :: Layout+ }++makeLenses ''Plotly++-- | helper function for building the plot.+plotly :: Text -> [Trace] -> Plotly+plotly idnm trs = Plotly idnm trs defLayout
src/Graphics/Plotly/Blaze.hs view
@@ -21,7 +21,7 @@ import Text.Blaze import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A-import Graphics.Plotly+import Graphics.Plotly.Base import Data.Monoid ((<>)) import Data.Text.Encoding (decodeUtf8) import Data.ByteString.Lazy (toStrict)
+ src/Graphics/Plotly/GoG.hs view
@@ -0,0 +1,128 @@+{-# LANGUAGE OverloadedStrings, FlexibleInstances, TypeFamilies, FlexibleContexts #-}++{-|+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 where++import qualified Graphics.Plotly.Base as Plot+import Data.Text (Text)+import Lens.Micro+import Data.Aeson++class ToJSON a => AxisValue a++instance AxisValue Double+instance AxisValue Float+instance AxisValue Text+instance AxisValue String+instance AxisValue Int++data RGB a = RGB a a a+data RGBA a = RGBA a a a a++instance ToJSON (RGB Int) where+ toJSON (RGB r g b) = toJSON $ concat ["rgb(",show r,",",show g, ",", show b,")"]++instance ToJSON (RGB Double) where+ toJSON (RGB r g b) = toJSON $ concat ["rgb(",showd r,",",showd g, ",", showd b,")"]+ where showd = show . floor . (*256)++instance ToJSON (RGBA Int) where+ toJSON (RGBA r g b a) = toJSON $ concat ["rgba(",show r,",",show g, ",", show b,",", show a, ")"]++instance ToJSON (RGBA Double) where+ toJSON (RGBA r g b a) = toJSON $ concat ["rgb(",showd r,",",showd g, ",", showd b,",", showd a,")"]+ where showd = show . floor . (*256)++class ToJSON a => IsColor a++instance IsColor Int+instance IsColor (RGB Int)+instance IsColor (RGB Double)+instance IsColor (RGBA Int)+instance IsColor (RGBA Double)++type family XVal a+type family YVal a+type family CVal a+type family SVal a++type instance XVal (x,y,c,s) = x+type instance YVal (x,y,c,s) = y+type instance CVal (x,y,c,s) = c+type instance SVal (x,y,c,s) = s++data Aes t a = Aes { _x :: (a -> XVal t)+ , _y :: (a -> YVal t)+ , _color :: Maybe (a -> CVal t)+ , _size :: Maybe (a -> SVal t)+ }+aes :: Aes ((), (), (), ()) a+aes = Aes (const ()) (const ()) Nothing Nothing++setx :: AxisValue v => Aes (vx,vy,vc,vs) a -> (a -> v) -> Aes (v, vy, vc, vs) a+setx (Aes _ fy fc fs) f = (Aes f fy fc fs)++x :: AxisValue v => Lens (Aes (vx,vy, vc, vs) a) (Aes (v,vy, vc, vs) a) (a -> vx) (a -> v)+x = lens _x setx++sety :: AxisValue v => Aes (vx,vy, vc, vs) a -> (a -> v) -> Aes (vx, v, vc, vs) a+sety (Aes fx _ fc fs) f = (Aes fx f fc fs)++y :: AxisValue v => Lens (Aes (vx,vy, vc, vs) a) (Aes (vx,v, vc, vs) a) (a -> vy) (a -> v)+y = lens _y sety++setcol :: IsColor v => Aes (vx,vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, v, vs) a+setcol (Aes fx fy _ fs) f = (Aes fx fy f fs)++color :: IsColor v => Lens (Aes (vx,vy, vc, vs) a) (Aes (vx,vy,v,vs) a) (Maybe (a -> vc)) (Maybe (a -> v))+color = lens _color setcol++setsize :: (AxisValue v, Num v) => Aes (vx,vy, vc, vs) a -> Maybe (a -> v) -> Aes (vx, vy, vc, v) a+setsize (Aes fx fy fc _) f = (Aes fx fy fc f)++size :: (AxisValue v, Num v) => Lens (Aes (vx,vy, vc, vs) a) (Aes (vx,vy,vc,v) a) (Maybe (a -> vs)) (Maybe (a -> v))+size = lens _size setsize+++points :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t), ToJSON (CVal t), ToJSON (SVal t))+ => Aes t a -> [a] -> Plot.Trace+points a xs = setSize (_size a) $ setColors (_color a) $ Plot.scatter+ & Plot.x ?~ map (toJSON . _x a) xs+ & Plot.y ?~ map (toJSON . _y a) xs+ & Plot.mode ?~ [Plot.Markers]+ where setColors Nothing p = p+ setColors (Just setC) p+ = p & Plot.marker . non Plot.defMarker . Plot.markercolor ?~ Plot.List (map (toJSON . setC) xs)+ setSize Nothing p = p+ setSize (Just setS) p+ = p & Plot.marker . non Plot.defMarker . Plot.size ?~ Plot.List (map (toJSON . setS) xs)++line :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t), Num (YVal t))+ => Aes t a -> [a] -> Plot.Trace+line a xs = Plot.scatter & Plot.x ?~ map (toJSON . _x a) xs+ & Plot.y ?~ map (toJSON . _y a) xs+ & Plot.mode ?~ [Plot.Lines]++hbars :: (AxisValue (XVal t), AxisValue (YVal t), Num (XVal t))+ => Aes t a -> [a] -> Plot.Trace+hbars a xs = Plot.bars & Plot.x ?~ map (toJSON . _x a) xs+ & Plot.y ?~ map (toJSON . _y a) xs+ & Plot.orientation ?~ Plot.Horizontal
src/Graphics/Plotly/Histogram.hs view
@@ -6,9 +6,10 @@ module Graphics.Plotly.Histogram where -import Graphics.Plotly+import Graphics.Plotly.Base import Data.List (sort, group) import Lens.Micro+import Data.Aeson (toJSON) -- | build a histogram with a given binsize histogram :: Int -- ^ number of bins@@ -18,13 +19,15 @@ let (lo, hi) = (minimum pts, maximum pts) binSize = (hi - lo) / realToFrac nbins binf :: Double -> Int- binf x = floor $ (x - lo) / binSize+ binf xv = floor $ (xv - lo) / binSize+ binToX :: Int -> Double binToX binN = realToFrac binN * binSize + lo bins = group $ sort $ map binf pts- goFill (car@(bin1,count1):cdr@((bin2,count2):_))+ goFill (car@(bin1,_):cdr@((bin2,_):_)) | bin2 == bin1 + 1 = car : goFill cdr | otherwise = car : goFill ((bin1+1,0):cdr) goFill l = l+ binMap :: [(Int, Int)] binMap = goFill $ map (\is -> (head is, length is)) bins - in bars & x ?~ map (binToX . fst) binMap & y ?~ map (realToFrac . snd) binMap+ in bars & x ?~ map (toJSON . binToX . fst) binMap & y ?~ map (toJSON . snd) binMap
src/Graphics/Plotly/Lucid.hs view
@@ -19,7 +19,7 @@ module Graphics.Plotly.Lucid where import Lucid-import Graphics.Plotly+import Graphics.Plotly.Base import Data.Monoid ((<>)) import Data.Text.Encoding (decodeUtf8) import Data.ByteString.Lazy (toStrict)
+ src/Graphics/Plotly/Simple.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE OverloadedStrings #-}++{-|++Functions to build Traces from standard data. Generated traces can still be customized with lenses++-}++module Graphics.Plotly.Simple where++import Graphics.Plotly.Base+import Lens.Micro+import Data.Text (Text)+import Data.Aeson+++-- |Generate a scatterplot from pairs+scatterPlot :: [(Double,Double)] -> Trace+scatterPlot xys = scatter & x ?~ map (toJSON .fst) xys+ & y ?~ map (toJSON .snd) xys+ & mode ?~ [Markers]+-- |Generate a line plot from pairs+linePlot :: [(Double,Double)] -> Trace+linePlot xys = scatter & x ?~ map (toJSON .fst) xys+ & y ?~ map (toJSON .snd) xys+ & mode ?~ [Lines]++-- |Generate a horizontal bar chart from pairs of text and value.+hbarChart :: [(Text, Double)] -> Trace+hbarChart tvs = bars & y ?~ map (toJSON . fst) tvs+ & x ?~ map (toJSON .snd) tvs+ & orientation ?~ Horizontal++-- |Generate a fan plot with a given width in standard deviations and+-- (x,(y,sd)) data+fanPlot :: Double -> [(Double, (Double, Double))] -> Trace+fanPlot sdCount tmnsds =+ let xs = map fst tmnsds ++ reverse (map fst tmnsds)+ ys = map ((\(m,sd) -> m+sdCount*sd) . snd) tmnsds+ ++ reverse ( map ((\(m,sd) -> m-sdCount*sd) . snd) tmnsds)+ in scatter & x ?~ map toJSON xs & y ?~ map toJSON ys & fill ?~ ToZeroY