Example #1
0
 /**
  * @param Closure|null $callback
  * @return string
  */
 public function render(Closure $callback = null)
 {
     $data = $this->treemap->getMap();
     $data = $this->format($data, $this->treemap);
     array_walk($data, [$this, 'nodeRenderrer']);
     if ($callback) {
         array_walk($data, $callback);
     }
     return $this->renderInternal($data);
 }
 /**
  * @param Treemap $root
  * @param $id
  * @return array
  */
 protected function getPresenters(Treemap $root, $id)
 {
     $presenters = [];
     foreach ($root->getMap() as $key => $node) {
         if (isset($node[$root->childrenAttribute]) && !empty($node[$root->childrenAttribute])) {
             $map = new Treemap($node[$root->childrenAttribute], $root->width, $root->height);
             $map->valueAttribute = $root->valueAttribute;
             $map->childrenAttribute = $root->childrenAttribute;
             $map->setNodeFrameResolver([$this, 'resolveNodeFrame']);
             $key = "{$id}-{$key}";
             $presenter = new HtmlPresenter($map);
             $presenters[$key] = $presenter;
             $presenters = array_merge($presenters, $this->getPresenters($map, $key));
         }
     }
     return $presenters;
 }