 ! Copyright (C) 2016-2017 Alexander Ilin.
 
 USING: accessors arrays binary-search charts
-combinators.short-circuit kernel locals math math.order
+combinators.short-circuit fry kernel locals math math.order
 math.statistics math.vectors opengl opengl.gl sequences
-specialized-arrays.instances.alien.c-types.float ui.gadgets
-ui.render ;
+specialized-arrays.instances.alien.c-types.float
+splitting.monotonic ui.gadgets ui.render ;
 IN: charts.lines
 
 ! Data must be a sequence of { x y } coordinates sorted by

        2drop { } clone
    ] if ;

! Split data into chunks to be drawn within the [ymin,ymax] limits.
! Return the (empty?) sequence of chunks, possibly with some new
! points at ymin and ymax at the gap bounds.
: drawable-chunks ( ymin,ymax data -- chunks )
    1array nip ;

PRIVATE>


    dup parent>> dup chart? [
        chart-axes swap
        [ color>> gl-color ] [ data>> ] bi
        dupd clip-data swap second drawable-chunks
        [ [ draw-line ] each ] unless-empty
    ] [ 2drop ] if ;
