removeBehavior method

bool removeBehavior(
  1. ChartBehavior<D>? behavior
)

Removes a behavior from the chart.

Returns true if a behavior was removed, otherwise returns false.

Implementation

bool removeBehavior(ChartBehavior<D>? behavior) {
  if (behavior == null) {
    return false;
  }

  final role = behavior.role;
  if (role != null && _behaviorRoleMap[role] == behavior) {
    _behaviorRoleMap.remove(role);
  }

  // Make sure the removed behavior is no longer registered for tap events.
  unregisterTappable(behavior);

  final wasAttached = _behaviorStack.remove(behavior);
  behavior.removeFrom(this);

  return wasAttached;
}