public function createLegend($name)
    {
        if ($this->legend) {
            $this->finishLegend();
        }

        $legend = $this->legendClass->newInstance($name);

        $event = new CreateLegendEvent($legend, $this);
        $this->dispatchEvent($event);
        $this->legend = $event->getLegend();

        return $this;
    }