Back to Fl Chart

ScatterChart

repo_files/documentations/scatter_chart.md

1.2.07.3 KB
Original Source

ScatterChart

How to use

dart
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

PropNameDescriptiondefault value
scatterSpotslist of ScatterSpot to show the scatter spots on the chart[]
titlesDatacheck the FlTitlesDataFlTitlesData()
axisTitleDatacheck the FlAxisTitleDataFlAxisTitleData()
scatterTouchDataScatterTouchData holds the touch interactivity detailsScatterTouchData()
showingTooltipIndicatorsindices of showing tooltip, The point is that you need to disable touches to show these tooltips manually[]
rotationQuarterTurnsRotates the chart 90 degrees (clockwise) in every quarter turns. This feature works like the RotatedBox widget0
errorIndicatorDataHolds data for representing an error indicator (you see the error indicators if you provide the xError or yError in the ScatterSpot)ErrorIndicatorData()

ScatterSpot

PropNameDescriptiondefault value
showdetermines to show or hide the spottrue
radiusradius of the showing spot[8]
colorcolors of the spot// a color based on the values
renderPrioritysort by this to manage overlap0
xErrorDetermines the error range of the data point using (FlErrorRange)[base_chart.md#FlErrorRange] (which ontains lowerBy and upperValue) for the x-axisnull
yErrorDetermines the error range of the data point using (FlErrorRange)[base_chart.md#FlErrorRange] (which ontains upperBy and upperValue) for the y-axisnull

ScatterTouchData (read about touch handling)

PropNameDescriptiondefault value
enableddetermines to enable or disable touch behaviorstrue
mouseCursorResolveryou can change the mouse cursor based on the provided FlTouchEvent and ScatterTouchResponseMouseCursor.defer
touchTooltipDataa ScatterTouchTooltipData, that determines how show the tooltip on top of touched spot (appearance of the showing tooltip bubble)ScatterTouchTooltipData()
touchSpotThresholdthe threshold of the touch accuracy0
handleBuiltInTouchesset this true if you want the built in touch handling (show a tooltip bubble and an indicator on touched spots)true
touchCallbacklisten to this callback to retrieve touch/pointer events and responses, it gives you a FlTouchEvent and ScatterTouchResponsenull
longPressDurationallows to customize the duration of the longPress gesture. If null, the duration of the longPressGesture is kLongPressTimeoutnull

ScatterTouchTooltipData

PropNameDescriptiondefault value
tooltipBorderborder of the tooltip bubbleBorderSide.none
tooltipBorderRadiusbackground corner radius of the tooltip bubbleBorderRadius.circular(4)
tooltipPaddingpadding of the tooltipEdgeInsets.symmetric(horizontal: 16, vertical: 8)
tooltipHorizontalAlignmenthorizontal alginment of tooltip relative to the spotFLHorizontalAlignment.center
tooltipHorizontalOffsethorizontal offset of tooltip0
maxContentWidthmaximum width of the tooltip (if a text row is wider than this, then the text breaks to a new line120
getTooltipItemsa callback that retrieve a ScatterTooltipItem by the given ScatterSpotdefaultScatterTooltipItem
fitInsideHorizontallyforces tooltip to horizontally shift inside the chart's bounding boxfalse
fitInsideVerticallyforces tooltip to vertically shift inside the chart's bounding boxfalse
getTooltipColora callback that retrieves the Color for each touched spots separately from the given ScatterSpot to set the background color of the tooltip bubbleColors.blueGrey.darken(15)

ScatterTooltipItem

PropNameDescriptiondefault value
texttext string of each row in the tooltip bubblenull
textStyleTextStyle of the showing text rownull
textDirectionTextDirection of the showing text rowTextDirection.ltr
bottomMarginbottom margin of the tooltip (to the top of most top spot)0
childrenList<TextSpan> pass additional InlineSpan children for a more advance tooltipnull

ScatterTouchResponse

you can listen to touch behaviors callback and retrieve this object when any touch action happened.
PropNameDescriptiondefault value
touchLocationthe location of the touch event in the device pixels coordinatesrequired
touchChartCoordinatethe location of the touch event in the chart coordinatesrequired
touchedSpotInstance of ScatterTouchedSpot which holds data about the touched sectionnull

ScatterTouchedSpot

PropNameDescriptiondefault value
spottouched ScatterSpotnull
spotIndexindex of touched ScatterSpotnull

ScatterLabelSettings

PropNameDescriptiondefault value
showLabelDetermines whether to show or hide the labels.false
getLabelTextStyleFunctionThis function gives you the index value of the spot in the list and returns the text style.null
getLabelFunctionThis function gives you the index value of the spot in the list and returns the label.spot.radius.toString()
textDirectionDetermines the direction of the text for the labels.TextDirection.ltr

some samples


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