charts: add optional axes slot

char-rename
Alexander Iljin 2017-01-22 00:51:30 +03:00 committed by John Benediktsson
parent 0c9cb2f0a7
commit c2f8572393
1 changed files with 7 additions and 3 deletions

View File

@ -1,15 +1,19 @@
! Copyright (C) 2016-2017 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel ui.gadgets ;
USING: accessors arrays kernel sequences ui.gadgets ;
IN: charts
TUPLE: chart < gadget ;
TUPLE: chart < gadget axes ;
M: chart pref-dim* drop { 300 300 } ;
! Return the x and y ranges of the visible area.
: chart-axes ( chart -- seq )
drop { { 0 300 } { 0 300 } } ;
[ dim>> ] [ axes>> ] bi [
nip
] [
[ 0 swap 2array ] map
] if* ;
! Return the { width height } of the visible area, in pixels.
: chart-dim ( chart -- seq ) dim>> ;