Пример #1
0
 /**
  * Write Plot Area
  *
  * @param  PHPPowerPoint_Shared_XMLWriter     $objWriter XML Writer
  * @param  PHPPowerPoint_Shape_Chart_PlotArea $subject
  * @param  PHPPowerPoint_Shape_Chart          $chart
  * @throws Exception
  */
 protected function _writePlotArea(PHPPowerPoint_Shared_XMLWriter $objWriter, PHPPowerPoint_Shape_Chart_PlotArea $subject, PHPPowerPoint_Shape_Chart $chart)
 {
     // c:plotArea
     $objWriter->startElement('c:plotArea');
     // Write layout
     $this->_writeLayout($objWriter, $subject);
     // Write chart
     $chartType = $subject->getType();
     if ($chartType instanceof PHPPowerPoint_Shape_Chart_Type_Bar3D) {
         $this->_writeTypeBar3D($objWriter, $chartType, $chart->getIncludeSpreadsheet());
     } elseif ($chartType instanceof PHPPowerPoint_Shape_Chart_Type_Pie3D) {
         $this->_writeTypePie3D($objWriter, $chartType, $chart->getIncludeSpreadsheet());
     } elseif ($chartType instanceof PHPPowerPoint_Shape_Chart_Type_Line) {
         $this->_writeTypeLine($objWriter, $chartType, $chart->getIncludeSpreadsheet());
     } elseif ($chartType instanceof PHPPowerPoint_Shape_Chart_Type_Scatter) {
         $this->_writeTypeScatter($objWriter, $chartType, $chart->getIncludeSpreadsheet());
     } else {
         throw new Exception('The chart type provided could not be rendered.');
     }
     // Write X axis?
     if ($chartType->hasAxisX()) {
         // c:catAx (Axis X)
         $objWriter->startElement('c:catAx');
         // c:axId
         $objWriter->startElement('c:axId');
         $objWriter->writeAttribute('val', '52743552');
         $objWriter->endElement();
         // c:scaling
         $objWriter->startElement('c:scaling');
         // c:orientation
         $objWriter->startElement('c:orientation');
         $objWriter->writeAttribute('val', 'minMax');
         $objWriter->endElement();
         $objWriter->endElement();
         // c:axPos
         $objWriter->startElement('c:axPos');
         $objWriter->writeAttribute('val', 'b');
         $objWriter->endElement();
         // c:numFmt
         $objWriter->startElement('c:numFmt');
         $objWriter->writeAttribute('formatCode', $subject->getAxisX()->getFormatCode());
         $objWriter->writeAttribute('sourceLinked', '0');
         $objWriter->endElement();
         // c:majorTickMark
         $objWriter->startElement('c:majorTickMark');
         $objWriter->writeAttribute('val', 'none');
         $objWriter->endElement();
         // c:tickLblPos
         $objWriter->startElement('c:tickLblPos');
         $objWriter->writeAttribute('val', 'nextTo');
         $objWriter->endElement();
         // c:txPr
         $objWriter->startElement('c:txPr');
         // a:bodyPr
         $objWriter->writeElement('a:bodyPr', null);
         // a:lstStyle
         $objWriter->writeElement('a:lstStyle', null);
         // a:p
         $objWriter->startElement('a:p');
         // a:pPr
         $objWriter->startElement('a:pPr');
         // a:defRPr
         $objWriter->writeElement('a:defRPr', null);
         $objWriter->endElement();
         // a:r
         $objWriter->startElement('a:r');
         // a:rPr
         $objWriter->startElement('a:rPr');
         $objWriter->writeAttribute('lang', 'en-US');
         $objWriter->writeAttribute('dirty', '0');
         $objWriter->endElement();
         // a:t
         $objWriter->writeElement('a:t', $subject->getAxisX()->getTitle());
         $objWriter->endElement();
         // a:endParaRPr
         $objWriter->startElement('a:endParaRPr');
         $objWriter->writeAttribute('lang', 'en-US');
         $objWriter->writeAttribute('dirty', '0');
         $objWriter->endElement();
         $objWriter->endElement();
         $objWriter->endElement();
         // c:crossAx
         $objWriter->startElement('c:crossAx');
         $objWriter->writeAttribute('val', '52749440');
         $objWriter->endElement();
         // c:crosses
         $objWriter->startElement('c:crosses');
         $objWriter->writeAttribute('val', 'autoZero');
         $objWriter->endElement();
         // c:lblAlgn
         $objWriter->startElement('c:lblAlgn');
         $objWriter->writeAttribute('val', 'ctr');
         $objWriter->endElement();
         // c:lblOffset
         $objWriter->startElement('c:lblOffset');
         $objWriter->writeAttribute('val', '100');
         $objWriter->endElement();
         $objWriter->endElement();
     }
     // Write Y axis?
     if ($chartType->hasAxisY()) {
         // c:valAx (Axis Y)
         $objWriter->startElement('c:valAx');
         // c:axId
         $objWriter->startElement('c:axId');
         $objWriter->writeAttribute('val', '52749440');
         $objWriter->endElement();
         // c:scaling
         $objWriter->startElement('c:scaling');
         // c:orientation
         $objWriter->startElement('c:orientation');
         $objWriter->writeAttribute('val', 'minMax');
         $objWriter->endElement();
         $objWriter->endElement();
         // c:axPos
         $objWriter->startElement('c:axPos');
         $objWriter->writeAttribute('val', 'l');
         $objWriter->endElement();
         // c:numFmt
         $objWriter->startElement('c:numFmt');
         $objWriter->writeAttribute('formatCode', $subject->getAxisY()->getFormatCode());
         $objWriter->writeAttribute('sourceLinked', '0');
         $objWriter->endElement();
         // c:majorGridlines
         //$objWriter->startElement('c:majorGridlines');
         //$objWriter->endElement();
         // c:majorTickMark
         $objWriter->startElement('c:majorTickMark');
         $objWriter->writeAttribute('val', 'none');
         $objWriter->endElement();
         // c:tickLblPos
         $objWriter->startElement('c:tickLblPos');
         $objWriter->writeAttribute('val', 'nextTo');
         $objWriter->endElement();
         // c:txPr
         $objWriter->startElement('c:txPr');
         // a:bodyPr
         $objWriter->writeElement('a:bodyPr', null);
         // a:lstStyle
         $objWriter->writeElement('a:lstStyle', null);
         // a:p
         $objWriter->startElement('a:p');
         // a:pPr
         $objWriter->startElement('a:pPr');
         // a:defRPr
         $objWriter->writeElement('a:defRPr', null);
         $objWriter->endElement();
         // a:r
         $objWriter->startElement('a:r');
         // a:rPr
         $objWriter->startElement('a:rPr');
         $objWriter->writeAttribute('lang', 'en-US');
         $objWriter->writeAttribute('dirty', '0');
         $objWriter->endElement();
         // a:t
         $objWriter->writeElement('a:t', $subject->getAxisY()->getTitle());
         $objWriter->endElement();
         // a:endParaRPr
         $objWriter->startElement('a:endParaRPr');
         $objWriter->writeAttribute('lang', 'en-US');
         $objWriter->writeAttribute('dirty', '0');
         $objWriter->endElement();
         $objWriter->endElement();
         $objWriter->endElement();
         // c:crossAx
         $objWriter->startElement('c:crossAx');
         $objWriter->writeAttribute('val', '52743552');
         $objWriter->endElement();
         // c:crosses
         $objWriter->startElement('c:crosses');
         $objWriter->writeAttribute('val', 'autoZero');
         $objWriter->endElement();
         // c:crossBetween
         $objWriter->startElement('c:crossBetween');
         $objWriter->writeAttribute('val', 'between');
         $objWriter->endElement();
         $objWriter->endElement();
     }
     $objWriter->endElement();
 }
Пример #2
0
 /**
  * Write chart relationships to XML format
  *
  * @param  PHPPowerPoint_Shape_Chart $pChart
  * @return string                    XML Output
  * @throws Exception
  */
 public function writeChartRelationships(PHPPowerPoint_Shape_Chart $pChart = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Starting relation id
     $relId = 1;
     // Write spreadsheet relationship?
     if ($pChart->getIncludeSpreadsheet()) {
         $this->_writeRelationship($objWriter, $relId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/package', '../embeddings/' . $pChart->getIndexedFilename() . '.xlsx');
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }