Skip to main content

CandlestickChart

How to use​

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​

candlestickSpotsList<CandlestickSpot>?#defaultconst []

Contains the data for the candlestick chart.

Each CandlestickSpot represents a candlestick in the chart that contains CandlestickSpot.open, CandlestickSpot.high, CandlestickSpot.low and CandlestickSpot.close values.

candlestickPainterFlCandlestickPainter?#defaultDefaultCandlestickPainter()

The painter used to draw the candlestick. You can use the DefaultCandlestickPainter or implement your own.

titlesDataFlTitlesData?#defaultconst FlTitlesData()

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

candlestickTouchDataCandlestickTouchData?#defaultCandlestickTouchData()

Handles touch behaviors and responses.

showingTooltipIndicatorsList<int>?#defaultconst []

you can show some tooltipIndicators (a popup with an information) on top of each CandlestickSpot 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 CandlestickTouchData.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.

rangeAnnotationsRangeAnnotations?#defaultconst RangeAnnotations()

Highlights some horizontal or vertical ranges behind the chart, see RangeAnnotations.

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.

rotationQuarterTurnsint#default0

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

touchedPointIndicatorAxisSpotIndicator?#defaultnull

Shows an indicator on the touched / hovered point

We manage to set it by default when CandlestickTouchData.handleBuiltInTouches is true, so nothing happens if you change this property as long as the handleBuiltInTouches property is true.

But you can set CandlestickTouchData.handleBuiltInTouches to false if you want to have customized touchedPointIndicator

CandlestickSpot​

xdouble#required

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

opendouble#required

The open value of the candlestick, see the OHLC standard.

highdouble#required

The highest value of the candlestick (the top of its wick).

lowdouble#required

The lowest value of the candlestick (the bottom of its wick).

closedouble#required

The close value of the candlestick, see the OHLC standard.

showbool?#defaulttrue

Determines show or hide the spot.

CandlestickTouchData (read about touch handling)​

enabledbool?#defaulttrue

Determines whether to enable or disable touch behaviors.

touchCallbackvoid Function(FlTouchEvent, CandlestickTouchResponse?)?#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, CandlestickTouchResponse?)?#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).

touchTooltipDataCandlestickTouchTooltipData?#defaultCandlestickTouchTooltipData()

Determines how the tooltip looks on top of the touched candlestick, see CandlestickTouchTooltipData.

handleBuiltInTouchesbool?#defaulttrue

If true, the chart handles touches by itself: it shows a tooltip bubble and an indicator on the touched (or hovered) candlestick.

touchSpotThresholddouble?#default4

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

CandlestickTouchTooltipData​

tooltipBorderRadiusBorderRadius?#defaultBorderRadius.circular(4)

Sets a border 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.

getTooltipItemsCandlestickTooltipItem? Function(FlCandlestickPainter, CandlestickSpot, int)?#defaultdefaultCandlestickTooltipItem

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.

showOnTopOfTheChartBoxAreabool?#defaultfalse

Forces the tooltip container to top of the line, default 'false'

rotateAngledouble?#default0.0

Controls the rotation of the tooltip.

tooltipBorderBorderSide?#defaultBorderSide.none

Border of the tooltip bubble.

getTooltipColorColor Function(CandlestickSpot)?#defaultdefaultCandlestickTooltipColor

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

CandlestickTooltipItem​

textString#required

Showing text.

textStyleTextStyle?#defaultnull

Style of showing text.

bottomMargindouble?#default8

Defines bottom space from 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

CandlestickTouchResponse​

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

The location of the touch in pixels on the screen.

touchChartCoordinateOffset#

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

touchedSpotCandlestickTouchedSpot?#

The touched spot, null if no candle is touched.

CandlestickTouchedSpot​

spotCandlestickSpot#

Touch happened on this spot

spotIndexint#

Touch happened on this spot index

some samples​


Sample 1 (Source Code)​