Skip to content

Line Series Trackball Tooltip Format Series Name #24

Closed
@walsha2

Description

@walsha2

Description:

In the following example for a line series chart (where x-axis is DateTimeAxis and y-axis is NumericAxis) the following does not work as expected:

tooltipSettings: InteractiveTooltip(
	textStyle: ChartTextStyle(color: Colors.black, fontSize: 11),
	format: 'series.name: point.y',
	borderWidth: 1,
	borderColor: Colors.black,
	color: Color.fromRGBO(255, 255, 255, 0.75),
)

The tooltip label correctly parses and replaces point.y but does not do the same for series.name it just keeps it as the string: 'series.name' in the tool tip and does not update.

Issue Resolution:

Digging through the code, the following seems to be the culprit - series.name is completely missing:

lib/src/chart/user_interaction/trackball_painter.dart
labelValue = chart
  .trackballBehavior.tooltipSettings.format
  .replaceAll('point.x', (x ?? xValue).toString())
  .replaceAll('point.y',
      _getLabelValue(yValue, cartesianSeries._yAxis))
  .replaceAll('{', '')
  .replaceAll('}', '');

Changing to this to the following (adding series.name replacement), solved the issue:

labelValue = chart
  .trackballBehavior.tooltipSettings.format
  .replaceAll('point.x', (x ?? xValue).toString())
  .replaceAll('point.y',
      _getLabelValue(yValue, cartesianSeries._yAxis))
  .replaceAll('{', '')
  .replaceAll('}', '')
  .replaceAll('series.name', cartesianSeries.name);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions