getValues() public method

Get Values
public getValues ( ) : array
return array
Exemplo n.º 1
0
 public function testValue()
 {
     $object = new Series();
     $array = array('0' => 'a', '1' => 'b', '2' => 'c', '3' => 'd');
     $this->assertInternalType('array', $object->getValues());
     $this->assertEmpty($object->getValues());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Series', $object->setValues());
     $this->assertEmpty($object->getValues());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Series', $object->setValues($array));
     $this->assertCount(count($array), $object->getValues());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Series', $object->addValue(4, 'e'));
     $this->assertCount(count($array) + 1, $object->getValues());
 }
Exemplo n.º 2
0
 /**
  * @param Chart $chart
  * @param Chart\Series $series
  * @throws \Exception
  */
 private function writeSeries(Chart $chart, Chart\Series $series)
 {
     $chartType = $chart->getPlotArea()->getType();
     $numRange = count($series->getValues());
     // chart:series
     $this->xmlContent->startElement('chart:series');
     $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$' . $this->rangeCol . '$2:.$' . $this->rangeCol . '$' . ($numRange + 1));
     $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$' . $this->rangeCol . '$1');
     if ($chartType instanceof Area) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:area');
     } elseif ($chartType instanceof AbstractTypeBar) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:bar');
     } elseif ($chartType instanceof Line) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:line');
     } elseif ($chartType instanceof AbstractTypePie) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:circle');
     } elseif ($chartType instanceof Scatter) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
     }
     $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries);
     if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) {
         $dataPointFills = $series->getDataPointFills();
         if (empty($dataPointFills)) {
             $incRepeat = $numRange;
         } else {
             $inc = 0;
             $incRepeat = 0;
             $newFill = new Fill();
             do {
                 if ($series->getDataPointFill($inc)->getHashCode() != $newFill->getHashCode()) {
                     // chart:data-point
                     $this->xmlContent->startElement('chart:data-point');
                     $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
                     // > chart:data-point
                     $this->xmlContent->endElement();
                     $incRepeat = 0;
                     // chart:data-point
                     $this->xmlContent->startElement('chart:data-point');
                     $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries . '_' . $inc);
                     // > chart:data-point
                     $this->xmlContent->endElement();
                 }
                 $inc++;
                 $incRepeat++;
             } while ($inc < $numRange);
             $incRepeat--;
         }
         // chart:data-point
         $this->xmlContent->startElement('chart:data-point');
         $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
         // > chart:data-point
         $this->xmlContent->endElement();
     } elseif ($chartType instanceof AbstractTypePie) {
         $count = count($series->getDataPointFills());
         for ($inc = 0; $inc < $count; $inc++) {
             // chart:data-point
             $this->xmlContent->startElement('chart:data-point');
             $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries . '_' . $inc);
             // > chart:data-point
             $this->xmlContent->endElement();
         }
     }
     // > chart:series
     $this->xmlContent->endElement();
 }