Skip to main content

ScatterChart

How to use​

ScatterChart(
ScatterChartData(
// read about it in the ScatterChartData section
),
duration: Duration(milliseconds: 150), // Optional
curve: Curves.linear, // Optional
);

Implicit Animations​

When you change the chart's state, it animates to the new state internally (using implicit animations). You can control the animation duration and curve using optional duration and curve properties, respectively.

ScatterChartData​

scatterSpotsList<ScatterSpot>?#defaultconst []

The spots to draw on the chart, see ScatterSpot.

titlesDataFlTitlesData?#defaultconst FlTitlesData()

Holds data to draw the titles around the chart, see FlTitlesData.

scatterTouchDataScatterTouchData?#defaultScatterTouchData()

Handles touch behaviors and responses, see ScatterTouchData.

showingTooltipIndicatorsList<int>?#defaultconst []

you can show some tooltipIndicators (a popup with an information) on top of each ScatterSpot using showingTooltipIndicators, just put indices you want to show it on top of them.

An important point is that you have to disable the default touch behaviour to show the tooltip manually, see ScatterTouchData.handleBuiltInTouches.

gridDataFlGridData?#defaultconst FlGridData()

Holds data to draw the grid lines behind the chart, see FlGridData.

borderDataFlBorderData?#defaultFlBorderData()

Holds data to draw the border around the chart, see FlBorderData.

minXdouble?#

Minimum x value of the chart. If you don't provide it, it is calculated from the chart's data (providing it is more performant).

maxXdouble?#

Maximum x value of the chart. If you don't provide it, it is calculated from the chart's data (providing it is more performant).

baselineXdouble?#default0

The x value that the vertical grid lines and the titles are aligned to, they are drawn at every baselineX + n * interval.

minYdouble?#

Minimum y value of the chart. If you don't provide it, it is calculated from the chart's data (providing it is more performant).

maxYdouble?#

Maximum y value of the chart. If you don't provide it, it is calculated from the chart's data (providing it is more performant).

baselineYdouble?#default0

The y value that the horizontal grid lines and the titles are aligned to, they are drawn at every baselineY + n * interval.

clipDataFlClipData?#defaultconst FlClipData.none()

Clips the chart to its border (prevents drawing outside of the border), see FlClipData.

backgroundColorColor?#defaultColors.transparent

A background color which is drawn behind the chart.

scatterLabelSettingsScatterLabelSettings?#defaultScatterLabelSettings()

Shows a label on each spot, see ScatterLabelSettings.

rotationQuarterTurnsint#default0

Rotates the chart 90 degrees (clockwise) in every quarter turn. It works like the RotatedBox widget.

errorIndicatorDataFlErrorIndicatorData<ScatterChartSpotErrorRangeCallbackInput>#defaultconst FlErrorIndicatorData<ScatterChartSpotErrorRangeCallbackInput>()

Holds data for showing error indicators on the scatterSpots

ScatterSpot​

xdouble#required

The x value of the spot, on the horizontal axis (from left to right).

ydouble#required

The y value of the spot, on the vertical axis (from bottom to top).

showbool?#defaulttrue

Determines show or hide the spot.

renderPriorityint?#default0

Meant to determine which spots are drawn on top when they overlap.

Note that the chart doesn't use it yet: the spots are drawn in the order of ScatterChartData.scatterSpots (the last one on top).

dotPainterFlDotPainter?#

Draws the spot, like a FlDotCirclePainter (the shape, size and color).

Defaults to a circle with a radius of 6, and a color of Colors.primaries picked from the x and y of the spot.

xErrorFlErrorRange?#defaultnull

The error range of the spot on the x axis, drawn by the errorIndicatorData of the chart, see FlErrorRange.

yErrorFlErrorRange?#defaultnull

The error range of the spot on the y axis, drawn by the errorIndicatorData of the chart, see FlErrorRange.

ScatterTouchData (read about touch handling)​

enabledbool?#defaulttrue

Determines whether to enable or disable touch behaviors.

touchCallbackvoid Function(FlTouchEvent, ScatterTouchResponse?)?#defaultnull

touchCallback notifies you about the happened touch/pointer events. It gives you a FlTouchEvent which is the happened event such as FlPointerHoverEvent, FlTapUpEvent, ... It also gives you a BaseTouchResponse which is the chart specific type and contains information about the elements that has touched.

mouseCursorResolverMouseCursor Function(FlTouchEvent, ScatterTouchResponse?)?#defaultnull

Using mouseCursorResolver you can change the mouse cursor based on the provided FlTouchEvent and BaseTouchResponse

longPressDurationDuration?#defaultnull

This property that allows to customize the duration of the longPress gesture. If null, it uses kLongPressTimeout (500 milliseconds).

touchTooltipDataScatterTouchTooltipData?#defaultconst ScatterTouchTooltipData()

Determines how the tooltip looks on top of the touched spot, see ScatterTouchTooltipData.

touchSpotThresholddouble?#default0

Extends the touchable area of each spot by this distance (in pixels).

handleBuiltInTouchesbool?#defaulttrue

If true, the chart handles touches by itself: it shows a tooltip bubble on top of the touched spot.

ScatterTouchTooltipData​

tooltipBorderRadiusBorderRadius?#defaultBorderRadius.circular(4)

Sets a rounded radius for the tooltip.

tooltipPaddingEdgeInsets?#defaultconst EdgeInsets.symmetric(horizontal: 16, vertical: 8)

Applies a padding for showing contents inside the tooltip.

tooltipHorizontalAlignmentFLHorizontalAlignment?#defaultFLHorizontalAlignment.center

Controls showing tooltip on left side, right side or center aligned with spot.

tooltipHorizontalOffsetdouble?#default0

Applies horizontal offset for showing tooltip.

maxContentWidthdouble?#default120

Maximum width of the tooltip's content, a text row which is wider than this breaks into a new line.

getTooltipItemsScatterTooltipItem? Function(ScatterSpot)?#defaultdefaultScatterTooltipItem

Retrieves data for showing content inside the tooltip.

fitInsideHorizontallybool?#defaultfalse

Forces the tooltip to shift horizontally inside the chart, if overflow happens.

fitInsideVerticallybool?#defaultfalse

Forces the tooltip to shift vertically inside the chart, if overflow happens.

rotateAngledouble?#default0.0

Controls the rotation of the tooltip.

tooltipBorderBorderSide?#defaultBorderSide.none

Border of the tooltip bubble.

getTooltipColorColor Function(ScatterSpot)?#defaultdefaultScatterTooltipColor

Retrieves the background color of the tooltip for each touched spot.

ScatterTooltipItem​

textString#required

Text of the tooltip.

textStyleTextStyle?#defaultnull

TextStyle of the text.

bottomMargindouble?#default8

The space between the tooltip and the top of the spot.

textAlignTextAlign?#defaultTextAlign.center

TextAlign of the showing content.

textDirectionTextDirection?#defaultTextDirection.ltr

Direction of showing text.

childrenList<TextSpan>?#defaultnull

Add further style and format to the text of the tooltip

ScatterTouchResponse​

You can listen to touch behaviors callback and retrieve this object when any touch action happens.​
touchLocationOffset#

The location of the touch in pixels on the screen.

touchChartCoordinateOffset#

The axis coordinate of the touch in chart's coordinate system.

touchedSpotScatterTouchedSpot?#

The touched spot, null if no spot is touched.

ScatterTouchedSpot​

spotScatterSpot#

Touch happened on this spot

spotIndexint#

Touch happened on this spot index

ScatterLabelSettings​

showLabelbool?#defaultfalse

Determines whether to show or hide the labels.

getLabelTextStyleFunctionTextStyle? Function(int, ScatterSpot)?#defaultgetDefaultLabelTextStyleFunction

This function gives you the index value of the spot in the list and returns the text style.

getLabelFunctionString Function(int, ScatterSpot)?#defaultgetDefaultLabelFunction

This function gives you the index value of the spot in the list and returns the label.

textDirectionTextDirection?#defaultTextDirection.ltr

Determines the direction of the text for the labels.

some samples​


Sample 1 (Source Code)​
Sample 2 (Source Code)​