drawSubPane method
void
drawSubPane({
- required Canvas canvas,
- required Rect bounds,
- required IndicatorResult indicator,
- required VisibleIndices visible,
- required CoordinateConverter converter,
- PriceRange? priceRange,
- double candleWidth = 8.0,
Draws sub-pane indicators (e.g. RSI, MACD) inside the dedicated sub-pane bounds.
Implementation
void drawSubPane({
required Canvas canvas,
required Rect bounds,
required IndicatorResult indicator,
required VisibleIndices visible,
required CoordinateConverter converter,
PriceRange? priceRange,
double candleWidth = 8.0,
}) {
final range = priceRange ??
PriceRange(indicator.fixedMin ?? 0.0, indicator.fixedMax ?? 100.0);
// Draw horizontal reference levels (e.g. 30, 50, 70 for RSI or 0.0 for MACD)
if (indicator.horizontalLevels != null) {
final levelPaint = Paint()
..color = theme.gridColor.withValues(alpha: 0.8)
..strokeWidth = 0.8
..style = PaintingStyle.stroke;
for (final level in indicator.horizontalLevels!) {
final y = CoordinateConverter.priceToY(level, bounds, range);
if (y >= bounds.top && y <= bounds.bottom) {
canvas.drawLine(
Offset(bounds.left, y),
Offset(bounds.right, y),
levelPaint,
);
}
}
}
// Draw histogram series first (if any) so line series render on top
for (final s in indicator.series) {
if (s.id == 'histogram') {
_drawHistogramBars(
canvas: canvas,
bounds: bounds,
series: s,
visible: visible,
priceRange: range,
converter: converter,
candleWidth: candleWidth,
);
}
}
// Draw line series
for (final s in indicator.series) {
if (s.id == 'histogram') continue;
_drawSeriesLine(
canvas: canvas,
bounds: bounds,
series: s,
visible: visible,
priceRange: range,
converter: converter,
);
}
}