Пример #1
0
        // Obtains a value of the axis point placed on the "default" axis
        // to display this value in the invoked form title.
        string GetFormTitle(MultiDimensionalData clickedItemData)
        {
            AxisPoint clickedPoint      = clickedItemData.GetAxisPoints(DashboardDataAxisNames.DefaultAxis)[0];
            string    clickedPointValue = clickedPoint.Value.ToString();

            return(clickedPointValue);
        }
        private static void AddRowsByGridDashboardItem(GridDashboardItem gridItem, MultiDimensionalData mData, DataTable dataTable)
        {
            IList <string> axis     = mData.GetAxisNames();
            int            rowCount = GetRowCount(mData, axis);

            for (int i = 0; i < rowCount; i++)
            {
                AxisPoint point  = mData.GetAxisPoints(axis[0])[i];
                DataRow   newRow = dataTable.NewRow();
                foreach (GridColumnBase column in gridItem.Columns)
                {
                    GridMeasureColumn mCol = column as GridMeasureColumn;
                    if (mCol != null)
                    {
                        newRow[mCol.Measure.DataMember] = GetMesureValue(mData, point, mCol);
                    }

                    GridDimensionColumn dCol = column as GridDimensionColumn;
                    if (dCol != null)
                    {
                        newRow[dCol.Dimension.DataMember] = GetDimenstionValue(mData, axis, point, dCol);
                    }
                }
                dataTable.Rows.Add(newRow);
            }
        }
        // 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);
        }
        // Handles the DashboardViewer.DashboardItemClick event.
        private void dashboardViewer1_DashboardItemClick(object sender,
                                                         DashboardItemMouseActionEventArgs e)
        {
            if (e.DashboardItemName == "cardDashboardItem1" & e.GetAxisPoint() != null)
            {
                // Obtains client data related to the clicked card.
                MultiDimensionalData clickedItemData = e.Data.GetSlice(e.GetAxisPoint());
                DeltaDescriptor      delta           = e.GetDeltas()[0];

                // Creates a data table that will be used to hold client data.
                DataTable dataSource = new DataTable();
                dataSource.Columns.Add("Argument", typeof(DateTime));
                dataSource.Columns.Add("Actual", typeof(double));
                dataSource.Columns.Add("Target", typeof(double));

                // Saves values of axis points placed on the "sparkline" axis and corresponding
                // actual/target values to the data table.
                foreach (AxisPoint point in
                         clickedItemData.GetAxisPoints(DashboardDataAxisNames.SparklineAxis))
                {
                    DataRow    row        = dataSource.NewRow();
                    DeltaValue deltaValue = clickedItemData.GetSlice(point).GetDeltaValue(delta);
                    if (deltaValue.ActualValue.Value != null &&
                        deltaValue.TargetValue.Value != null)
                    {
                        row["Argument"] = point.Value;
                        row["Actual"]   = deltaValue.ActualValue.Value;
                        row["Target"]   = deltaValue.TargetValue.Value;
                    }
                    else
                    {
                        row["Argument"] = DBNull.Value;
                        row["Actual"]   = DBNull.Value;
                        row["Target"]   = DBNull.Value;
                    }
                    dataSource.Rows.Add(row);
                }
                DisplayDetailedChart(GetFormTitle(clickedItemData), dataSource);
            }
        }
 private static int GetRowCount(MultiDimensionalData mData, IList <string> axis)
 {
     return(mData.GetAxisPoints(axis[0]).Count);
 }