BaseChartPainter class abstract
A base class for rendering chart components.
This class provides common functionality for painting charts, such as rendering styles, data, and helper methods.
BaseChartPainter Purpose: This abstract class serves as the base for specific chart painters (e.g., candlestick chart, line chart). It handles common chart drawing logic like calculating values, drawing the background, grid, and axes.
- Inheritance
-
- Object
- Listenable
- CustomPainter
- BaseChartPainter
- Implementers
Constructors
-
BaseChartPainter.new(ChartStyle chartStyle, {List<
KLineEntity> ? datas, required double scaleX, required double scrollX, required bool isLongPress, required double selectX, required double xFrontPadding, required BaseDimension baseDimension, bool isOnTap = false, MainState mainState = MainState.mA, bool volHidden = false, bool isTapShowInfoDialog = false, Set<SecondaryState> secondaryStateLi = const <SecondaryState>{}, bool isLine = false}) - constructor BaseChartPainter
Properties
- baseDimension → BaseDimension
-
base dimension
final
- chartStyle → ChartStyle
-
chart style
final
-
datas
↔ List<
KLineEntity> ? -
A list of KLineEntity objects representing the chart data.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLine ↔ bool
-
getter/setter pair
- isLongPress ↔ bool
-
Variables related to long-press interactions.
getter/setter pair
- isOnTap ↔ bool
-
getter/setter pair
- isTapShowInfoDialog ↔ bool
-
getter/setter pair
- mainState ↔ MainState
-
An enum indicating the type of main chart (e.g., MA, BOLL).
getter/setter pair
- mBottomPadding ↔ double
-
getter/setter pair
- mChildPadding ↔ double
-
getter/setter pair
- mDataLen ↔ double
-
getter/setter pair
- mDisplayHeight ↔ double
-
getter/setter pair
-
mFormats
↔ List<
String> -
getter/setter pair
- mGridColumns ↔ int
-
getter/setter pair
- mGridRows ↔ int
-
getter/setter pair
- mItemCount ↔ int
-
getter/setter pair
- mMainHighMaxValue ↔ double
-
getter/setter pair
- mMainLowMinValue ↔ double
-
getter/setter pair
- mMainMaxIndex ↔ int
-
getter/setter pair
- mMainMaxValue ↔ double
-
getter/setter pair
- mMainMinIndex ↔ int
-
getter/setter pair
- mMainMinValue ↔ double
-
getter/setter pair
- mMainRect ↔ Rect
-
Rectangle box of main chart
getter/setter pair
- mPointWidth ↔ double
-
getter/setter pair
-
mSecondaryRectList
↔ List<
RenderRect> -
Secondary list support
getter/setter pair
- mStartIndex ↔ int
-
getter/setter pair
- mStopIndex ↔ int
-
getter/setter pair
- mTopPadding ↔ double
-
getter/setter pair
- mTranslateX ↔ double
-
getter/setter pair
- mVolMaxValue ↔ double
-
getter/setter pair
- mVolMinValue ↔ double
-
getter/setter pair
- mVolRect ↔ Rect?
-
Rectangle box of the vol chart
getter/setter pair
- mWidth ↔ double
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scaleX ↔ double
-
Values for zooming and scrolling the chart horizontally.
getter/setter pair
- scrollX ↔ double
-
Values for zooming and scrolling the chart horizontally.
getter/setter pair
-
secondaryStateLi
↔ Set<
SecondaryState> -
A set of enums indicating the types of secondary indicators to display (e.g., MACD, KDJ).
getter/setter pair
- selectX ↔ double
-
Values for zooming and scrolling the chart horizontally.
getter/setter pair
- semanticsBuilder → SemanticsBuilderCallback?
-
Returns a function that builds semantic information for the picture drawn
by this painter.
no setterinherited
- volHidden ↔ bool
-
A boolean to control the visibility of the volume chart.
getter/setter pair
- xFrontPadding ↔ double
-
getter/setter pair
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be notified when it is time to repaint.
inherited
-
calculateSelectedX(
double selectX) → int -
calculate the value of x after long pressing and convert to
index
-
calculateValue(
) → dynamic - calculate values Calculates maximum and minimum values, indices, and other data needed for drawing.
-
drawBg(
Canvas canvas, Size size) → void - draw the background of chart
-
drawChart(
Canvas canvas, Size size) → void - draw chart
-
drawCrossLine(
Canvas canvas, Size size) → void - draw cross line
-
drawCrossLineText(
Canvas canvas, Size size) → void - draw text of the cross line
-
drawDate(
Canvas canvas, Size size) → void - draw date
-
drawGrid(
dynamic canvas) → void - draw the grid of chart
-
drawMaxAndMin(
Canvas canvas) → void - draw maximum and minimum values
-
drawNowPrice(
Canvas canvas) → void - draw the current price
-
drawText(
Canvas canvas, KLineEntity data, double x) → void - draw text
-
drawVerticalText(
dynamic canvas) → void - draw vertical text
-
getItem(
int position) → KLineEntity - Methods for converting between screen coordinates and data indices.
-
getMainMaxMinValue(
KLineEntity item, int i) → void - compute maximum and minimum value
-
getMinTranslateX(
) → double - get the minimum value of translation
-
getSecondaryMaxMinValue(
int index, KLineEntity item) → dynamic - compute maximum and minimum of secondary value
-
getTextStyle(
Color color) → TextStyle - define text style
-
getVolMaxMinValue(
KLineEntity item) → void -
getX(
int position) → double - Get x coordinate based on index
-
hitTest(
Offset position) → bool? -
Called whenever a hit test is being performed on an object that is using
this custom paint delegate.
inherited
-
indexOfTranslateX(
double translateX) → int -
initChartRenderer(
) → void - init chart renderer
-
initFormats(
) → void - init format time
-
initRect(
Size size) → void - init the rectangle box to draw chart
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paint(
Canvas canvas, Size size) → void -
paint chart
override
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies when it is time to repaint.
inherited
-
setTranslateXFromScrollX(
double scrollX) → void - scrollX convert to TranslateX
-
shouldRebuildSemantics(
covariant CustomPainter oldDelegate) → bool -
Called whenever a new instance of the custom painter delegate class is
provided to the RenderCustomPaint object, or any time that a new
CustomPaint object is created with a new instance of the custom painter
delegate class (which amounts to the same thing, because the latter is
implemented in terms of the former).
inherited
-
shouldRepaint(
covariant BaseChartPainter oldDelegate) → bool -
Called whenever a new instance of the custom painter delegate class is
provided to the RenderCustomPaint object, or any time that a new
CustomPaint object is created with a new instance of the custom painter
delegate class (which amounts to the same thing, because the latter is
implemented in terms of the former).
override
-
toString(
) → String -
A string representation of this object.
inherited
-
translateXtoX(
double translateX) → double - translateX is converted to X in view
-
xToTranslateX(
double x) → double
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maxScrollX ↔ double
-
getter/setter pair