charts: scale the chart to the gadget size

char-rename
Alexander Iljin 2017-01-20 15:43:38 +03:00 committed by John Benediktsson
parent 88b1770cca
commit 41f520d606
1 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2016-2017 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel ui.gadgets ;
USING: accessors kernel ui.gadgets ;
IN: charts
TUPLE: chart < gadget ;
@ -11,13 +11,12 @@ M: chart pref-dim* drop { 300 300 } ;
: chart-axes ( chart -- seq )
drop { { 0 300 } { 0 300 } } ;
! Return the width and height of the visible area, in pixels.
: chart-dim ( chart -- seq )
drop { 300 300 } ;
! Return the { width height } of the visible area, in pixels.
: chart-dim ( chart -- seq ) dim>> ;
! There are several things to do to present data on the screen.
! Map the data coordinates to the screen coordinates.
! Cut off data outside the presentation window. When cutting off vertically, split the line into segments and add new points if necessary. Return an array of line segments.
! Remove redundant points from the drawing pass.
! chart new line new COLOR: blue >>color { { 0 100 } { 100 0 } { 100 50 } { 150 50 } { 200 100 } } >>data add-gadget gadget.
! chart new line new COLOR: blue >>color { { 0 100 } { 100 0 } { 100 50 } { 150 50 } { 200 100 } } >>data add-gadget "Chart" open-window