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