barchart 0.1.1 → 0.1.1.1
raw patch · 3 files changed
+90/−181 lines, 3 filesdep ~cmdargsdep ~filepathPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: cmdargs, filepath
API changes (from Hackage documentation)
- Graphics.BarChart: class (Num a) => Measurable a
+ Graphics.BarChart: class Num a => Measurable a
- Graphics.BarChart: diagram :: (Measurable a) => Config -> BarChart a -> Diagram
+ Graphics.BarChart: diagram :: Measurable a => Config -> BarChart a -> Diagram
- Graphics.BarChart: drawIntervals :: (Measurable a) => Intervals a -> BarChart a
+ Graphics.BarChart: drawIntervals :: Measurable a => Intervals a -> BarChart a
- Graphics.BarChart: drawMultiBarIntervals :: (Measurable a) => MultiBarIntervals a -> BarChart a
+ Graphics.BarChart: drawMultiBarIntervals :: Measurable a => MultiBarIntervals a -> BarChart a
- Graphics.BarChart: drawMultiBars :: (Measurable a) => MultiBars a -> BarChart a
+ Graphics.BarChart: drawMultiBars :: Measurable a => MultiBars a -> BarChart a
- Graphics.BarChart: mergeIntervals :: (Num a) => [(Label, Intervals a)] -> MultiBarIntervals a
+ Graphics.BarChart: mergeIntervals :: Num a => [(Label, Intervals a)] -> MultiBarIntervals a
- Graphics.BarChart: parseIntervals :: (Read a) => CSV -> Intervals a
+ Graphics.BarChart: parseIntervals :: Read a => CSV -> Intervals a
- Graphics.BarChart: parseMultiBarIntervals :: (Read a) => [Label] -> CSV -> MultiBarIntervals a
+ Graphics.BarChart: parseMultiBarIntervals :: Read a => [Label] -> CSV -> MultiBarIntervals a
- Graphics.BarChart: parseMultiBars :: (Read a) => [Label] -> CSV -> MultiBars a
+ Graphics.BarChart: parseMultiBars :: Read a => [Label] -> CSV -> MultiBars a
- Graphics.BarChart: render :: (Measurable a) => BarChart a -> IO ()
+ Graphics.BarChart: render :: Measurable a => BarChart a -> IO ()
- Graphics.BarChart: renderWith :: (Measurable a) => Config -> BarChart a -> IO ()
+ Graphics.BarChart: renderWith :: Measurable a => Config -> BarChart a -> IO ()
- Graphics.BarChart: size :: (Measurable a) => a -> Double
+ Graphics.BarChart: size :: Measurable a => a -> Double
Files
- README.markdown +21/−7
- barchart.cabal +7/−6
- src/barchart.hs +62/−168
README.markdown view
@@ -1,14 +1,18 @@-barchart is a command-line program for generating bar charts from CSV-files. It has special support for creating charts from data generated-by the Haskell benchmarking tools [criterion] and-[progression]. barchart can create PNG, SVG, PDF, and PS files using-the Haskell [Diagrams] library for rendering and, hence, depends on a-Haskell binding to Cairo which is part of [Gtk2Hs].+barchart is a command-line program with associated Haskell library for+generating bar charts from CSV files. It has special support for+creating charts from data generated by the Haskell benchmarking tools+[criterion] and [progression]. barchart can create PNG, SVG, PDF, and+PS files using the Haskell [Diagrams] library for rendering and,+hence, depends on a Haskell binding to Cairo which is part of+[Gtk2Hs]. # installation -available soon. be patient.+You can install barchart from [Hackage] using `cabal-install` which is+part of the [Haskell Platform] by typing: + cabal install barchart+ # usage Bar charts can be created from CSV files using the `barchart`@@ -162,6 +166,12 @@ `1.0` the bars are drawn directly next to each other, a value of 0.0 draws bars that are actually lines. +## api++If the `barchart` command-line program is insufficient for your needs,+you can use the provided [API] in your own Haskell applications to+generate custom bar charts.+ ## criterion [criterion] is a Haskell tool for statistically robust benchmarking@@ -311,6 +321,10 @@ [email]: mailto:sebf@informatik.uni-kiel.de [GitHub]: http://github.com/sebfisch/haskell-barchart [issues]: http://github.com/sebfisch/haskell-barchart/issues++[Hackage]: http://hackage.haskell.org/package/barchart+[Haskell Platform]: http://hackage.haskell.org/platform/+[API]: http://sebfisch.github.com/haskell-barchart/api/doc/html/barchart/index.html [guitar]: http://sebfisch.github.com/haskell-barchart/examples/guitar.png [guitar-mean]: http://sebfisch.github.com/haskell-barchart/examples/guitar-mean.png
barchart.cabal view
@@ -1,5 +1,5 @@ Name: barchart-Version: 0.1.1+Version: 0.1.1.1 Cabal-Version: >= 1.6 Synopsis: Creating Bar Charts in Haskell @@ -28,16 +28,17 @@ Main-is: barchart.hs Hs-Source-Dirs: src Build-Depends: base >= 3 && < 5,- cmdargs >= 0.1 && < 0.2, - csv >= 0.1 && < 1.2, + cmdargs >= 0.4 && < 0.7,+ csv >= 0.1 && < 1.2, diagrams >= 0.2 && < 0.3,- filepath >= 1.1 && < 1.2+ filepath >= 1.1 && < 1.3 Extensions: DeriveDataTypeable, FlexibleContexts, GeneralizedNewtypeDeriving, NamedFieldPuns, RecordWildCards, TypeFamilies+ GHC-Options: -fno-warn-missing-fields Library Exposed-Modules: Graphics.BarChart@@ -48,9 +49,9 @@ Graphics.BarChart.Parser.Progression Hs-Source-Dirs: src Build-Depends: base >= 3 && < 5,- csv >= 0.1 && < 1.2, + csv >= 0.1 && < 1.2, diagrams >= 0.2 && < 0.3,- filepath >= 1.1 && < 1.2+ filepath >= 1.1 && < 1.3 Extensions: FlexibleContexts, GeneralizedNewtypeDeriving, NamedFieldPuns,
src/barchart.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE NamedFieldPuns, RecordWildCards, DeriveDataTypeable #-} -import Graphics.BarChart hiding ( Intervals )+import Graphics.BarChart hiding ( Intervals, BarChart ) import Graphics.BarChart.Types ( readColor ) import Data.Char ( toLower )@@ -14,7 +14,7 @@ import qualified Graphics.Rendering.Diagrams as D -data ExecMode+data BarChart = Blocks { out_file, title, xlabel, ylabel :: String, file_type :: FileType, division, colors :: String,@@ -69,199 +69,91 @@ data Breakdown = Summary | Summary_Comparison | Benchmark_Comparison deriving (Eq,Show,Data,Typeable) +blocksMode :: BarChart blocksMode = Blocks { out_file = outFile conf- &= text "Name of generated file"- & typFile,- file_type = Guess_File_Type `enum`- [Guess_File_Type- &= text "Guess output file type by name (default)",- PNG &= text "Generate .png file",- SVG &= text "Generate .svg file",- PDF &= text "Generate .pdf file",- PS &= text "Generate .ps file"],+ &= help "Name of generated file"+ &= typFile,+ file_type = enum [Guess_File_Type+ &= help "Guess output file type by name (default)",+ PNG &= help "Generate .png file",+ SVG &= help "Generate .svg file"+ &= explicit+ &= name "svg",+ PDF &= help "Generate .pdf file",+ PS &= help "Generate .ps file"], title = caption conf- &= text "Title of bar chart"- & typString,+ &= help "Title of bar chart"+ &= typString, xlabel = xLabel conf- &= text "Label of x axis"- & typString,+ &= help "Label of x axis"+ &= typString, ylabel = xLabel conf- &= text "Label of y axis"- & typString,- division = "" &= text "Labels separated by whitespace"- & typStrings,- colors = "" &= text "Color names separated by whitespace"- & typStrings,+ &= help "Label of y axis"+ &= typString,+ division = "" &= help "Labels separated by whitespace"+ &= typStrings,+ colors = "" &= help "Color names separated by whitespace"+ &= typStrings, width = width- &= text "Width of generated bar chart"- & typ "NUM",+ &= help "Width of generated bar chart"+ &= typ "NUM", height = height- &= text "Height of generated bar chart"- & typ "NUM",- label_size = 12 &= text "Font size used for labels"- & typ "NUM",+ &= help "Height of generated bar chart"+ &= typ "NUM",+ label_size = 12 &= help "Font size used for labels"+ &= typ "NUM", bar_width = barRatio conf- &= text "Bar width between 0 and 1"- & flag "W"- & typ "FLOAT",- in_files = [] &= text "CVS files with data to visualise"- & args }+ &= help "Bar width between 0 and 1"+ &= name "W"+ &= typ "FLOAT",+ in_files = [] &= typ "FILES"+ &= args } where (width,height) = dimensions conf --- cannot reuse flag attributes in cmdargs :(-intervalsMode =- Intervals {- out_file = outFile conf- &= text "Name of generated file"- & typFile,- file_type = Guess_File_Type `enum`- [Guess_File_Type- &= text "Guess output file type by name (default)",- PNG &= text "Generate .png file",- SVG &= text "Generate .svg file",- PDF &= text "Generate .pdf file",- PS &= text "Generate .ps file"],- title = caption conf- &= text "Title of bar chart"- & typString,- xlabel = xLabel conf- &= text "Label of x axis"- & typString,- ylabel = xLabel conf- &= text "Label of y axis"- & typString,- division = "" &= text "Labels separated by whitespace"- & typStrings,- colors = "" &= text "Color names separated by whitespace"- & typStrings,- width = width- &= text "Width of generated bar chart"- & typ "NUM",- height = height- &= text "Height of generated bar chart"- & typ "NUM",- label_size = 12 &= text "Font size used for labels"- & typ "NUM",- bar_width = barRatio conf- &= text "Bar width between 0 and 1"- & flag "W"- & typ "FLOAT",- in_files = [] &= text "CVS files with data to visualise"- & args }- where (width,height) = dimensions conf+intervalsMode :: BarChart+intervalsMode = Intervals {} +criterionMode :: BarChart criterionMode = Criterion {- out_file = outFile conf- &= text "Name of generated file"- & typFile,- file_type = Guess_File_Type `enum`- [Guess_File_Type- &= text "Guess output file type by name (default)",- PNG &= text "Generate .png file",- SVG &= text "Generate .svg file",- PDF &= text "Generate .pdf file",- PS &= text "Generate .ps file"],- title = caption conf- &= text "Title of bar chart"- & typString,- xlabel = xLabel conf- &= text "Label of x axis"- & typString,- ylabel = xLabel conf- &= text "Label of y axis"- & typString,- division = "" &= text "Labels separated by whitespace"- & typStrings,- colors = "" &= text "Color names separated by whitespace"- & typStrings,- width = width- &= text "Width of generated bar chart"- & typ "NUM",- height = height- &= text "Height of generated bar chart"- & typ "NUM",- label_size = 12 &= text "Font size used for labels"- & typ "NUM",- bar_width = barRatio conf- &= text "Bar width between 0 and 1"- & flag "W"- & typ "FLOAT",- in_files = [] &= text "CVS files with data to visualise"- & args,- breakdown = Summary `enum`- [Summary- &= text "Show benchmark summary (default)",- Summary_Comparison- &= text "Compare different benchmark summaries"- & flag "s",- Benchmark_Comparison- &= text "Compare different benchmarks"- & flag "b"] }- where (width,height) = dimensions conf+ breakdown = enum [Summary+ &= help "Show benchmark summary (default)",+ Summary_Comparison+ &= help "Compare different benchmark summaries"+ &= name "s",+ Benchmark_Comparison+ &= help "Compare different benchmarks"+ &= name "b"] } +progressionMode :: BarChart progressionMode = Progression {- out_file = outFile conf- &= text "Name of generated file"- & typFile,- file_type = Guess_File_Type `enum`- [Guess_File_Type- &= text "Guess output file type by name (default)",- PNG &= text "Generate .png file",- SVG &= text "Generate .svg file",- PDF &= text "Generate .pdf file",- PS &= text "Generate .ps file"],- title = caption conf- &= text "Title of bar chart"- & typString,- xlabel = xLabel conf- &= text "Label of x axis"- & typString,- ylabel = xLabel conf- &= text "Label of y axis"- & typString,- division = "" &= text "Labels separated by whitespace"- & typStrings,- colors = "" &= text "Color names separated by whitespace"- & typStrings,- width = width- &= text "Width of generated bar chart"- & typ "NUM",- height = height- &= text "Height of generated bar chart"- & typ "NUM",- label_size = 12 &= text "Font size used for labels"- & typ "NUM",- bar_width = barRatio conf- &= text "Bar width between 0 and 1"- & flag "W"- & typ "FLOAT",- in_files = [] &= text "CVS files with data to visualise"- & args,- breakdown = Summary_Comparison `enum`- [Summary_Comparison- &= text "Breakdown chart by benchmark summary (default)"- & flag "s",- Benchmark_Comparison- &= text "Breakdown chart by benchmarks"- & flag "b"] }- where (width,height) = dimensions conf+ breakdown = enum [Summary_Comparison+ &= help "Breakdown chart by benchmark summary (default)"+ &= name "s",+ Benchmark_Comparison+ &= help "Breakdown chart by benchmarks"+ &= name "b"] } +typString, typStrings :: Ann typString = typ "STRING" typStrings = typ "STRINGS" -execModes = [blocksMode &= defMode,+execModes :: [BarChart]+execModes = [blocksMode &= auto, intervalsMode, criterionMode, progressionMode] +exitIf :: String -> Bool -> IO () exitIf msg cond = when cond (error msg) -main = do execMode <- cmdArgs "Bar Chart 0.0" (map mode execModes)+main :: IO ()+main = do execMode <- cmdArgs (modes execModes) exitIf "no input files given" $ null (in_files execMode) dispatch execMode +dispatch :: BarChart -> IO () dispatch mode@Blocks{..} = forM_ in_files $ \in_file -> writeMultiBarChart@@ -307,7 +199,7 @@ in_file (words division) -guessDefaults :: FilePath -> ExecMode -> ExecMode+guessDefaults :: FilePath -> BarChart -> BarChart guessDefaults in_file = guessColors . guessTitle . guessFileType . guessOutFile where guessOutFile mode =@@ -327,11 +219,13 @@ guessColors mode = mode { colors = colors mode ? "forestgreen firebrick midnightblue" } +guessBenchmarkDefaults :: FilePath -> BarChart -> BarChart guessBenchmarkDefaults in_file = guessAxis . guessDefaults in_file where guessAxis mode = mode { xlabel = xlabel mode ? "benchmark", ylabel = ylabel mode ? "run time" } +config :: BarChart -> Config config mode = Config { outFile = out_file mode, outputType = fromFileType $ file_type mode,