/** * Initializes the widget options. * This method sets the default values for various options. */ protected function initOptions() { if (empty($this->content) && $this->skipOnEmpty == false) { throw new InvalidConfigException("No content for widget data"); } elseif (empty($this->content)) { return false; } $itemsCount = count($this->content); $colorStep = round(100 / $itemsCount); ArrayHelper::multisort($this->content, 'value', SORT_DESC); foreach ($this->content as $key => $item) { if (empty($this->content[$key]['color'])) { $nextColor = $this->adjustBrightness(isset($nextColor) ? $nextColor : $this->baseColor, $colorStep); $this->content[$key]['color'] = $nextColor; $this->content[$key]['label'] = $this->content[$key]['label']; } } $this->pieOptions['data']['content'] = $this->content; $this->pieOptions['header']['title']['text'] = $this->title; $this->pieOptions = ArrayHelper::merge($this->pieOptions, $this->options); $this->registerAssets(); }