Skip to content

Commit

Permalink
Draw shadow under tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Sosssen committed Nov 5, 2024
1 parent 2ba2f36 commit 7af14da
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/chart/line_chart/line_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,10 @@ class LineChartPainter extends AxisChartPainter<LineChartData> {
bottomLeft: radius,
bottomRight: radius,
);
final shadowRoundedRect = RRect.fromRectAndRadius(
rect.shift(tooltipData.shadowOffset),
radius,
);

var topSpot = showingTooltipSpots.showingSpots[0];
for (final barSpot in showingTooltipSpots.showingSpots) {
Expand All @@ -1139,6 +1143,12 @@ class LineChartPainter extends AxisChartPainter<LineChartData> {
}

_bgTouchTooltipPaint.color = tooltipData.getTooltipColor(topSpot);
_shadowTouchTooltipPaint
..color = tooltipData.shadowColor
..maskFilter = MaskFilter.blur(
BlurStyle.normal,
tooltipData.shadowBlur,
);

final rotateAngle = tooltipData.rotateAngle;
final rectRotationOffset =
Expand All @@ -1161,6 +1171,7 @@ class LineChartPainter extends AxisChartPainter<LineChartData> {
angle: rotateAngle,
drawCallback: () {
canvasWrapper
..drawRRect(shadowRoundedRect, _shadowTouchTooltipPaint)
..drawRRect(roundedRect, _bgTouchTooltipPaint)
..drawRRect(roundedRect, _borderTouchTooltipPaint);
},
Expand Down

0 comments on commit 7af14da

Please sign in to comment.