RadarChart class
Chart that draws RadarData as a spider web: each entry sits on its own spoke from the center, and the entries of
a data set are joined into a polygon. Works best with 5 to 10 entries per data set. The xAxis labels the spokes
and yAxis scales the distance from the center. Angles are in degrees, 0 at 3 o'clock, increasing clockwise; the
first spoke points at rotationAngle.
- Inheritance
-
- Object
- Chart<
RadarData> - PieRadarChartBase<
RadarData> - RadarChart
Constructors
Properties
-
afterDrawListeners
→ List<
void Function()> -
Called at the end of every onDraw, in list order: after the markers, or after the empty state.
finalinherited
- animator ↔ ChartAnimator
-
Runs the animations: the x and y phases of animateX, animateY and animateXY, and the value animations.
getter/setter pairinherited
- center → MPPointF
-
Center of the whole chart in pixels, ignoring offsets. See centerOffsets for the content center.
no setterinherited
- centerOffsets → MPPointF
-
Center of the content rectangle in pixels, as a fresh MPPointF.
no setterinherited
- centerOfView → MPPointF
-
Center of the whole chart view in pixels, as a fresh MPPointF.
no setterinherited
-
chartTouchListener
↔ ChartTouchListener<
Chart< ChartData< >IDataSet< >Entry> > -
Handles touch events for this chart. Replace it to customize gestures; isTouchEnabled must stay true.
getter/setter pairinherited
- contentRect → MutableRect
-
Rectangle in pixels in which the data is drawn, the view minus axis, legend and extra offsets.
no setterinherited
- data ↔ RadarData?
-
The data this chart displays, or null when nothing has been set.
getter/setter pairinherited
- defaultValueFormatter → IValueFormatter
-
Formatter the chart computed from its data, used by data sets that have no formatter of their own.
no setterinherited
- defaultValueFormatterInternal → DefaultValueFormatter
-
Formatter used for data sets without their own. Its digit count follows the y range of the data.
finalinherited
- description ↔ Description
-
The description text drawn in the bottom right corner by default.
getter/setter pairinherited
- descriptionPaint ↔ ChartPaint
-
Paint used for the description text.
getter/setter pairinherited
- diameter → double
-
Largest circle diameter in pixels that fits the content area after the extra offsets.
no setterinherited
- dragDecelerationFrictionCoef ↔ double
-
How slowly a deceleration scroll loses speed, between 0 (stops at once) and 0.999.
Values outside that range are clamped. Default 0.9.
getter/setter pairinherited
- extraBottomOffset ↔ double
-
Extra space in dp added below the content area on top of the calculated offsets.
getter/setter pairinherited
- extraLeftOffset ↔ double
-
Extra space in dp added left of the content area on top of the calculated offsets.
getter/setter pairinherited
- extraRightOffset ↔ double
-
Extra space in dp added right of the content area on top of the calculated offsets.
getter/setter pairinherited
- extraTopOffset ↔ double
-
Extra space in dp added above the content area on top of the calculated offsets.
getter/setter pairinherited
- factor → double
-
Pixels per y value unit: the radius divided by the yAxis range. Infinite or NaN while the range is 0.
no setter
-
gestureListeners
→ List<
OnChartGestureListener> -
Additional gesture listeners, notified after onChartGestureListener in list order.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- height ↔ double
-
Height of the chart in logical pixels,
View.getHeight(). Set by onSizeChanged.getter/setter pairinherited -
highlighted
↔ List<
Highlight> -
The values currently highlighted. Empty, never null, when nothing is highlighted.
getter/setter pairinherited
- highlighter ↔ IHighlighter
-
Turns a touch position into the Highlight of the nearest value.
getter/setter pairinherited
- host ↔ ChartHost?
-
What shows this chart on screen and receives its redraw, post and scroll requests, or null. The widget layer's
render object assigns itself here while it is attached.
getter/setter pairinherited
- infoPaint ↔ ChartPaint
-
Paint used for the no-data text.
getter/setter pairinherited
- isAnimating → bool
-
True while any animation runs: animateX, animateY, animateXY, a spin, animateValue or animateDataChange.
no setterinherited
- isChartTouchListenerInitialized → bool
-
Whether chartTouchListener has been assigned, Kotlin's
::chartTouchListener.isInitialized.no setterinherited - isDragDecelerationEnabled ↔ bool
-
Whether the chart keeps scrolling after the finger is lifted.
getter/setter pairinherited
- isDrawMarkersEnabled ↔ bool
-
Whether the marker is drawn at highlighted values.
getter/setter pairinherited
- isDrawWebEnabled ↔ bool
-
Whether the web is drawn at all. Default true.
getter/setter pair
- isEmpty → bool
-
True when there is no data or the data holds no entries.
no setterinherited
- isHighlightPerTapEnabled ↔ bool
-
Whether a tap highlights the nearest value. Values can still be highlighted by drag or in code.
getter/setter pairinherited
- isLoading ↔ bool
-
Whether the data is on its way. While true and the chart has nothing to draw, the empty state shows
loadingText and its icon pulses. Data that arrives is drawn as usual, so this can stay true until then.
getter/setter pairinherited
- isLogEnabled ↔ bool
-
Prints chart internals with
debugPrintwhile true. Slows down drawing, so keep it off in production.getter/setter pairinherited - isNoDataIconEnabled ↔ bool
-
Whether the empty state draws an icon above its text: noDataIcon, or a small outline of this chart type.
getter/setter pairinherited
- isRendererInitialized → bool
-
Whether renderer has been assigned, Kotlin's
::renderer.isInitialized.no setterinherited - isRotationEnabled ↔ bool
-
Whether the chart can be rotated by dragging. Default true.
getter/setter pairinherited
- isTouchEnabled ↔ bool
-
Whether the chart reacts to touch at all. False disables tapping, dragging, scaling and rotating.
getter/setter pairinherited
- isUnbindEnabled ↔ bool
-
Kept for API parity; it has no effect. On Android it releases the background drawable and the child views when
the chart leaves the window; a Flutter chart has neither.
getter/setter pairinherited
-
jobs
→ List<
void Function()> -
Viewport jobs waiting for the chart to get a size. They run once in onSizeChanged.
finalinherited
- legend ↔ Legend
-
The legend component. It is filled from the data sets unless a custom legend is set on it.
getter/setter pairinherited
- legendLabelPaint ↔ ChartPaint
-
Paint used for legend labels.
getter/setter pairinherited
- legendRenderer ↔ LegendRenderer
-
Draws the legend.
getter/setter pairinherited
- loadingText ↔ String
-
Text of the empty state while isLoading is true.
getter/setter pairinherited
- marker ↔ IMarker?
-
Marker drawn at each highlighted value, or null for none.
A MarkerView or MarkerImage is attached to this chart when set.
getter/setter pairinherited
- maxHighlightDistance ↔ double
-
Farthest distance in dp a touch may be from a value and still highlight it. Default 500.
getter/setter pairinherited
- maxVisibleCount → int
-
The number of entries of the data, or 0 without data.
no setterinherited
- minOffset ↔ double
-
Smallest space in dp between the view edge and the chart on every side. Default 0.
getter/setter pairinherited
- noDataIcon ↔ ChartDrawable?
-
Icon drawn above the empty state text instead of the outline of this chart type, or null for the outline.
getter/setter pairinherited
- noDataIconColor ↔ Color
-
Color of the chart type outline in the empty state. Default a faint slate that reads on light and dark backgrounds.
getter/setter pairinherited
- noDataText ↔ String
-
Text of the empty state, drawn while the chart has no data or data without entries. An empty string draws
only the icon.
getter/setter pairinherited
- noDataTextAlignment ↔ PaintAlign
-
Horizontal alignment of the empty state: at the left edge, in the center or at the right edge of the chart.
getter/setter pairinherited
- noDataTextColor ↔ Color
-
Color of noDataText and loadingText.
getter/setter pairinherited
- noDataTextSize ↔ double
-
Size of noDataText and loadingText in dp. Default 13.
getter/setter pairinherited
- noDataTextTypeface ↔ Typeface
-
Typeface of noDataText and loadingText; null sets the default. Default sans serif medium.
getter/setter pairinherited
- onChartGestureListener ↔ OnChartGestureListener?
-
Single listener told about gestures such as tap, double tap, drag, scale and fling.
getter/setter pairinherited
- onChartValueSelectedListener ↔ OnChartValueSelectedListener?
-
Single listener told when a value is selected or the selection is cleared.
getter/setter pairinherited
- radius → double
-
Radius of the web in pixels: half the smaller side of the content rectangle.
no setteroverride
- rawRotationAngle → double
-
The last value given to rotationAngle before normalizing, in degrees, which may be negative or above 360.
Default 270.
no setterinherited
- renderer ↔ DataRenderer
-
Draws the data. Each chart type installs its own renderer; replace it for custom drawing.
getter/setter pairinherited
- requiredBaseOffset → double
-
The rotated label width in pixels while the x axis draws labels, otherwise 10 dp.
no setteroverride
- requiredLegendOffset → double
-
Twice the legend text size in pixels.
no setteroverride
- requiredVerticalBaseOffset → double
-
Half the rotated label width plus the rotated label height in pixels while the x axis draws labels, otherwise
10 dp. A label is drawn half its width beyond the web, so above and below that is half a width plus its height.
no setteroverride
- rotationAngle ↔ double
-
Angle in degrees at which the first slice or entry starts, normalized to 0 (inclusive) until 360 (exclusive).
Default 270, the top of the chart. Setting it also stores the unnormalized value in rawRotationAngle.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showsEmptyState → bool
-
Whether the chart has no data or no entries and draws its empty state instead of the data.
no setterinherited
- skipWebLineCount ↔ int
-
Number of spokes left out between two drawn ones, for charts with many entries. Negative values are raised to
0. Default 0.
getter/setter pair
- sliceAngle → double
-
Angle in degrees between two neighbouring spokes: 360 divided by the entry count of the largest data set (by 1
without data).
no setter
-
valueSelectedListeners
→ List<
OnChartValueSelectedListener> -
Additional listeners, notified after onChartValueSelectedListener in list order.
Meant for observers that must not replace the app's own listener, such as a widget's chart controller.
finalinherited
- viewPortHandler ↔ ViewPortHandler
-
Holds the chart size, the content rectangle and the zoom and drag matrix.
getter/setter pairinherited
- webAlpha ↔ int
-
Opacity of all web lines from 0 (invisible) to 255 (opaque). Default 150.
getter/setter pair
- webColor ↔ Color
-
Color of the web lines running from the center outwards. Default gray,
Color.rgb(122, 122, 122); its alpha is replaced by webAlpha.getter/setter pair - webColorInner ↔ Color
-
Color of the web rings between the spokes. Default gray,
Color.rgb(122, 122, 122); its alpha is replaced by webAlpha.getter/setter pair - webLineWidth ↔ double
-
Width in dp of the web lines running from the center outwards. Default 1.5.
getter/setter pair
- webLineWidthInner ↔ double
-
Width in dp of the web rings between the spokes. Default 0.75.
getter/setter pair
- width ↔ double
-
Width of the chart in logical pixels,
View.getWidth(). Set by onSizeChanged.getter/setter pairinherited - xAxis ↔ XAxis
-
The x axis component: its labels, range, grid lines and position.
getter/setter pairinherited
- xAxisRenderer ↔ XAxisRendererRadarChart
-
Draws the
xAxislabels around the web.getter/setter pair - xChartMax → double
-
Largest x value of the x axis, independent of zoom and drag.
no setterinherited
- xChartMin → double
-
Smallest x value of the x axis, independent of zoom and drag.
no setterinherited
- xRange → double
-
Difference between xChartMax and xChartMin.
no setterinherited
- yAxis → YAxis
-
The single y axis, scaling the distance from the center: the left axis, with labels 10 dp right of the first
spoke.
no setter
- yAxisRenderer ↔ YAxisRendererRadarChart
-
Draws yAxis.
getter/setter pair
- yChartMax → double
-
The yAxis maximum.
no setteroverride
- yChartMin → double
-
The yAxis minimum, the value at the center.
no setteroverride
- yMax → double
-
Largest y value across all data sets, or 0 without data.
no setterinherited
- yMin → double
-
Smallest y value across all data sets, or 0 without data.
no setterinherited
- yRange → double
-
Range of yAxis in values.
no setter
Methods
-
addViewportJob(
void job()) → void -
Runs a viewport job once the chart has a size: posted right away when it already has one, otherwise stored
in jobs until onSizeChanged. The zoom and move functions use this, passing a job's
run. At most 64 jobs wait, because only the last position matters and a chart that never gets a size would otherwise collect them forever.inherited -
animateDataChange(
RadarData newData, int durationMillis, {EasingFunction easing = Easing.Linear, void onEnd() = _noop}) → void -
Sets
newDataand animates every entry from the value it replaces to its own value. Entries are paired by data set index and entry index; entries past the old end grow from 0, entries past the new end are gone at once. Stacked bars animate each stack value, candles open, high, low and close, bubbles their size and pie slices their value. The axis ranges follow on every frame and highlights stay on their x value.inherited -
animateValue(
Entry entry, double toY, int durationMillis, {EasingFunction easing = Easing.Linear, void onEnd() = _noop}) → void -
Animates the y value of one entry to
toY. The axis ranges follow the value on every frame. Works for line, bar, scatter, bubble, pie and radar entries. A running animation of the same entry is cancelled first and the new one starts from the current value. Setting data ends the animation with the entry attoY.inherited -
animateX(
int durationMillis, {EasingFunction easing = Easing.Linear, void onEnd() = _noop}) → void -
Animates the drawing of the data along the x axis. The chart redraws itself while animating. A running x
animation is cancelled first.
inherited
-
animateXY(
int durationMillisX, int durationMillisY, {EasingFunction easingX = Easing.Linear, EasingFunction? easingY, void onEnd() = _noop}) → void -
Animates the drawing of the data along both axes. The chart redraws itself while animating. Running x and y
animations are cancelled first.
inherited
-
animateY(
int durationMillis, {EasingFunction easing = Easing.Linear, void onEnd() = _noop}) → void -
Animates the drawing of the data along the y axis. The chart redraws itself while animating. A running y
animation is cancelled first.
inherited
-
calcMinMax(
) → void -
Computes the yAxis range from the y values and the
xAxisrange from 0 to the entry count of the largest data set.override -
calculateOffsets(
) → void -
Computes the content rectangle from the legend, the offsets the chart requires, the extra offsets and
minOffset.
inherited
-
clear(
) → void -
Sets data to null, clears the highlight and redraws, which shows noDataText.
inherited
-
clearAllViewportJobs(
) → void -
Drops all jobs waiting in jobs.
inherited
-
clearValues(
) → void -
Removes all data sets from data but keeps the data object, then redraws. Does nothing without data.
inherited
-
computeScroll(
) → void -
Advances the rotation deceleration of the chartTouchListener by one frame.
inherited
-
disableScroll(
) → void -
Keeps the current gesture with the chart, so an enclosing scrollable does not take it over
(
requestDisallowInterceptTouchEvent(true)on Android).inherited -
distanceToCenter(
double x, double y) → double -
Distance in pixels between the pixel position (
x,y) and the content center.inherited -
drawDescription(
Canvas c) → void -
Draws the description text at its position, or in the bottom right corner when it has none.
inherited
-
drawEmptyState(
Canvas canvas) → void -
Draws the empty state: the icon and noDataText, or loadingText while isLoading, as one block centered
vertically and placed horizontally by noDataTextAlignment. Override it to draw an empty state of your own.
inherited
-
drawMarkers(
Canvas canvas) → void -
Draws the marker at every highlighted value that lies inside the content area.
inherited
-
drawNoDataIcon(
Canvas canvas, MutableRect bounds, ChartPaint paint) → void -
Draws two nested hexagons, the outline of a web, inside
boundsfor the empty state.override -
enableScroll(
) → void -
Lets an enclosing scrollable take over gestures again (
requestDisallowInterceptTouchEvent(false)on Android).inherited -
getAngleForPoint(
double x, double y) → double -
Angle in degrees of the pixel position (
x,y) around the content center: 0 at 3 o'clock, 90 at 6 o'clock, 180 at 9 o'clock, 270 at 12 o'clock; from 0 (inclusive) to 360 (exclusive) for a finite position. The center itself yields 90.inherited -
getHighlightByTouchPoint(
double x, double y) → Highlight? -
Finds the value nearest to a touch position.
inherited
-
getIndexForAngle(
double angle) → int -
Index of the entry whose spoke is nearest to
angle, in degrees (0 at 3 o'clock, increasing clockwise), takingrotationAngleinto account. Never -1: every angle maps to a spoke, and to 0 without data.override -
getMarkerPosition(
Highlight high) → Float32List -
Pixel position where the marker for
highis drawn, as[x, y].inherited -
getPosition(
MPPointF center, double dist, double angle, [MPPointF? outputPoint]) → MPPointF -
Pixel position at the distance
distin pixels and the angleanglein degrees (0 at 3 o'clock, increasing clockwise) from the pointcenterin pixels.inherited -
highlightValue(
double x, int dataSetIndex, {double y = double.nan, int dataIndex = -1, int stackIndex = -1, bool callListener = true}) → void -
Highlights the entry closest to the given x value (and, when
yis a number, closest toyamong entries with the same x) in one data set and redraws.inherited -
highlightValueOf(
Highlight? highlight, {bool callListener = true}) → void -
Highlights the value described by
highlightand redraws. This is what a tap calls. Null, or a highlight that matches no entry, clears the highlight instead.inherited -
highlightValues(
List< Highlight> highs) → void -
Highlights all the given values at once and redraws. The list is taken as is, without checking that
the entries exist, and no listener is called. An empty list clears the highlight.
inherited
-
init(
) → void -
Creates the components, paints and animator. Subclasses add their renderer, highlighter and touch listener.
override
-
invalidate(
) → void -
Requests a redraw from the host,
View.invalidate(). Does nothing without a host.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyAfterDraw(
) → void -
Calls each of afterDrawListeners. onDraw calls it once at its very end; a chart type that overrides onDraw
and draws after
super.onDrawcalls it at the end of its own onDraw instead, asBarLineChartBase,PieChartandRadarChartdo.inherited -
notifyDataSetChanged(
) → void -
Like the base, but also computes the axis labels (see
computeAxes) before the legend and the offsets.override -
onDetachedFromWindow(
) → void -
Also stops a running rotation deceleration, whose ticker runs on the host's vsync.
inherited
-
onDraw(
Canvas canvas) → void -
Draws the x axis labels, the web, the limit lines behind the data, the data, the highlights, the limit lines in
front of the data, the y axis labels, the values, the legend, the description and the markers, in that order, or
the empty state while there is nothing to draw.
override
-
onHostVsyncChanged(
) → void -
Also stops a running rotation deceleration, whose ticker runs on the previous vsync. Not in Kotlin.
inherited
-
onSizeChanged(
double w, double h) → void -
Sets the chart size to
wxh,View.onSizeChanged: the host calls it when the laid out size changes.inherited -
onTouchEvent(
ChartTouchEvent event) → bool -
Passes
eventto the chartTouchListener while isTouchEnabled is true and a listener is assigned, and returns what it returns; otherwise consumes nothing.inherited -
onValueSelected(
void onValueSelected(Entry entry, Highlight highlight), {void onNothingSelected() = _noop}) → void -
Replaces onChartValueSelectedListener with functions.
inherited
-
post(
void job()) → void -
Runs
jobafter the current frame through the host,View.post(Runnable), or at once without a host.inherited -
removeViewportJob(
void job()) → void -
Removes a job from jobs before it has run.
inherited
-
setExtraOffsets(
double left, double top, double right, double bottom) → void -
Sets all four extra offsets in dp at once. They apply on the next offset calculation.
inherited
-
setLastHighlighted(
List< Highlight> ? highs) → void -
Tells the touch listener which highlight a tap must toggle off next.
inherited
-
setupDefaultFormatter(
double min, double max) → void -
Sets the digit count of the default value formatter from the value range.
inherited
-
spin(
int durationMillis, double fromAngle, double toAngle, {EasingFunction easing = Easing.Linear, void onEnd()?}) → void -
Animates rotationAngle from one angle to another and redraws on every step. A running spin is cancelled
first.
inherited
-
stopAnimations(
) → void -
Ends every running animation at once at its final state: the drawing is complete, a spin stands at its end
angle and animated values hold their targets. Each
onEndruns. Leaving the window does the same.inherited -
toImage(
{int? width, int? height, double pixelRatio = 1.0}) → Future< Image> -
Draws the chart into a new image, over white. Kotlin's
toBitmap.inherited -
toPngBytes(
{int? width, int? height, double pixelRatio = 1.0}) → Future< Uint8List> -
Draws the chart like toImage and encodes the image as PNG.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
valuesToHighlight(
) → bool -
True when at least one value is highlighted.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited