timeplot 0.3.2 → 0.3.3
raw patch · 3 files changed
+15/−12 lines, 3 files
Files
- Graphics/Rendering/Chart/Event.hs +6/−5
- Tools/TimePlot.hs +8/−6
- timeplot.cabal +1/−1
Graphics/Rendering/Chart/Event.hs view
@@ -21,7 +21,8 @@ import Data.Accessor.Template import Control.Monad -data Event t e = LongEvent t t e -- ^ An event that has a beginning and an end+data Event t e = LongEvent (t,Bool) (t,Bool) e -- ^ An event that has a beginning and an end. + -- True = "known explicitly", False = "implicit" (e.g. imposed by axis bounds) | PulseEvent t e -- ^ A zero-length event deriving (Show) @@ -86,7 +87,7 @@ (Point x1 y1) = pmap (LMax,LMax) (cx,cy) = ((x0+x1)/2, (y0+y1)/2) drawEventFill (PulseEvent t e) = return ()- drawEventFill (LongEvent t1 t2 e) = do+ drawEventFill (LongEvent (t1,_) (t2,_) e) = do let (Point x1 cy) = pmap (LValue t1, LValue e) let (Point x2 cy') = pmap (LValue t2, LValue e) -- Assume cy' == cy (pmap is coordinate-wise) filledRect (plot_event_long_fillstyle_ p e) $ Rect@@ -104,7 +105,7 @@ moveTo (Point x (y - pulseHeight/2 - C.textExtentsHeight extents - C.textExtentsYbearing extents - 1)) setLineStyle $ solidLine 2 (opaque black) c $ C.showText label- drawEventFrame (LongEvent t1 t2 e) = do+ drawEventFrame (LongEvent (t1,_) (t2,_) e) = do let (Point x1 cy) = pmap (LValue t1, LValue e) let (Point x2 cy') = pmap (LValue t2, LValue e) -- Assume cy' == cy (pmap is coordinate-wise) framedRect (plot_event_long_linestyle_ p e) $ Rect@@ -114,7 +115,7 @@ plotAllPointsEvent p = let (ts, es) = unzip (map decomp d) in (concat ts, es) where d = plot_event_data_ p- decomp (PulseEvent t e) = ([t], e)- decomp (LongEvent t1 t2 e) = ([t1,t2], e)+ decomp (PulseEvent t e) = ([t], e)+ decomp (LongEvent (t1,_) (t2,_) e) = ([t1,t2], e) $( deriveAccessors ''PlotEvent )
Tools/TimePlot.hs view
@@ -342,7 +342,7 @@ KindDots -> withAnyOrdinate $ plotTrackDots name es KindSum bs ss -> withAnyOrdinate $ plotTrackSum name es bs ss KindCumSum ss -> withAnyOrdinate $ plotTrackCumSum name es ss- KindDuration sk -> plotWithKind name sk (edges2durations (edges es) minTime maxTime)+ KindDuration sk -> plotWithKind name sk (edges2durations (edges es) minTime maxTime name) KindWithin _ _ -> error "KindDuration should not be plotted" KindNone -> error "KindNone should not be plotted" @@ -540,8 +540,10 @@ layout1_grid_last ^= True $ defaultLayout1 -edges2durations :: forall t. (Ord t, HasDelta t) => [(t,S.ByteString,Edge)] -> t -> t -> [(t,InEvent)]-edges2durations tes minTime maxTime = [(t2, InValue track $ toSeconds (t2 `sub` t1) (undefined::t)) | (track,LongEvent t1 t2 _) <- edges2events tes minTime maxTime]+edges2durations :: forall t. (Ord t, HasDelta t) => [(t,S.ByteString,Edge)] -> t -> t -> S.ByteString -> [(t,InEvent)]+edges2durations tes minTime maxTime commonTrack = + [(t2, InValue commonTrack $ toSeconds (t2 `sub` t1) (undefined::t)) + | (track, LongEvent (t1,True) (t2,True) _) <- edges2events tes minTime maxTime] edges2events :: (Ord t) => [(t,S.ByteString,Edge)] -> t -> t -> [(S.ByteString,Event t Status)] edges2events tes minTime maxTime = snd $ RWS.execRWS (mapM_ step tes >> flush) () M.empty @@ -559,17 +561,17 @@ step (t,s,Pulse st) = RWS.tell [(s, PulseEvent t st)] step (t,s,SetTo st) = trackCase s (putTrack s (t, 1, st))- (\t0 n st0 -> RWS.tell [(s, LongEvent t0 t st0)] >> + (\t0 n st0 -> RWS.tell [(s, LongEvent (t0,True) (t,True) st0)] >> putTrack s (t, n, st)) step (t,s,Rise) = trackCase s (putTrack s (t, 1, emptyStatus)) (\t0 n st -> putTrack s (t, n+1, st)) step (t,s,Fall) = do (t0, numActive, st) <- getTrack s case numActive of- 1 -> RWS.tell [(s, LongEvent t0 t st)] >> killTrack s+ 1 -> RWS.tell [(s, LongEvent (t0,True) (t,True) st)] >> killTrack s n -> putTrack s (t0, max 0 (n-1), st) - flush = RWS.get >>= mapM_ (\(s, (t0,_,st)) -> RWS.tell [(s, LongEvent t0 maxTime st)]) . M.toList+ flush = RWS.get >>= mapM_ (\(s, (t0,_,st)) -> RWS.tell [(s, LongEvent (t0,True) (maxTime,False) st)]) . M.toList edges2bins :: forall t. (Ord t,HasDelta t,Show t) => Delta t -> t -> t -> [(t,S.ByteString,Edge)] -> [((t,t), [(S.ByteString,Double)])] edges2bins binSize minTime maxTime es = snd $ RWS.execRWS (mapM_ step es >> flush) () (M.empty, iterate (add binSize) minTime)
timeplot.cabal view
@@ -1,5 +1,5 @@ name: timeplot-version: 0.3.2+version: 0.3.3 cabal-version: >=1.6 build-type: Simple license: BSD3