AxisPoint EnsureInstancePoint(MultiDimensionalData data, AxisPoint axisPoint) { IEnumerable <DimensionDescriptor> axisDimensions = data.GetDimensions(axisPoint.AxisName); DimensionDescriptor instanceDimension = axisDimensions.FirstOrDefault(dim => dim.ID == axisPoint.Dimension.ID); IEnumerable <AxisPoint> points = data.GetAxisPointsByDimension(instanceDimension); return(points.Single(p => p.Equals(axisPoint))); }
// Converts data from a dashboard data model to the Gantt chart data model. ObservableCollection <GanttTask> ConfigureGanttTasks(MultiDimensionalData data) { DimensionDescriptorCollection dimensions = data.GetDimensions(DashboardDataAxisNames.DefaultAxis); MeasureDescriptorCollection measures = data.GetMeasures(); ReadOnlyCollection <AxisPoint> gridRows = data.GetAxisPoints(DashboardDataAxisNames.DefaultAxis); ObservableCollection <GanttTask> tasks = new ObservableCollection <GanttTask>(); List <string> keys = new List <string>(); keys.Add("root"); foreach (AxisPoint row in gridRows) { string parentKey = "root"; foreach (DimensionDescriptor dimension in dimensions.Cast <DimensionDescriptor>()) { string currentKey = parentKey + "|" + row.GetDimensionValue(dimension).DisplayText; if (keys.Contains(currentKey)) { GanttTask currentTask = tasks.Where(t => t.Id == keys.IndexOf(currentKey)).First(); DateTime start = (DateTime)data.GetSlice(row).GetValue(measures[0]).Value; DateTime finish = (DateTime)data.GetSlice(row).GetValue(measures[1]).Value; currentTask.Start = new DateTime(Math.Min(currentTask.Start.Ticks, start.Ticks)); currentTask.Finish = new DateTime(Math.Max(currentTask.Finish.Ticks, finish.Ticks)); } else { keys.Add(currentKey); data.GetSlice(row).GetValue(measures[0]); tasks.Add(new GanttTask() { Id = keys.IndexOf(currentKey), ParentId = keys.IndexOf(parentKey), Name = row.GetDimensionValue(dimension).DisplayText, Start = (DateTime)data.GetSlice(row).GetValue(measures[0]).Value, Finish = (DateTime)data.GetSlice(row).GetValue(measures[1]).Value }); } parentKey = currentKey; } } return(tasks); }
private static object GetDimenstionValue(MultiDimensionalData mData, IList <string> axis, AxisPoint point, GridDimensionColumn dCol) { return(point.GetDimensionValue(mData.GetDimensions(axis[0]).OfType <DimensionDescriptor>().First(d => d.DataMember == dCol.Dimension.DataMember)).Value); }