Skip to content

Commit

Permalink
feat(line_chart): add List<InlineSpan>? children parameter to LineToo…
Browse files Browse the repository at this point in the history
…ltipItem for enhanced styling
  • Loading branch information
jrc2139 committed Mar 20, 2021
1 parent a521525 commit 4437045
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/src/chart/line_chart/line_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1550,8 +1550,15 @@ class LineTooltipItem with EquatableMixin {
/// Style of showing text.
final TextStyle textStyle;

/// Shows a [text] with [textStyle] as a row in the tooltip popup.
LineTooltipItem(this.text, this.textStyle);
/// List<InlineSpan> add further style and format to the text of the tooltip
final List<InlineSpan>? children;

/// Shows a [text] with [textStyle] and optional List<InlineSpan> [children] as a row in the tooltip popup.
LineTooltipItem(
this.text,
this.textStyle, {
this.children,
});

/// Used for equality check, see [EquatableMixin].
@override
Expand Down
7 changes: 6 additions & 1 deletion lib/src/chart/line_chart/line_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,12 @@ class LineChartPainter extends AxisChartPainter<LineChartData>
continue;
}

final span = TextSpan(style: tooltipItem.textStyle, text: tooltipItem.text);
final span = TextSpan(
style: tooltipItem.textStyle,
text: tooltipItem.text,
children: tooltipItem.children,
);

final tp = TextPainter(
text: span,
textAlign: TextAlign.center,
Expand Down

0 comments on commit 4437045

Please sign in to comment.