public function clusterChart($searchModel) { $from = strtotime('today', $searchModel->timestampFrom); $to = strtotime('tomorrow', $searchModel->timestampTo); $query = Window::find()->select(['title'])->joinWith('records')->distinct(true)->orderBy('title'); StatsHelper::whereFromTo($query, $from, $to); $titles = $query->createCommand()->queryColumn(); $titles = array_filter($titles, function ($a) { return trim($a) != ''; }); $clusters = ClusterHelper::clusterizeStrings($titles); $clustersList = array_map(function ($a) { return ['id' => $a, 'name' => $a]; }, array_unique(array_values($clusters))); $this->view->registerJs('var dashboardClusters = ' . json_encode($clustersList), View::POS_HEAD); $durations = ClusterHelper::getProcessWindowHierarchy($clusters, $from, $to); $this->view->registerJs('var dashboardClustersDurations = ' . json_encode($durations), View::POS_HEAD); $this->view->registerAssetBundle(SunburstAsset::className()); }
public function clusterData($fromTimestamp, $toTimestamp) { $windows = StatsHelper::windows($fromTimestamp, $toTimestamp); list($clusters, $winIdCluster) = ClusterHelper::clusterizeStrings($windows); $from = $fromTimestamp; $to = $toTimestamp; $clustersList = array_map(function ($a) { return ['id' => $a, 'name' => $a]; }, array_unique(array_values($clusters))); $durations = ClusterHelper::getProcessWindowHierarchy($winIdCluster, $from, $to); return ['clusters' => $clustersList, 'durations' => $durations]; }