private void dashboardViewer1_DashboardItemElementCustomColor(object sender,
                                                                      DashboardItemElementCustomColorEventArgs e)
        {
            MultiDimensionalData data           = e.Data;
            AxisPointTuple       currentElement = e.TargetElement;

            if (e.DashboardItemName == "chartDashboardItem1")
            {
                string country =
                    currentElement.GetAxisPoint(DashboardDataAxisNames.ChartSeriesAxis).Value.ToString();
                decimal value = (decimal)(data.GetSlice(currentElement)).GetValue(e.Measures[0]).Value;
                if (country == "UK" && value > 50000 || country == "USA" && value > 100000)
                {
                    e.Color = Color.DarkGreen;
                }
                else
                {
                    e.Color = Color.DarkRed;
                }
            }
            if (e.DashboardItemName == "pieDashboardItem1")
            {
                decimal value =
                    (decimal)(data.GetSlice(currentElement)).GetValue(data.GetMeasures()[0]).Value;
                if (value < 100000)
                {
                    e.Color = Color.Orange;
                }
            }
        }
        void CustomizePieTotalLabel(string componentName, MultiDimensionalData data, CustomizePieTotalLabelEventArgs e)
        {
            PieTotalSettings settings   = PieTotalSettings.FromJson(dashboardControl.Dashboard.Items[componentName].CustomProperties[customPropertyName]);
            string           resultText = string.Empty;

            if (!string.IsNullOrEmpty(settings.Prefix))
            {
                resultText += settings.Prefix + Environment.NewLine;
            }



            MeasureDescriptor measure = data.GetMeasures().First();

            if (!string.IsNullOrEmpty(settings.MeasureId) ||
                data.GetMeasures().Where(m => m.ID == settings.MeasureId).Any())
            {
                measure = data.GetMeasures().FirstOrDefault(m => m.ID == settings.MeasureId);
            }
            if (measure != null)
            {
                AxisPoint axisPoint = e.Series.Tag as AxisPoint;
                resultText += data.GetSlice(axisPoint).GetValue(measure).DisplayText;
            }
            if (!string.IsNullOrEmpty(settings.Postfix))
            {
                resultText += Environment.NewLine + settings.Postfix;
            }
            e.Text = resultText;
        }
        // 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 object GetMesureValue(MultiDimensionalData mData, AxisPoint point, GridMeasureColumn mCol)
 {
     return(mData.GetSlice(point).GetValue(mData.GetMeasures().OfType <MeasureDescriptor>().First(d => d.DataMember == mCol.Measure.DataMember)).Value);
 }