code: private function writeLegend(XMLWriter $objWriter, Legend $legend = null)
      {
          if ($legend === null) {
              return;
          }
  
          $objWriter->startElement('c:legend');
  
          $objWriter->startElement('c:legendPos');
          $objWriter->writeAttribute('val', $legend->getPosition());
          $objWriter->endElement();
  
          $this->writeLayout($objWriter, $legend->getLayout());
  
          $objWriter->startElement('c:overlay');
          $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0');
          $objWriter->endElement();
  
          $objWriter->startElement('c:txPr');
          $objWriter->startElement('a:bodyPr');
          $objWriter->endElement();
  
          $objWriter->startElement('a:lstStyle');
          $objWriter->endElement();
  
          $objWriter->startElement('a:p');
          $objWriter->startElement('a:pPr');
          $objWriter->writeAttribute('rtl', 0);
  
          $objWriter->startElement('a:defRPr');
          $objWriter->endElement();
          $objWriter->endElement();
  
          $objWriter->startElement('a:endParaRPr');
          $objWriter->writeAttribute('lang', 'en-US');
          $objWriter->endElement();
  
          $objWriter->endElement();
          $objWriter->endElement();
  
          $objWriter->endElement();
      }
docs: Write Chart Legend.
  
  @param XMLWriter $objWriter XML Writer
  @param Legend $legend
  
  @throws WriterException