public DrilldownGraphDto GetDrilldownGraph(DimensionTree allDimensionsTree, TreeDimensionDto xDimension,
                                                   Measure measure, List <FlatDimensionDto> filters, bool requireDrilldownChart)
        {
            var graph = new DrilldownGraphDto
            {
                DimensionName = xDimension.Name,
                Name          = $"Drilldown graph of {measure.Name} by {xDimension.Name}",
                Roots         = new List <GraphXAxisRootDto>()
            };
            var xDimIsRoot = allDimensionsTree.IsRoot(xDimension.Id);

            // if x-dimension is root dimension, there is no point for showing drilldown graph
            if (xDimIsRoot && !requireDrilldownChart)
            {
                return(null);
            }
            // otherwise values of x dimension will be root and its parents values will be leaves
            else if (!xDimIsRoot)
            {
                var filteredXValues = GetFilteredValues(allDimensionsTree, xDimension, filters);
                foreach (var xValue in filteredXValues)
                {
                    graph.Roots.Add(GetParentRoot(allDimensionsTree, xDimension, measure, xValue, filters));
                }
            }
            else
            {
                var filteredXValues = GetFilteredValues(allDimensionsTree, xDimension, filters).ToList();
                foreach (var xValue in filteredXValues)
                {
                    graph.Roots.Add(GetRoot(allDimensionsTree, xDimension, measure, filteredXValues, filters, xValue));
                }
            }
            return(graph);
        }
 public DrilldownChartViewModel Map(DrilldownGraphDto graph)
 {
     if (graph == null) return null;
     return new DrilldownChartViewModel
     {
         ChartTitle = graph.Name,
         Series = new [] { GetSeries(graph) } ,
         Drilldown = GetDrilldown(graph)
     };
 }
 private DrilldownViewModel GetDrilldown(DrilldownGraphDto graph)
 {
     var viewModel = new DrilldownViewModel
     {
         Series = new DrilldownSeriesViewModel[graph.Roots.Count]
     };
     for (int i = 0; i < graph.Roots.Count; i++)
     {
         viewModel.Series[i] = GetSeries(graph.Roots.Cast<DrilldownGraphXAxisRootDto>().ToList()[i]);
     }
     return viewModel;
 }
 private DrilldownSeriesViewModel GetSeries(DrilldownGraphDto graph)
 {
     var graphRoots = graph.Roots.Cast<DrilldownGraphXAxisRootDto>().ToList();
     var series = new DrilldownSeriesViewModel
     {
         Id = graph.Name,
         Name = graph.DimensionName,
         Data = new DrilldownSeriesDataViewModel[graph.Roots.Count]
     };
     for (int i = 0; i < graph.Roots.Count; i++)
     {
         series.Data[i] = new DrilldownSeriesDataViewModel
         {
             Drilldown = graphRoots[i].Name,
             Name = graphRoots[i].Name,
             Y = graphRoots[i].GetValue()
         };
     }
     return series;
 }