public GroupedGraphDto GetGroupedGraph(DimensionTree allDimensionsTree, TreeDimensionDto xDimension,
                                               DimensionDto legendDimension, Measure measure, List <FlatDimensionDto> filterDimensions, bool group)
        {
            var graph = new GroupedGraphDto
            {
                Name  = $"Grouped graph of {measure.Name} by {xDimension.Name} and {legendDimension.Name}",
                Roots = new List <GraphXAxisRootDto>()
            };
            var xDimIsRoot      = allDimensionsTree.IsRoot(xDimension.Id);
            var filteredXValues = GetFilteredValues(allDimensionsTree, xDimension, filterDimensions);

            // if x-dimension is root dimension, its values will be leaves
            // x-dim values will be also leaves if graph should not be grouped
            if (xDimIsRoot || !group)
            {
                graph.Roots.Add(GetRoot(allDimensionsTree, xDimension, measure, filteredXValues, filterDimensions, null, legendDimension));
            }
            // otherwise its values will be root and its parents values will be leaves
            else
            {
                foreach (var xValue in filteredXValues)
                {
                    graph.Roots.Add(GetParentRoot(allDimensionsTree, xDimension, measure, xValue, filterDimensions, legendDimension));
                }
            }
            return(graph);
        }
 public GroupedChartViewModel Map(GroupedGraphDto graph)
 {
     var viewModel = new GroupedChartViewModel
     {
         Categories = new List<GroupedCategoryViewModel>(),
         ChartTitle = graph.Name,
         Series = new List<GroupedSeriesViewModel>()
     };
     viewModel.Categories.AddRange(GetCategories(graph.Roots));
     viewModel.Series.AddRange(GetSeries(graph.GetLegendValues().ToList()));
     return viewModel;
 }