X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=timegraph%2FTimeGraph%2FTimeGraph.dcl;fp=timegraph%2FTimeGraph%2FTimeGraph.dcl;h=4313cb8ccd303efe390e3a4fb20067e671a6a5e1;hb=9b250e33701c0905600c8bd403c0d72fa76d64b8;hp=0000000000000000000000000000000000000000;hpb=9d093d11da012724253e1a3b31d3f1af94b4e1bd;p=clean-tests.git diff --git a/timegraph/TimeGraph/TimeGraph.dcl b/timegraph/TimeGraph/TimeGraph.dcl new file mode 100644 index 0000000..4313cb8 --- /dev/null +++ b/timegraph/TimeGraph/TimeGraph.dcl @@ -0,0 +1,31 @@ +definition module TimeGraph + +import iTasks.WF.Definition +import iTasks.UI.JS.Encoding +import Graphics.Scalable.Image + +:: TimeGraphOptions a + = { valueSpan :: a -> Span // turn value into rendering distance + , measures :: [TimeGraphMeasure a] // the measures that are drawn across the graph + , distance :: Span // the distance between two neighbouring values + , maxValue :: a // the maximum value that can be rendered visibly + , maxNoElts :: Int // the maximum number of elements that are rendered + } +:: TimeGraphMeasure a + = { base :: a // the value at which the measure is rendered + , label :: String // the label of the measure + , left :: Bool // if True, label is rendered at left of graph, otherwise at right of graph + , font :: FontDef // the font used to render this label + } + +/** time_graph options values: + is a task that renders @values in a graph using @options. + The number of values that are shown is controlled by @options.maxNoElts. + The dimensions of the graph are controlled by @options.distance (the width of each bar) and the application of + the function @options.valueSpan to the displayed value (the height of each bar). + The maximum value that can be displayed is controlled by @options.maxValue. + The @options.measures show labelled lines across the bars. The position of the label is controlled by the .left + field of the measure. The height is controlled by the .base field of the measure. Each label can have a different + font, defined by the .font field of the measure. +*/ +time_graph :: !(TimeGraphOptions a) ![a] -> Task [a] | JSEncode{|*|}, JSDecode{|*|}, iTask a