code: public function addLegend(string $name, $parent, string $position = self::POSITION_AFTER, $hide = false): self
      {
          $this->validatePosition($position);
  
          $this->legends[] = [
              'name' => $name,
              'parents' => (array) $parent,
              'position' => $position,
              'hide' => (bool) $hide,
          ];
  
          return $this;
      }
docs: If the legend already exists, nothing will be changed.
  
  @param string|array $parent
  @param bool         $hide