ushalow
[clean-tests.git] / old / timegraph / TimeGraph / TimeGraph.dcl
1 definition module TimeGraph
2
3 import iTasks.WF.Definition
4 import iTasks.UI.JS.Encoding
5 import Graphics.Scalable.Image
6
7 :: TimeGraphOptions a
8 = { valueSpan :: a -> Span // turn value into rendering distance
9 , measures :: [TimeGraphMeasure a] // the measures that are drawn across the graph
10 , distance :: Span // the distance between two neighbouring values
11 , maxValue :: a // the maximum value that can be rendered visibly
12 , maxNoElts :: Int // the maximum number of elements that are rendered
13 }
14 :: TimeGraphMeasure a
15 = { base :: a // the value at which the measure is rendered
16 , label :: String // the label of the measure
17 , left :: Bool // if True, label is rendered at left of graph, otherwise at right of graph
18 , font :: FontDef // the font used to render this label
19 }
20
21 /** time_graph options values:
22 is a task that renders @values in a graph using @options.
23 The number of values that are shown is controlled by @options.maxNoElts.
24 The dimensions of the graph are controlled by @options.distance (the width of each bar) and the application of
25 the function @options.valueSpan to the displayed value (the height of each bar).
26 The maximum value that can be displayed is controlled by @options.maxValue.
27 The @options.measures show labelled lines across the bars. The position of the label is controlled by the .left
28 field of the measure. The height is controlled by the .base field of the measure. Each label can have a different
29 font, defined by the .font field of the measure.
30 */
31 time_graph :: !(TimeGraphOptions a) ![a] -> Task [a] | JSEncode{|*|}, JSDecode{|*|}, iTask a