Skip to content

Commit

Permalink
feat(bartooltip): add textspan children parameter for idsplaying more
Browse files Browse the repository at this point in the history
information on a bar chart tooltip
  • Loading branch information
jrc2139 committed Jan 22, 2021
1 parent 7e898b9 commit 8d98eec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/src/chart/bar_chart/bar_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -768,16 +768,21 @@ class BarTooltipItem with EquatableMixin {
/// TextStyle of the showing content.
final TextStyle textStyle;

/// List<InlineSpan> for more flexibility in showing content.
final List<InlineSpan> children;

/// content of the tooltip, is a [text] String with a [textStyle].
BarTooltipItem(String text, TextStyle textStyle)
BarTooltipItem(String text, TextStyle textStyle, [List<InlineSpan> children])
: text = text,
textStyle = textStyle;
textStyle = textStyle,
children = children;

/// Used for equality check, see [EquatableMixin].
@override
List<Object> get props => [
text,
textStyle,
children,
];
}

Expand Down
7 changes: 6 additions & 1 deletion lib/src/chart/bar_chart/bar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@ class BarChartPainter extends AxisChartPainter<BarChartData> with TouchHandler<B
return;
}

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 8d98eec

Please sign in to comment.