private GraphXAxisRootDto GetRoot(DimensionTree allDimensionsTree, DimensionDto xDimension, Measure measure,
                                          IEnumerable <DimensionValueDto> filteredXValues, List <FlatDimensionDto> filters,
                                          DimensionValueDto xValue = null, DimensionDto legendDimension = null)
        {
            GraphXAxisRootDto xAxisRoot;

            if (legendDimension == null)
            {
                xAxisRoot = new DrilldownGraphXAxisRootDto
                {
                    Id          = xValue?.Id ?? 0,
                    Name        = xValue?.Value ?? string.Empty,
                    XAxisLeaves = new List <GraphXAxisLeafDto>()
                };
                var leaf = GetLeaf(allDimensionsTree, xDimension, xValue, measure, filters);
                xAxisRoot.XAxisLeaves.Add(leaf);
            }
            else
            {
                xAxisRoot = new GroupedGraphXAxisRootDto
                {
                    Id          = xValue?.Id ?? 0,
                    Name        = xValue?.Value ?? string.Empty,
                    XAxisLeaves = new List <GraphXAxisLeafDto>()
                };
                foreach (var dimValue in filteredXValues)
                {
                    var leaf = GetLeaf(allDimensionsTree, xDimension, dimValue, measure, filters, legendDimension);
                    xAxisRoot.XAxisLeaves.Add(leaf);
                }
            }

            return(xAxisRoot);
        }
        private GraphXAxisRootDto GetParentRoot(DimensionTree allDimensionsTree, TreeDimensionDto childDimension,
                                                Measure measure, DimensionValueDto xValue, List <FlatDimensionDto> filters, DimensionDto legendDimension = null)
        {
            GraphXAxisRootDto xAxisRoot;

            if (legendDimension == null)
            {
                xAxisRoot = new DrilldownGraphXAxisRootDto
                {
                    Id          = xValue.Id,
                    Name        = xValue.Value,
                    XAxisLeaves = new List <GraphXAxisLeafDto>()
                };
            }
            else
            {
                xAxisRoot = new GroupedGraphXAxisRootDto
                {
                    Id          = xValue.Id,
                    Name        = xValue.Value,
                    XAxisLeaves = new List <GraphXAxisLeafDto>()
                };
            }
            var parentDimension = allDimensionsTree.GetDimensionDto((int)childDimension.ParentId);
            var xDimValues      = _querier.GetValuesOfDimension(
                parentDimension, new Column {
                Name = childDimension.IdName, Value = xValue.Id.ToString()
            });
            var filteredValues = GetFilteredValues(allDimensionsTree, parentDimension, filters, xDimValues);

            foreach (var dimValue in filteredValues)
            {
                var leaf = GetLeaf(allDimensionsTree, allDimensionsTree.GetDimensionDto((int)childDimension.ParentId), dimValue, measure, filters, legendDimension);
                xAxisRoot.XAxisLeaves.Add(leaf);
            }
            return(xAxisRoot);
        }
        public static GroupedGraphDto GetGroupedGraph()
        {
            var root1 = new GroupedGraphXAxisRootDto
            {
                Name        = "Bakery",
                XAxisLeaves = new List <GraphXAxisLeafDto>
                {
                    new GroupedGraphXAxisLeafDto
                    {
                        Name         = "Bread",
                        LegendValues = new List <GraphLegendValueDto>
                        {
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Europe"
                                }, Value = 30
                            },
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Asia"
                                }, Value = 50
                            },
                        }
                    },
                    new GroupedGraphXAxisLeafDto
                    {
                        Name         = "Bun",
                        LegendValues = new List <GraphLegendValueDto>
                        {
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Europe"
                                }, Value = 70
                            },
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Asia"
                                }, Value = 80
                            },
                        }
                    },
                }
            };
            var root2 = new GroupedGraphXAxisRootDto
            {
                Name        = "Dairy",
                XAxisLeaves = new List <GraphXAxisLeafDto>
                {
                    new GroupedGraphXAxisLeafDto
                    {
                        Name         = "Milk",
                        LegendValues = new List <GraphLegendValueDto>
                        {
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Europe"
                                }, Value = 15
                            },
                            new GraphLegendValueDto {
                                Legend = new GraphLegendDto {
                                    Name = "Asia"
                                }, Value = 35
                            },
                        }
                    }
                }
            };

            return(new GroupedGraphDto
            {
                Name = "Grouped graph",
                Roots = new List <GraphXAxisRootDto>
                {
                    root1, root2
                }
            });
        }