-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Pretty print charts from ghci. -- -- Serve and print charts from ghci, with automatic formatting. @package prettychart @version 0.2.2.0 -- | Various common chart patterns. module Prettychart.Charts -- | interpret a [Double] as a line with x coordinates of [0..] simpleLineChart :: Double -> Colour -> [Double] -> Chart -- | convert from [a] to [Point a], by adding the index as the x axis -- --
-- >>> xify [1..3] -- [Point 0.0 1.0,Point 1.0 2.0,Point 2.0 3.0] --xify :: [Double] -> [Point Double] -- | convert from [a] to [Point a], by adding the index as the y axis -- --
-- >>> yify [1..3] -- [Point 1.0 0.0,Point 2.0 1.0,Point 3.0 2.0] --yify :: [Double] -> [Point Double] -- | Create a hud that has time as the x-axis, based on supplied UTCTime -- list. timeXAxis :: Int -> [UTCTime] -> AxisOptions -- | common pattern of chart title, x-axis title and y-axis title titles3 :: Double -> (Text, Text, Text) -> [Priority TitleOptions] -- | histogram chart histChart :: Range Double -> Int -> [Double] -> ChartOptions -- | scatter chart scatterChart :: [[Point Double]] -> [Chart] -- | blendMidLineStyle n w produces n lines of width w -- interpolated between two colors. blendMidLineStyles :: Int -> Double -> (Colour, Colour) -> [Style] -- | Format quantile-style numbers -- --
-- >>> quantileNames [0.01, 0.5, 0.99] -- ["1%","50%","99%"] --quantileNames :: Functor f => f Double -> f Text -- | Chart template for quantiles. quantileChart :: [Text] -> [Style] -> [[Double]] -> ChartOptions -- | A chart drawing quantiles of a time series digitChart :: [UTCTime] -> [Double] -> [Text] -> ChartOptions -- | A histogram based on quantile information quantileHistChart :: Maybe [Text] -> [Double] -> [Double] -> ChartOptions -- | Surface chart of quantile vs quantile counts digitSurfaceChart :: SurfaceStyle -> SurfaceLegendOptions -> (Text, Text, Text) -> [Text] -> [(Int, Int)] -> ChartTree -- | Read some text and attempt to make a chart. module Prettychart.Any -- | Attempt to read some text and interpret it as data suitable for -- charting. -- -- In the example below, anyChart determines that the input text -- is of type [(Double, Double)] and renders a scatter chart of the data. -- --
-- >>> unknownData = (,) <$> (((\x -> sin (pi * x/40)) . fromIntegral <$> ([1..40] :: [Int]))) <*> (((\x -> cos (pi * x/40)) . fromIntegral <$> ([1..40] :: [Int]))) -- -- >>> let c = anyChart $ show $ unknownData -- -- >>> writeFile "other/anychart.svg" $ either id (unpack . renderChartOptions) c ---- anyChart :: String -> Either String ChartOptions -- | Attempt to read chart data and write to file. anyWrite :: FilePath -> String -> IO () -- | Read a String and try a chart with a particular shape. tryChart :: Read a => String -> (a -> ChartOptions) -> Either String ChartOptions -- | Default chart for a single list. anyList1 :: [Double] -> ChartOptions -- | Default chart for a double list. anyList2 :: [[Double]] -> ChartOptions -- | Default scatter chart for paired data anyTuple2 :: [[(Double, Double)]] -> ChartOptions -- | Bar chart for a labelled list. anySingleNamedBarChart :: [(Text, Double)] -> ChartOptions -- | Bar chart for a double list. anyBar2 :: [[Double]] -> ChartOptions -- | Multiple line chart. anyLineChart :: [[Double]] -> ChartOptions -- | Default pixel chart for double list. anySurfaceChart :: [[Double]] -> ChartOptions -- | Serve a chart web page with a web socket in it, that accepts -- ChartOptions. module Prettychart.Server -- | Start the chart server. Returns the chart consumer, and a server quit -- signal effect. -- -- An iconic ghci session transcript: -- --
-- > import Chart.Examples -- > (sendChart, quitChartServer) <- startChartServer (Just "prettychart") -- > sendChart unitExample ---- -- ... point browser to localhost:9160 ... -- --
-- > quitChartServer --startChartServer :: Maybe String -> IO (ChartOptions -> IO Bool, IO ()) -- | Start the chart server protocol with bespoke SocketConfig and -- Page configurations. -- --
-- startChartServerWith (defaultSocketConfig & #port .~ 4567) (defaultSocketPage & #htmlBody %~ divClass_ "row" "bespoke footnote") --startChartServerWith :: SocketConfig -> Page -> IO (ChartOptions -> IO Bool, IO ()) -- | Print a chart supplying a ChartOptions consumer, and a showable -- thing that may be chartable. The first argument flags whether to also -- print the item to stdout. printChart :: Show a => Bool -> (ChartOptions -> IO Bool) -> a -> IO () -- | Page containing a web socket and javascript needed to run it. chartSocketPage :: Maybe ByteString -> Page -- | A haskell library to serve charts via ghci. module Prettychart