public Form1()
        {
            InitializeComponent();
            dashboardDesigner1.CreateRibbon();

            // Creates a color table containing dimension values, measures and corresponding colors.
            DataTable colorTable = CreateColorTable();
            // Loads a dashboard from the XML file.
            Dashboard            dashboard  = new Dashboard(); dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");
            IDashboardDataSource dataSource = dashboard.DataSources["dataSource1"];

            // Specifies the coloring mode for the specified pie series, pie measures and chart argument.
            PieDashboardItem   pie1   = (PieDashboardItem)dashboard.Items["pieDashboardItem1"];
            ChartDashboardItem chart1 = (ChartDashboardItem)dashboard.Items["chartDashboardItem1"];

            pie1.SeriesDimensions[0].ColoringMode     = ColoringMode.Hue;
            pie1.ColoringOptions.MeasuresColoringMode = ColoringMode.Hue;
            chart1.Arguments[0].ColoringMode          = ColoringMode.Hue;

            foreach (DataRow row in colorTable.Rows)
            {
                dashboard.ColorScheme.Add(CreateColorSchemeEntry(row, dataSource, false));
                dashboard.ColorScheme.Add(CreateColorSchemeEntry(row, dataSource, true));
            }
            dashboardDesigner1.Dashboard = dashboard;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: HongTham06/DoAn
        void InitializeDashboardItems()
        {
            IDashboardDataSource olapDataSource = dashboardDesigner1.Dashboard.DataSources[0];

            // PivotDashboardItem pivot = new PivotDashboardItem();

            /*pivot.DataSource = olapDataSource;
             * pivot.Values.Add(new Measure("[Measures].[Sales Amount]"));
             * pivot.Columns.Add(new Dimension("[Sales Channel].[Sales Channel].[Sales Channel]"));
             * pivot.Rows.AddRange(
             *  new Dimension("[Sales Territory].[Sales Territory].[Group]", 1),
             *  new Dimension("[Sales Territory].[Sales Territory].[Country]", 1),
             *  new Dimension("[Sales Territory].[Sales Territory].[Region]", 1));
             * pivot.AutoExpandRowGroups = true;*/

            ChartDashboardItem chart = new ChartDashboardItem();

            chart.DataSource = olapDataSource;
            chart.Arguments.Add(new Dimension("[Sales Territory].[Sales Territory].[Country]"));
            chart.Panes.Add(new ChartPane());
            SimpleSeries salesAmountSeries = new SimpleSeries(SimpleSeriesType.Bar);

            salesAmountSeries.Value = new Measure("[Measures].[Sales Amount]");
            chart.Panes[0].Series.Add(salesAmountSeries);
            dashboardDesigner1.Dashboard.Items.AddRange(chart);
        }
コード例 #3
0
        private Dashboard CreateDashboard()
        {
            Dashboard dashBoard = new Dashboard();

            IDashboardDataSource sqlDataSource = CreateSqlDataSource();

            dashBoard.DataSources.Add(sqlDataSource);

            ChartDashboardItem chart = new ChartDashboardItem();

            chart.DataSource = sqlDataSource; chart.DataMember = "MyQuery";
            chart.Arguments.Add(new Dimension("OrderDate", DateTimeGroupInterval.MonthYear));
            chart.Panes.Add(new ChartPane());
            SimpleSeries salesAmountSeries = new SimpleSeries(SimpleSeriesType.SplineArea);

            salesAmountSeries.Value = new Measure("ExtendedPrice");
            chart.Panes[0].Series.Add(salesAmountSeries);

            GridDashboardItem grid = new GridDashboardItem();

            grid.DataSource = sqlDataSource;
            grid.DataMember = "MyQuery";
            grid.Columns.Add(new GridDimensionColumn(new Dimension("SalesPerson")));
            grid.Columns.Add(new GridMeasureColumn(new Measure("ExtendedPrice")));

            dashBoard.Items.AddRange(chart, grid);

            return(dashBoard);
        }
        private RangeFilterDashboardItem CreateRangeFilter(IDashboardDataSource dataSource)
        {
            RangeFilterDashboardItem rangeFilter = new RangeFilterDashboardItem();

            rangeFilter.DataSource = dataSource;
            SimpleSeries salesAmountSeries = new SimpleSeries(SimpleSeriesType.Area);

            rangeFilter.Series.Add(salesAmountSeries);
            salesAmountSeries.Value = new Measure("Extended Price");
            rangeFilter.Argument    = new Dimension("OrderDate");
            rangeFilter.Argument.DateTimeGroupInterval = DateTimeGroupInterval.MonthYear;
            rangeFilter.FilterString = "[OrderDate] > #2018-01-01#";
            rangeFilter.DateTimePeriods.AddRange(
                DateTimePeriod.CreateLastYear(),
                DateTimePeriod.CreateNextMonths("Next 3 Months", 3),
                new DateTimePeriod
            {
                Name  = "Year To Date",
                Start = new FlowDateTimePeriodLimit(DateTimeInterval.Year, 0),
                End   = new FlowDateTimePeriodLimit(DateTimeInterval.Day, 1)
            },
                new DateTimePeriod
            {
                Name  = "Jul-18-2018 - Jan-18-2019",
                Start = new FixedDateTimePeriodLimit(new DateTime(2018, 7, 18)),
                End   = new FixedDateTimePeriodLimit(new DateTime(2019, 1, 18))
            }
                );
            rangeFilter.DefaultDateTimePeriodName = "Year To Date";
            // The caption is initially hidden. Uncomment the line below to show the caption.
            //rangeFilter.ShowCaption = true;
            return(rangeFilter);
        }
        public static DashboardItem GenerateCardItem(IDashboardDataSource dataSource, string itemComponentName)
        {
            CardDashboardItem cardItem = new CardDashboardItem()
            {
                ComponentName = itemComponentName
            };

            cardItem.SeriesDimensions.Add(new Dimension("Country"));
            cardItem.SparklineArgument = new Dimension("SalesDate", DateTimeGroupInterval.DayMonthYear);
            cardItem.DataSource        = dataSource;
            cardItem.ShowCaption       = false;

            Measure actualValue = new Measure("Sales");

            actualValue.NumericFormat.FormatType = DataItemNumericFormatType.Currency;
            Measure targetValue = new Measure("SalesTarget");

            targetValue.NumericFormat.FormatType = DataItemNumericFormatType.Currency;
            Card card = new Card(actualValue, targetValue);

            card.LayoutTemplate = new CardCompactLayoutTemplate();
            cardItem.Cards.Add(card);

            return(cardItem);
        }
        static void UpdateDataSourceParametersNames(IDashboardDataSource dataSource, string originalNamePattern, string copyNamePattern)
        {
            DashboardSqlDataSource sqlDataSource = dataSource as DashboardSqlDataSource;

            if (sqlDataSource != null)
            {
                UpdateSqlDataSourceParameters(sqlDataSource, originalNamePattern, copyNamePattern);
            }
        }
        static bool ResolveNamesConflict(IDashboardDataSource dataSourceCopy, DataSourceCollection toDataSources, IDictionary <string, string> dataSourceNamesMap)
        {
            // Provide your data source component names confilict resolution logic here

            string newName = NamesGenerator.GenerateName(dataSourceCopy.ComponentName, 1, toDataSources.Select(ds => ds.ComponentName));

            dataSourceNamesMap.Add(dataSourceCopy.ComponentName, newName);
            dataSourceCopy.ComponentName = newName;
            return(true);
        }
        private PieDashboardItem CreatePies(IDashboardDataSource dataSource)
        {
            PieDashboardItem pies = new PieDashboardItem();

            pies.DataSource = dataSource;
            pies.Values.Add(new Measure("Extended Price"));
            pies.Arguments.Add(new Dimension("Country"));
            pies.SeriesDimensions.Add(new Dimension("OrderDate"));
            return(pies);
        }
        private PivotDashboardItem CreatePivot(IDashboardDataSource dataSource)
        {
            PivotDashboardItem pivot = new PivotDashboardItem();

            pivot.DataSource = dataSource;
            pivot.Columns.AddRange(new Dimension("Country"), new Dimension("Sales Person"));
            pivot.Rows.AddRange(new Dimension("CategoryName"), new Dimension("ProductName"));
            pivot.Values.AddRange(new Measure("Extended Price"), new Measure("Quantity"));
            pivot.AutoExpandColumnGroups = true;
            return(pivot);
        }
        public static DashboardItem GenerateListBoxItem(IDashboardDataSource dataSource, string itemComponentName)
        {
            ListBoxDashboardItem listBoxItem = new ListBoxDashboardItem()
            {
                ComponentName = itemComponentName
            };

            listBoxItem.Name       = "Countries";
            listBoxItem.DataSource = dataSource;
            listBoxItem.FilterDimensions.Add(new Dimension("Country"));
            listBoxItem.InteractivityOptions.IgnoreMasterFilters = false;

            return(listBoxItem);
        }
        public static DashboardItem GeneratePieItem(IDashboardDataSource dataSource, string itemComponentName)
        {
            PieDashboardItem pieItem = new PieDashboardItem()
            {
                ComponentName = itemComponentName
            };

            pieItem.DataSource = dataSource;
            pieItem.Values.Add(new Measure("Sales"));
            pieItem.Arguments.Add(new Dimension("Country"));
            pieItem.SeriesDimensions.Add(new Dimension("SalesDate"));

            return(pieItem);
        }
        public static DashboardItem GenerateGridItem(IDashboardDataSource dataSource, string itemComponentName)
        {
            GridDashboardItem gridItem = new GridDashboardItem()
            {
                ComponentName = itemComponentName
            };

            gridItem.DataSource = dataSource;

            gridItem.Columns.Add(new GridDimensionColumn(new Dimension("Country")));
            gridItem.Columns.Add(new GridMeasureColumn(new Measure("Sales")));
            gridItem.Columns.Add(new GridDeltaColumn(new Measure("Sales"), new Measure("SalesTarget")));
            gridItem.Columns.Add(new GridSparklineColumn(new Measure("Sales")));
            gridItem.SparklineArgument = new Dimension("SalesDate", DateTimeGroupInterval.MonthYear);

            return(gridItem);
        }
コード例 #13
0
        private PivotDashboardItem CreatePivot(IDashboardDataSource dataSource)
        {
            // Create a pivot dashboard item and specify its data source.
            PivotDashboardItem pivot = new PivotDashboardItem();

            pivot.DataSource = dataSource;

            // Specify dimensions that provide pivot column and row headers.
            pivot.Columns.AddRange(new Dimension("Country"), new Dimension("Sales Person"));
            pivot.Rows.AddRange(new Dimension("CategoryName"), new Dimension("ProductName"));

            // Specify measures whose data is used to calculate pivot cell values.
            pivot.Values.AddRange(new Measure("Extended Price"), new Measure("Quantity"));

            // Specify the default expanded state of pivot column field values.
            pivot.AutoExpandColumnGroups = true;

            return(pivot);
        }
コード例 #14
0
        private RangeFilterDashboardItem CreateRangeFilter(IDashboardDataSource dataSource)
        {
            // Create a Range Filter dashboard item and specify its data source.
            RangeFilterDashboardItem rangeFilter = new RangeFilterDashboardItem();

            rangeFilter.DataSource = dataSource;
            // Create a new series of the Area type and add this series to the Series collection to
            // display it within the Range Filter.
            SimpleSeries salesAmountSeries = new SimpleSeries(SimpleSeriesType.Area);

            rangeFilter.Series.Add(salesAmountSeries);
            // Specify a measure to provide data used to calculate the Y-coordinate of the data points.
            salesAmountSeries.Value = new Measure("Extended Price");
            // Specify a dimension to provide Range Filter argument values.
            rangeFilter.Argument = new Dimension("OrderDate");
            // Specify a group interval for argument values.
            rangeFilter.Argument.DateTimeGroupInterval = DateTimeGroupInterval.MonthYear;
            // Restrict the displayed data.
            rangeFilter.FilterString = "[OrderDate] > #2018-01-01#";
            // Add predefined ranges to the context menu.
            // You can show the item caption and use the Select Date Time Periods drop-down button to apply predefined ranges.
            rangeFilter.DateTimePeriods.AddRange(
                DateTimePeriod.CreateLastYear(),
                DateTimePeriod.CreateNextMonths("Next 3 Months", 3),
                new DateTimePeriod
            {
                Name  = "Year To Date",
                Start = new FlowDateTimePeriodLimit(DateTimeInterval.Year, 0),
                End   = new FlowDateTimePeriodLimit(DateTimeInterval.Day, 1)
            },
                new DateTimePeriod
            {
                Name  = "Jul-18-2018 - Jan-18-2019",
                Start = new FixedDateTimePeriodLimit(new DateTime(2018, 7, 18)),
                End   = new FixedDateTimePeriodLimit(new DateTime(2019, 1, 18))
            }
                );
            // Specify the period selected when the control is initialized.
            rangeFilter.DefaultDateTimePeriodName = "Year To Date";
            // The caption is initially hidden. Uncomment the line to show the caption.
            //rangeFilter.ShowCaption = true;
            return(rangeFilter);
        }
        static void AddDataSourceCopy(IDashboardDataSource dataSource, DashboardMerger dashboardMerger, Action <IDashboardDataSource> addDataSourceDelegate)
        {
            DataSourceCollection         toDataSources      = dashboardMerger.TargetDashboard.DataSources;
            IDictionary <string, string> dataSourceNamesMap = dashboardMerger.DataSourceNamesMap;
            IDashboardDataSource         dataSourceCopy     = CreateDataSourceCopy(dataSource);

            if (dataSourceCopy != null)
            {
                if (toDataSources.Any(d => d.ComponentName == dataSourceCopy.ComponentName))
                {
                    if (ResolveNamesConflict(dataSourceCopy, toDataSources, dataSourceNamesMap))
                    {
                        addDataSourceDelegate(dataSourceCopy);
                    }
                }
                else
                {
                    addDataSourceDelegate(dataSourceCopy);
                }
            }
        }
        // Creates color scheme entries used to map dimension values, measures and colors.
        private ColorSchemeEntry CreateColorSchemeEntry(DataRow colorSchemeRecord,
                                                        IDashboardDataSource dataSource,
                                                        bool includeMeasures)
        {
            DimensionDefinition categoryDefinition = new DimensionDefinition("CategoryName");
            DimensionDefinition countryDefinition  = new DimensionDefinition("Country");
            MeasureDefinition   priceDefinition    = new MeasureDefinition("Extended Price");

            ColorSchemeEntry entry = new ColorSchemeEntry();

            entry.DimensionKeys.Add(new ColorSchemeDimensionKey(categoryDefinition,
                                                                colorSchemeRecord["CategoryName"]));
            entry.DimensionKeys.Add(new ColorSchemeDimensionKey(countryDefinition,
                                                                colorSchemeRecord["Country"]));
            if (includeMeasures)
            {
                entry.MeasureKey = new ColorSchemeMeasureKey(priceDefinition);
            }
            entry.ColorDefinition = new ColorDefinition((Color)colorSchemeRecord["color"]);
            entry.DataSource      = dataSource;
            return(entry);
        }
コード例 #17
0
 protected static Dashboard CreateCopy(Dashboard dashboard)
 {
     using (Stream stream = new MemoryStream())
     {
         dashboard.SaveToXml(stream);
         stream.Seek(0L, SeekOrigin.Begin);
         Dashboard copy = new Dashboard();
         copy.LoadFromXml(stream);
         for (int i = 0; i < dashboard.DataSources.Count; i++)
         {
             IDashboardDataSource dataSource = dashboard.DataSources[i];
             if (dataSource is DashboardObjectDataSource)
             {
                 copy.DataSources[i].Data = dataSource.Data;
             }
             DashboardExtractDataSource extractDataSource = dataSource as DashboardExtractDataSource;
             if (extractDataSource is DashboardExtractDataSource)
             {
                 ((DashboardExtractDataSource)copy.DataSources[i]).FileName = extractDataSource.FileName;
             }
         }
         return(copy);
     }
 }
        static IDashboardDataSource CreateDataSourceCopy(IDashboardDataSource dataSourceToCopy)
        {
            DashboardEFDataSource efDataSource = dataSourceToCopy as DashboardEFDataSource;

            if (efDataSource != null)
            {
                XElement element = efDataSource.SaveToXml();
                DashboardEFDataSource newDataSource = new DashboardEFDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardExcelDataSource excelDataSource = dataSourceToCopy as DashboardExcelDataSource;

            if (excelDataSource != null)
            {
                XElement element = excelDataSource.SaveToXml();
                DashboardExcelDataSource newDataSource = new DashboardExcelDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardExtractDataSource extractDataSource = dataSourceToCopy as DashboardExtractDataSource;

            if (extractDataSource != null)
            {
                XElement element = extractDataSource.SaveToXml();
                DashboardExtractDataSource newDataSource = new DashboardExtractDataSource();
                newDataSource.LoadFromXml(element);
                return(newDataSource);
            }

            DashboardObjectDataSource objectDataSource = dataSourceToCopy as DashboardObjectDataSource;

            if (objectDataSource != null)
            {
                XElement element = objectDataSource.SaveToXml();
                DashboardObjectDataSource newDataSource = new DashboardObjectDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardOlapDataSource olapDataSource = dataSourceToCopy as DashboardOlapDataSource;

            if (olapDataSource != null)
            {
                XElement element = olapDataSource.SaveToXml();
                DashboardOlapDataSource newDataSource = new DashboardOlapDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }

            DashboardSqlDataSource sqlDataSource = dataSourceToCopy as DashboardSqlDataSource;

            if (sqlDataSource != null)
            {
                XElement element = sqlDataSource.SaveToXml();
                DashboardSqlDataSource newDataSource = new DashboardSqlDataSource();
                newDataSource.LoadFromXml(element);
                newDataSource.Fill();
                return(newDataSource);
            }
            return(null);
        }