builder method
Implementation
@override
BasePainter builder(BuildContext context) {
final data = watchController();
double lastClose = 0;
final painter = VolChartPainter(
paddingTop: widget.paddingTop,
pointSpace: data.getSpace(),
scrollX: data.getScrollX(),
scale: data.getScale(),
pressOffset: data.getPressOffset(),
values: data.values,
showMaLine: widget.showMaLine,
pointWidth: data.pointWidth,
upperStyle: widget.upperStyle,
fairStyle: widget.fairStyle,
lowerStyle: widget.lowerStyle,
upperColor: widget.upperColor,
fairColor: widget.fairColor,
lowerColor: widget.lowerColor,
strokeWidth: widget.strokeWidth,
gridLineWidth: widget.gridLineWidth,
gridLineColor: widget.gridLineColor,
gridHorizontalGrids: widget.gridHorizontalGrids,
gridVerticalGrids: widget.gridVerticalGrids,
ma10LineColor: widget.ma10LineColor,
ma5LineColor: widget.ma5LineColor,
maStrokeWidth: widget.maStrokeWidth,
crossLineColor: widget.crossLineColor,
crossLineWidth: widget.crossLineWidth,
textStyle: widget.textStyle,
showText: widget.showText,
transform: (values) {
return values.map((e) => e.volume).toList();
},
transformBarStyle: (item) {
BarStyle style;
if (data.isKChart()) {
if (item.close >= item.open) {
style = BarStyle.upper;
} else {
style = BarStyle.lower;
}
} else {
if (item.close < lastClose) {
style = BarStyle.lower;
} else if (item.close > lastClose) {
style = BarStyle.upper;
} else {
style = BarStyle.fair;
}
lastClose = item.close;
}
return style;
},
);
return painter;
}