(lispkit draw chart)
Library (lispkit draw chart) provides abstractions that are shared between the various chart libraries of LispKit, such as (lispkit draw chart bar) and (lispkit draw chart function). Currently, this library defines a single record type, legend-config, which encapsulates the parameters needed for drawing a legend within a chart. A legend links labels (e.g. names of bar segments or function graphs) to the colors used to visually distinguish them in a chart.
Chart-specific libraries typically provide their own constructor for legend configurations (e.g. make-bar-chart-config from (lispkit draw chart bar) or make-function-legend-config from (lispkit draw chart function)) that come with defaults tailored to the corresponding chart type. The accessor and mutator procedures for legend configuration objects, however, are defined once, centrally, by this library and are used by all chart libraries.
Legends
A legend configuration is a record encapsulating all parameters needed for drawing a legend. Legend configurations are mutable objects that are created via procedure make-legend-config (or via a chart-specific constructor such as make-bar-chart-config or make-function-legend-config). For every parameter, there is an accessor and a setter procedure.
(make-legend-config key val ...) ![]()
Creates a new legend configuration object from the provided keyword/value pairs. The following keyword arguments are supported. The default value is provided in parenthesis.
font:Font used for all text in a legend (Helvetica 10).color:Color used for legend labels and the border of the legend's bounding box (black).bg-color:Background color of the legend's bounding box (white).stroke-width:Width of a stroke for drawing the bounding box of the legend (1).corner-radius:Corner radius for a rounded bounding box;0results in a rectangular bounding box with square corners (0).horizontal-offset:Horizontal offset from chart bounds. A non-negative value is interpreted as an offset from the left bound; a negative value is interpreted as an offset from the right bound (70).vertical-offset:Vertical offset from chart bounds. A non-negative value is interpreted as an offset from the top bound; a negative value is interpreted as an offset from the bottom bound (10).sample-area-width:Width of the area reserved for the color sample box in front of each legend label (17).sample-length:Height and width of the color sample box shown for each entry of the legend (10).line-pad:Padding between two consecutive lines/entries of the legend (3).entry-pad:Top/bottom and left/right padding between the legend entries and the bounding box of the legend (6).
(legend-config? obj) ![]()
Returns #t if obj is a legend configuration object, #f otherwise.
(legend-font lconf) ![]()
Returns the font defined by the given legend configuration lconf.
(legend-font-set! lconf font) ![]()
Sets the font for the given legend configuration lconf to font.
(legend-color lconf) ![]()
Returns the color used for legend labels and the bounding box border defined by the given legend configuration lconf. Some chart libraries fall back to a chart-specific default color if lconf does not define a color (i.e. legend-color returns #f).
(legend-color-set! lconf color) ![]()
Sets the color used for legend labels and the bounding box border for the given legend configuration lconf to color.
(legend-bg-color lconf) ![]()
Returns the background color of the legend's bounding box defined by the given legend configuration lconf. Some chart libraries fall back to a chart-specific default background color if lconf does not define a background color (i.e. legend-bg-color returns #f).
(legend-bg-color-set! lconf color) ![]()
Sets the background color of the legend's bounding box for the given legend configuration lconf to color.
(legend-stroke-width lconf) ![]()
Returns the stroke width defined by the given legend configuration lconf, i.e. the width used for drawing the border of the legend's bounding box.
(legend-stroke-width-set! lconf val) ![]()
Sets the stroke width for the given legend configuration lconf to val.
(legend-corner-radius lconf) ![]()
Returns the corner radius defined by the given legend configuration lconf, used for drawing a rounded bounding box around the legend. A value of 0 results in a rectangular bounding box with square corners.
(legend-corner-radius-set! lconf val) ![]()
Sets the corner radius for the given legend configuration lconf to val.
(legend-horizontal-offset lconf) ![]()
Returns the horizontal offset defined by the given legend configuration lconf. A non-negative value is interpreted as an offset of the legend from the left bound of the chart; a negative value is interpreted as an offset from the right bound.
(legend-horizontal-offset-set! lconf val) ![]()
Sets the horizontal offset for the given legend configuration lconf to val.
(legend-vertical-offset lconf) ![]()
Returns the vertical offset defined by the given legend configuration lconf. A non-negative value is interpreted as an offset of the legend from the top bound of the chart; a negative value is interpreted as an offset from the bottom bound.
(legend-vertical-offset-set! lconf val) ![]()
Sets the vertical offset for the given legend configuration lconf to val.
(legend-sample-area-width lconf) ![]()
Returns the sample area width defined by the given legend configuration lconf, i.e. the width reserved in front of each label for the color sample box.
(legend-sample-area-width-set! lconf val) ![]()
Sets the sample area width for the given legend configuration lconf to val.
(legend-sample-length lconf) ![]()
Returns the sample length defined by the given legend configuration lconf, i.e. the height and width of the color sample box (for bar charts) or the length of the color sample line (for function charts) shown for each legend entry.
(legend-sample-length-set! lconf val) ![]()
Sets the sample length for the given legend configuration lconf to val.
(legend-line-pad lconf) ![]()
Returns the line padding defined by the given legend configuration lconf, i.e. the vertical padding between two consecutive legend entries.
(legend-line-pad-set! lconf val) ![]()
Sets the line padding for the given legend configuration lconf to val.
(legend-entry-pad lconf) ![]()
Returns the entry padding defined by the given legend configuration lconf, i.e. the top/bottom and left/right padding between the legend entries and the bounding box of the legend.
(legend-entry-pad-set! lconf val) ![]()
Sets the entry padding for the given legend configuration lconf to val.
Last updated