module Simulation.Aivika.Experiment.SamplingStatsWriter
(SamplingStatsWriter(..),
defaultSamplingStatsWriter) where
import Simulation.Aivika.Experiment.Types
import Simulation.Aivika.Experiment.HtmlWriter
import Simulation.Aivika.Statistics
data SamplingStatsWriter a =
SamplingStatsWriter { samplingStatsWidth :: Int,
samplingStatsMeanText :: String,
samplingStatsDeviationText :: String,
samplingStatsMinText :: String,
samplingStatsMaxText :: String,
samplingStatsCountText :: String,
samplingStatsFormatter :: ShowS,
samplingStatsWrite :: SamplingStatsWriter a -> String ->
SamplingStats a -> HtmlWriter ()
}
defaultSamplingStatsWriter :: Show a => SamplingStatsWriter a
defaultSamplingStatsWriter =
SamplingStatsWriter {
samplingStatsWidth = 400,
samplingStatsMeanText = "mean",
samplingStatsDeviationText = "deviation",
samplingStatsMinText = "minimum",
samplingStatsMaxText = "maximum",
samplingStatsCountText = "count",
samplingStatsFormatter = id,
samplingStatsWrite = \writer name stats ->
do let format x = samplingStatsFormatter writer x
writeHtml "<p>"
writeHtml "<table frame='border' cellspacing='4' width='"
writeHtml $ show $ samplingStatsWidth writer
writeHtml "'>"
writeHtml "<tr>"
writeHtml "<td colspan='2'>"
writeHtml "<p align='center'>"
writeHtmlText name
writeHtml "</h4>"
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ samplingStatsMeanText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ samplingStatsMean stats
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ samplingStatsDeviationText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ samplingStatsDeviation stats
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ samplingStatsMinText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ samplingStatsMin stats
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ samplingStatsMaxText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ samplingStatsMax stats
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ samplingStatsCountText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtml $ format $ show $ samplingStatsCount stats
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "</table>"
writeHtml "</p>"
}