public OrgChartViewModel GetOrgChartViewModel() { IEnumerable <User> users = userRepository.GetUsers(); IEnumerable <IGrouping <string, User> > userByGroup = users.GroupBy(u => u.department).OrderBy(g => g.Key); IEnumerable <string> departments = users.Select(u => u.department).Distinct(); OrgChartViewModel model = new OrgChartViewModel(); model.labels = userByGroup.Select(g => g.Key); model.values = new List <int>(); foreach (var group in userByGroup) { model.values.Add(group.Count()); } return(model); }
private void GetViewModelAndBindForEvents() { this.viewModel = this.RootGrid.Resources["ViewModel"] as OrgChartViewModel; this.viewModel.ChildTreeLayoutViewModel.LayoutSettingsChanged += (_, __) => this.LayoutOrgChart(false); this.viewModel.ChildrenExpandedOrCollapsed += this.OnViewModelChildrenExpandedOrCollapsed; }