| Package | flare.vis.legend |
| Class | public class Legend |
| Inheritance | Legend flash.display.Sprite |
LegendItem instances
stored in the items sprite. Range legends consist of
a single LegendRange instance stored in the
items sprite.
There are multiple ways to generate a legend. To build a legend
based on an existing visual encoding, use the static
fromScale constructor. This method takes a data scale
and one more or more palettes (e.g., color, shape, or size palettes)
and uses them to generate an appropriate legend. If the data scale
is a quantitative scale and only a color palette is provided, a
continuous range legend will be generated. Otherwise, a discrete
legend will be created.
Legends can also be created from a collection of independent
values using the static fromValues constructor. This
method takes an array of legend item descriptions and uses them to
generate a legend. For example, consider this code:
var legend:Legend = Legend.fromValues("Legend Title", [
{color: 0xff0000, shape:Shapes.X, label:"Red X"},
{color: 0x00ff00, shape:Shapes.SQUARE, label:"Green Square"},
{color: 0x0000ff, shape:Shapes.CIRCLE, label:"Blue Circle"}
]);
This example will create a legend with the described values.
See the documentation for the buildFromValues method
for more details.
| Property | Defined by | ||
|---|---|---|---|
| baseIconSize : Number Base icon size, corresponding to a size factor of 1.
| Legend | ||
| border : RectSprite
[read-only] Sprite defining the border of the legend.
| Legend | ||
| bounds : Rectangle The layout bounds for this legend instance.
| Legend | ||
| colorPalette : ColorPalette
The color palette used to encode values (may be null).
| Legend | ||
| defaultColor : uint The default color to use for legend items.
| Legend | ||
| discrete : Boolean [read-only] Flag indicating if this legend is discrete or continuous.
| Legend | ||
| items : Sprite [read-only] Sprite containing the legend items.
| Legend | ||
| labelTextFormat : TextFormat TextFormat (font, size, style) of legend item labels.
| Legend | ||
| labelTextMode : int Label text mode.
| Legend | ||
| margin : Number Margins within legend items.
| Legend | ||
| orientation : String The desired orientation of this legend.
| Legend | ||
| range : LegendRange
[read-only] The legend range, if this legend is continuous.
| Legend | ||
| scale : Scale
Scale instance used to define the legend mapping.
| Legend | ||
| shapePalette : ShapePalette
The shape palette used to encode values (may be null).
| Legend | ||
| sizePalette : SizePalette
The size palette used to encode values (may be null).
| Legend | ||
| spacing : Number Spacing between legend items.
| Legend | ||
| title : TextSprite
[read-only] TextSprite containing the legend title.
| Legend | ||
| Method | Defined by | ||
|---|---|---|---|
|
Legend(title:String, scale:Scale = null, colors:ColorPalette = null, shapes:ShapePalette = null, sizes:SizePalette = null)
Creates a new Legend for the given data field.
| Legend | ||
|
buildFromScale():void
Builds the contents of this legend from the current scale values.
| Legend | ||
|
buildFromValues(values:Array):void
Populates the contents of this legend from a list of value objects.
| Legend | ||
|
[static]
Generates a legend from a given scale and one or more palettes.
| Legend | ||
|
fromValues(title:String, values:Array):Legend
[static]
Generates a legend from an array of legend item values.
| Legend | ||
|
layout(t:Transitioner = null):void
Performs layout, setting the position for all items in the legend.
| Legend | ||
|
setItemProperties(vals:Object, t:* = null):Transitioner
Sets property values on all legend items.
| Legend | ||
|
Update the legend, recomputing layout of items.
| Legend | ||
| baseIconSize | property |
baseIconSize:Number [read-write]Base icon size, corresponding to a size factor of 1.
Implementation public function get baseIconSize():Number
public function set baseIconSize(value:Number):void
| border | property |
border:RectSprite [read-only]Sprite defining the border of the legend.
Implementation public function get border():RectSprite
| bounds | property |
bounds:Rectangle [read-write]The layout bounds for this legend instance.
Implementation public function get bounds():Rectangle
public function set bounds(value:Rectangle):void
| colorPalette | property |
colorPalette:ColorPalette [read-write]The color palette used to encode values (may be null).
Implementation public function get colorPalette():ColorPalette
public function set colorPalette(value:ColorPalette):void
| defaultColor | property |
defaultColor:uint [read-write]The default color to use for legend items.
Implementation public function get defaultColor():uint
public function set defaultColor(value:uint):void
| discrete | property |
discrete:Boolean [read-only]Flag indicating if this legend is discrete or continuous.
Implementation public function get discrete():Boolean
| items | property |
items:Sprite [read-only]Sprite containing the legend items.
Implementation public function get items():Sprite
| labelTextFormat | property |
labelTextFormat:TextFormat [read-write]TextFormat (font, size, style) of legend item labels.
Implementation public function get labelTextFormat():TextFormat
public function set labelTextFormat(value:TextFormat):void
| labelTextMode | property |
labelTextMode:int [read-write]Label text mode.
Implementation public function get labelTextMode():int
public function set labelTextMode(value:int):void
| margin | property |
margin:Number [read-write]Margins within legend items.
Implementation public function get margin():Number
public function set margin(value:Number):void
| orientation | property |
orientation:String [read-write]The desired orientation of this legend.
Implementation public function get orientation():String
public function set orientation(value:String):void
| range | property |
range:LegendRange [read-only]The legend range, if this legend is continuous. This value is null if the legend is discrete.
Implementation public function get range():LegendRange
| scale | property |
scale:Scale [read-write]Scale instance used to define the legend mapping.
Implementation public function get scale():Scale
public function set scale(value:Scale):void
| shapePalette | property |
shapePalette:ShapePalette [read-write]The shape palette used to encode values (may be null).
Implementation public function get shapePalette():ShapePalette
public function set shapePalette(value:ShapePalette):void
| sizePalette | property |
sizePalette:SizePalette [read-write]The size palette used to encode values (may be null).
Implementation public function get sizePalette():SizePalette
public function set sizePalette(value:SizePalette):void
| spacing | property |
spacing:Number [read-write]Spacing between legend items.
Implementation public function get spacing():Number
public function set spacing(value:Number):void
| title | property |
title:TextSprite [read-only]TextSprite containing the legend title.
Implementation public function get title():TextSprite
| Legend | () | constructor |
public function Legend(title:String, scale:Scale = null, colors:ColorPalette = null, shapes:ShapePalette = null, sizes:SizePalette = null)Creates a new Legend for the given data field.
Parameterstitle:String — the data field to describe with the legend
|
|
scale:Scale (default = null) — the visualization corresponding to this legend
|
|
colors:ColorPalette (default = null) — the scale value used to map the data field to visual
variables
|
|
shapes:ShapePalette (default = null) |
|
sizes:SizePalette (default = null) |
| buildFromScale | () | method |
public function buildFromScale():voidBuilds the contents of this legend from the current scale values. This method will remove all items from the legend and rebuild the legend using the current scale and palette settings.
| buildFromValues | () | method |
public function buildFromValues(values:Array):void
Populates the contents of this legend from a list of value objects.
This method will create a legend with discrete entries determined by
the contents of the input values array. This should be
an array of objects containing the following properties:
value: The data value the legend item represents.
This value is not required.label: The text label to place in the legend item.
If this value is not provided, the method will attempt to
generate a label string from the value property.color: The color for the legend item. If missing,
this legend's default color will be used.shape: The shape for the legend item. If missing,
a default circle shape will be used.size: The size for the legend item. If missing,
a size value of 1 will be used.values:Array — an array of value to include in the legend.
|
| fromScale | () | method |
public static function fromScale(title:String, scale:Scale, palette:Palette, ... args):LegendGenerates a legend from a given scale and one or more palettes. If multiple palettes of the same type are provided, only the first of each type will be used for the legend, the others will be ignored.
Parameterstitle:String — the title text for the legend
|
|
scale:Scale — the scale instance determining the legend values
|
|
palette:Palette — a color, shape, or size palette for legend items
|
|
... args — one or more additional palettes
|
Legend —
the generated Legend, or null if a legend could not be built
|
| fromValues | () | method |
public static function fromValues(title:String, values:Array):Legend
Generates a legend from an array of legend item values. This method
simply instantiates a new Legend instance with the
given title and then invokes the buildFromValues method
with the given value array.
title:String — the legend title text, or null for no title.
|
|
values:Array — an array of values for the legend items. See the
documentation for the buildFromValues method for more.
|
Legend —
the generated legend
|
| layout | () | method |
public function layout(t:Transitioner = null):voidPerforms layout, setting the position for all items in the legend.
Parameterst:Transitioner (default = null) — a transitioner for value updates
|
| setItemProperties | () | method |
public function setItemProperties(vals:Object, t:* = null):Transitioner
Sets property values on all legend items. The values
within the vals argument can take a number of forms:
Function, it will be evaluated
for each element and the result will be used as the property
value for that element.IEvaluable instance, such as
flare.util.Property or
flare.query.Expression, it will be evaluated for
each element and the result will be used as the property value
for that element.vals:Object — an object containing the properties and values to set.
|
|
t:* (default = null) — a transitioner or time span for updating object values. If
the input is a transitioner, it will be used to store the updated
values. If the input is a number, a new Transitioner with duration
set to the input value will be used. The input is null by default,
in which case object values are updated immediately.
|
Transitioner —
the transitioner used to update the values
|
| update | () | method |
public function update(t:Transitioner = null):TransitionerUpdate the legend, recomputing layout of items.
Parameterst:Transitioner (default = null) — a transitioner for value updates
|
Transitioner —
the input transitioner
|