|(require plot-container)||package: plot-container|
Create a new instance of a plot-container% which will arrange plot snip% objects in columns columns with spacing pixels between them. The number of rows will be determined by the number of plot snips added. Additional init argyments can be passed in, they will all go to the editor-canvas% class, see its documentation for what options are available.Return the dimensions of a plot snip when this plot-container% would hold snip-count snips. The dimensions will be calculated based on the current size of the canvas plus the number of columns and spacing between snips.
This method can be used to construct the plot snip instances with the correct dimensions and avoid a snip resize operation when these snips are added to the container.
WARNING: The cell dimensions are only valid if the snips are arranged in rows and columns by calling set-snips. If a layout is used, as per set-snips/layout, the cell dimensions returned by this method will not correspond to the ones assigned to the snips in the layout.Clear all snips from the container.Set snip as the only snip managed by the container, replacing any previous plot snips.Set the contents of the container to the snip instances passed in as paramters, replacing any previous plot snips.Set the contents of the container to the group, which is a group of snips created using hgroup, vgroup and cgroup. This method allows subdividing the contents of the container area in a tree-like fashion.Add snip as a floating snip to the container and place it at x, y. Any previous floating snips will be kept as well.Remove all existing floating snips, than add snip as a floating snip to the container and place it at x, y.Set a message to be displayed in the plot container when it contains no snips at all. If the message is #f, no message will be displayed.Set pict to be displayed at locations x, y, or hide the pict when #f. The pict will be displayed on top of all other snips in the container and can be used to implement tool tips for the contents of the container.
(send a-plot-container set-hover-pict-at-mouse-event pict event) → any/c pict : (or/c #f pict?) event : (is-a?/c mouse-event%)Display pict at the location of the mouse event. This method will take the mouse event coordinates, convert them to plot container coordinates and call set-hover-pict.
(vgroup item ... [ #:border border #:spacing spacing]) → plot-container-group? item : (listof (or/c plot-container-group? (is-a?/c snip%))) border : (or/c positive? zero?) = 0 spacing : (or/c positive? zero?) = 5
(hgroup item ... [ #:border border #:spacing spacing]) → plot-container-group? item : (listof (or/c plot-container-group? (is-a?/c snip%))) border : (or/c positive? zero?) = 0 spacing : (or/c positive? zero?) = 5
(cgroup columns item ... [ #:border border #:spacing spacing]) → plot-container-group? columns : positive-integer? item : (listof (or/c plot-container-group? (is-a?/c snip%))) border : (or/c positive? zero?) = 0 spacing : (or/c positive? zero?) = 5
vgroup will place items in one vertical column with the height equally divided between all items.
hgroup will place items in one horizontal row with the width equally divided between all items.
cgroup will place all items in columns, with the number of rows depending on the number of itmes. The width is divided equally between the number of columns and the height is divided equally between the number of rows.
This module provides a collection of helper functions for building interactive plots. The plot-snip function returns a snip% representing the plot, and this snip has two additional methods, set-mouse-event-callback and set-overlay-renderers, which help with this. See the plot documentation for 2d-plot-snip% for more details.
The parameters are considered valid when the coordinates x and y are not #f, the mouse event is a motion event and the plot snip is directly under the mouse with no other snips above it.
The x, y coordinates can be #f when they are inside the plot snip but not on the plot itself, for example in the axes area.
This function encapsulates all the logic on whether to add or clear overlay renderers from a plot, and allows writing hover callbacks in the following form:
(define (hover-callback snip event x y) (if (good-hover? snip x y event) ; Need to add overlay renderers for position x,y (send snip set-overlay-renderers ...) ; Need to clear any overlay renderers (send snip set-overlay-renderers #f)))
(xposition->histogram-slot xposition [ skip gap])
(or/c #f exact-nonnegative-integer?) (or/c #f exact-nonnegative-integer?) xposition : number? skip : number? = () gap : number? = ()
Returns two values, the series, when multiple historams are plotted and the slot within that histogram. Will return (values #f #f) if the X position is between the bars of the histogram.
Assumes the snip is added to an editor.