Back to Fl Chart

CandlestickChart

repo_files/documentations/candlestick_chart.md

1.2.08.4 KB
Original Source

CandlestickChart

How to use

dart
CandlestickChart(
	CandlestickChartData(
    // read about it in the CandlestickChartData 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.

CandlestickChartData

PropNameDescriptiondefault value
candlestickSpotsHolds the data for the candlestick chart, which is a list of CandlestickSpot objects. Each CandlestickSpot represents a single data point in the chart.[]
candlestickPainterIt is a painter that is used to draw each individual candlestick. You can use this to customize the appearance of the candlesticks (Or you can implement your own painter).DefaultCandlestickPainter()
titlesDatacheck the FlAxisTitleDataFlAxisTitleData()
candlestickTouchDataCandlestickTouchData holds the touch interactivity detailsCandlestickTouchData()
showingTooltipIndicatorsindices of showing tooltip, The point is that you need to disable touches to show these tooltips manually[]
gridDatacheck the FlGridDataFlGridData()
borderDatacheck the FlBorderDataFlBorderData()
minXgets minimum x of x axis, if null, value will read from the input lineBars (But it is more performant if you provide them)null
maxXgets maximum x of x axis, if null, value will read from the input lineBars (But it is more performant if you provide them)null
baselineXdefines the baseline of x-axis0
minYgets minimum y of y axis, if null, value will read from the input lineBars (But it is more performant if you provide them)null
maxYgets maximum y of y axis, if null, value will read from the input lineBars (But it is more performant if you provide them)null
baselineYdefines the baseline of y-axis0
rangeAnnotationsshow range annotations behind the chart, check RangeAnnotationsRangeAnnotations()
clipDataclip the chart to the border (prevent drawing outside the border)FlClipData.none()
backgroundColora background color which is drawn behind th chartnull
rotationQuarterTurnsRotates the chart 90 degrees (clockwise) in every quarter turns. This feature works like the RotatedBox widget0
touchedPointIndicatorShows the touched point in the chart, by default it shows a horizontal and vertical line exactly on the touched candle. If the handleBuiltInTouches is true in CandlestickTouchData, this parameter is used under the hood to highlight the selected point. But you can disable the handleBuiltInTouches and implement your own way to highlight the point. Look at AxisSpotIndicator for more informationnull

CandlestickSpot

PropNameDescriptiondefault value
openThe open value of the candlestick (based on the OHLC standardrequired
highThe high value of the candlestick (based on the OHLC standard)required
lowThe low value of the candlestick (based on the OHLC standard)required
closeThe close value of the candlestick (based on the OHLC standard)required
showDetermines to show or hide this individual candlesticktrue

CandlestickTouchData (read about touch handling)

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

CandlestickTouchTooltipData

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 CandlestickTooltipItem by the given CandlestickSpotdefaultCandlestickTooltipItem
fitInsideHorizontallyforces tooltip to horizontally shift inside the chart's bounding boxfalse
fitInsideVerticallyforces tooltip to vertically shift inside the chart's bounding boxfalse
showOnTopOfTheChartBoxAreaforces the tooltip container to top of the linefalse
getTooltipColora callback that retrieves the Color for each touched spots separately from the given CandlestickSpot to set the background color of the tooltip bubbleColors.blueGrey.darken(80)

CandlestickTooltipItem

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

CandlestickTouchResponse

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 CandlestickTouchedSpot which holds data about the touched spotnull

CandlestickTouchedSpot

PropNameDescriptiondefault value
spottouched CandlestickSpotnull
spotIndexindex of touched CandlestickSpotnull

some samples


Sample 1 (Source Code)