Legend class
The legend of a chart. By default it shows one entry per data set, or one per color for data sets with several colors, recomputed whenever the chart data changes. Assign entries to show your own entries instead. Sizes and spacings are in dp and converted to px in calculateDimensions.
Kotlin's Legend() and Legend(entries) constructors are one constructor with an optional list.
- Inheritance
-
- Object
- ComponentBase
- Legend
Constructors
-
Legend([List<
LegendEntry> ? entries]) -
Creates a legend; with
entriesit is a custom legend that shows them.
Properties
-
calculatedLabelBreakPoints
→ List<
bool> -
Per entry, whether a new row starts with it. Filled by calculateDimensions for a horizontal legend.
final
-
calculatedLabelSizes
→ List<
FSize> -
Label size in px per entry, in entry order. Filled by calculateDimensions for a horizontal legend.
final
-
calculatedLineSizes
→ List<
FSize> -
Size in px of each row. Filled by calculateDimensions for a horizontal legend.
final
- direction ↔ LegendDirection
-
Order of form and label within an entry. Default LegendDirection.LEFT_TO_RIGHT.
getter/setter pair
-
entries
↔ List<
LegendEntry> -
Entries to draw. Assigning them makes the legend custom, so it stops mirroring the data sets until
resetCustom. An entry with a null label draws only its form, stacked with the next entry.
getter/setter pair
-
extraEntries
↔ List<
LegendEntry> -
Entries appended after the computed ones the next time the chart data changes. Ignored by a custom legend. See
setExtra.
getter/setter pair
- form ↔ LegendForm
-
Form drawn for entries whose own form is LegendForm.DEFAULT. Default LegendForm.SQUARE.
getter/setter pair
- formLineDashEffect ↔ DashPathEffect?
-
Dash pattern of LegendForm.LINE forms, used by entries without their own; null draws solid lines.
getter/setter pair
- formLineWidth ↔ double
-
Stroke width in dp of LegendForm.LINE forms, used by entries whose own width is NaN. Default 3.
getter/setter pair
- formSize ↔ double
-
Size of the forms in dp, used by entries whose own size is NaN. Default 8.
getter/setter pair
- formToTextSpace ↔ double
-
Space in dp between a form and its label. Default 5.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- horizontalAlignment ↔ LegendHorizontalAlignment
-
Horizontal placement of the legend. Default LegendHorizontalAlignment.LEFT.
getter/setter pair
- isDrawInsideEnabled ↔ bool
-
Whether the legend is drawn over the content area instead of the chart reserving space for it. Default false.
getter/setter pair
- isEnabled ↔ bool
-
Whether the component is drawn at all. Default true.
getter/setter pairinherited
- isLegendCustom → bool
-
Whether entries were assigned rather than computed from the data sets. Default false.
no setter
- isWordWrapEnabled ↔ bool
-
Whether a horizontal legend breaks into several rows instead of being cut off. Costs performance. Default false.
getter/setter pair
- maxSizePercent ↔ double
-
Largest share of the chart the legend may take, 0..1: of the width for a vertical legend at the side, of the
height for a horizontal one. A wrapping horizontal legend breaks its rows at this share of the content width.
Default 0.95.
getter/setter pair
- neededHeight ↔ double
-
Total height in px the legend needs, including yOffset. Set by calculateDimensions.
getter/setter pair
- neededWidth ↔ double
-
Total width in px the legend needs, including xOffset. Set by calculateDimensions.
getter/setter pair
- orientation ↔ LegendOrientation
-
Whether the entries are laid out in rows or in one column. Default LegendOrientation.HORIZONTAL.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackSpace ↔ double
-
Space in dp between stacked forms, that is entries without a label. Default 3.
getter/setter pair
- textColor ↔ Color
-
Label text color. Default black.
getter/setter pairinherited
- textHeightMax ↔ double
-
Height in px of the tallest label. Set by calculateDimensions.
getter/setter pair
- textSize ↔ double
-
Label text size in dp, clamped to 6..24. Default 10.
getter/setter pairinherited
- textWidthMax ↔ double
-
Width in px of the widest entry, form and spacing included. Set by calculateDimensions.
getter/setter pair
- typeface ↔ Typeface?
-
Typeface for the labels, or null for the default typeface.
getter/setter pairinherited
- verticalAlignment ↔ LegendVerticalAlignment
-
Vertical placement of the legend. Default LegendVerticalAlignment.BOTTOM.
getter/setter pair
- xEntrySpace ↔ double
-
Horizontal space in dp between two entries in a row. Default 6.
getter/setter pair
- xOffset ↔ double
-
Horizontal space in dp kept between the component's labels and whatever they sit next to. Default 5.
getter/setter pairinherited
- yEntrySpace ↔ double
-
Vertical space in dp between two entries in a column, or between wrapped rows. Default 0.
getter/setter pair
- yOffset ↔ double
-
Vertical space in dp kept between the component's labels and whatever they sit next to. Default 5.
getter/setter pairinherited
Methods
-
calculateDimensions(
ChartPaint labelPaint, ViewPortHandler viewPortHandler) → void - Measures the legend: the largest entry, neededWidth and neededHeight, and for a horizontal legend the row layout. Converts the dp sizes to px. The chart calls this before it lays out its content area.
-
getMaximumEntryHeight(
ChartPaint p) → double - Height in px of the tallest label.
-
getMaximumEntryWidth(
ChartPaint p) → double - Width in px of the widest entry: the longest label plus the largest form size and formToTextSpace.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resetCustom(
) → void - Makes the legend mirror the data sets again after entries were assigned. Applied when the chart data changes next.
-
setComputedEntries(
List< LegendEntry> computed) → void - Sets entries to the entries computed from the data sets without changing isLegendCustom.
-
setExtra(
List< Color> colors, List<String> labels) → void -
Builds extraEntries from parallel lists of colors and labels; surplus items of the longer list are dropped.
A color of ColorTemplate.COLOR_SKIP or 0 (
Color(0x00000000)) gives the entry LegendForm.NONE, ColorTemplate.COLOR_NONE gives it LegendForm.EMPTY. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited