public Form1()
        {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            DashboardSqlDataSource dataSource = new DashboardSqlDataSource();
            CustomSqlQuery         sqlQuery   = new CustomSqlQuery("Countries", "select * from Countries");

            dataSource.ConnectionParameters = new Access97ConnectionParameters(@"..\..\Data\countriesDB.mdb", "", "");
            dataSource.Queries.Add(sqlQuery);

            ChoroplethMapDashboardItem choroplethMap = new ChoroplethMapDashboardItem();

            choroplethMap.DataSource = dataSource;
            choroplethMap.DataMember = "Countries";

            choroplethMap.Area = ShapefileArea.WorldCountries;

            choroplethMap.AttributeName      = "NAME";
            choroplethMap.AttributeDimension = new Dimension("Country");

            ValueMap populationMap = new ValueMap(new Measure("Population"));

            choroplethMap.Maps.Add(populationMap);

            dashboard.Items.Add(choroplethMap);
            dashboardViewer1.Dashboard = dashboard;
        }
        public Form1()
        {
            InitializeComponent();
            // Loads a dashboard that contains a choropleth map with the default palette.
            Dashboard dashboard = new Dashboard();

            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            // Gets the ValueMap object that provides data for coloring map shapes.
            ChoroplethMapDashboardItem map = (ChoroplethMapDashboardItem)dashboard.Items[0];
            ValueMap populationMap         = (ValueMap)map.Maps[0];

            // Creates CustomPalette and CustomScale objects.
            CustomPalette customPalette = new CustomPalette();
            CustomScale   customScale   = new CustomScale();

            // Creates lists of custom colors and range stops.
            List <Color>  customColors = new List <Color>();
            List <double> rangeStops   = new List <double>();

            // Specifies that the absolute scale is used to define a set of colors.
            customScale.IsPercent = false;

            // Specifies custom colors and corresponding range stops.
            customColors.Add(Color.LightBlue);  rangeStops.Add(100000);
            customColors.Add(Color.SkyBlue);    rangeStops.Add(1000000);
            customColors.Add(Color.LightCoral); rangeStops.Add(10000000);
            customColors.Add(Color.Tomato);     rangeStops.Add(100000000);
            customColors.Add(Color.Maroon);     rangeStops.Add(1000000000);

            // Adds custom colors and range stops to a custom palette and corresponding custom scale.
            customPalette.Colors.AddRange(customColors);
            customScale.RangeStops.AddRange(rangeStops);

            // Specifies a custom palette and scale for the ValueMap object.
            populationMap.Palette = customPalette;
            populationMap.Scale   = customScale;

            // Sets the customized dashboard as a currently opened dashboard.
            dashboardViewer1.Dashboard = dashboard;
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();

            //Create an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource();

            excelDataSource.FileName = @"..\..\Data\Sales.xlsx";
            ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("Sheet1", "A1:I4166");

            excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
            excelDataSource.Fill();
            dashboard.DataSources.Add(excelDataSource);

            // Create a Choropleth Map dashboard item.
            ChoroplethMapDashboardItem map = new ChoroplethMapDashboardItem();

            map.Name                    = "Choropleth Map";
            map.DataSource              = excelDataSource;
            map.Legend.Visible          = true;
            map.ShapeTitleAttributeName = "NAME";
            map.AttributeName           = "NAME";
            map.AttributeDimension      = new Dimension("State");
            ValueMap revenueYTDMap = new ValueMap(new Measure("RevenueYTD (Sum)"));

            map.Maps.Add(revenueYTDMap);

            // Loads a custom shape file to the map.
            map.Area = ShapefileArea.Custom;
            CustomShapefileData data = new CustomShapefileData();

            data.ShapeData           = File.ReadAllBytes(@"..\..\Map\USA.shp");
            data.AttributeData       = File.ReadAllBytes(@"..\..\Map\USA.dbf");
            map.CustomShapefile.Data = data;

            dashboard.Items.Add(map);
            dashboardViewer.Dashboard = dashboard;
        }
Ejemplo n.º 4
0
        public Form1()
        {
            InitializeComponent();

            // Creates a new dashboard and a data source for this dashboard.
            Dashboard dashboard = new Dashboard();

            DashboardSqlDataSource dataSource = new DashboardSqlDataSource();
            CustomSqlQuery         sqlQuery   = new CustomSqlQuery("Countries", "select * from Countries");

            dataSource.ConnectionParameters = new Access97ConnectionParameters(@"..\..\Data\countriesDB.mdb", "", "");
            dataSource.Queries.Add(sqlQuery);

            // Creates a choropleth map dashboard item and specifies its data source.
            ChoroplethMapDashboardItem choroplethMap = new ChoroplethMapDashboardItem();

            choroplethMap.DataSource = dataSource;
            choroplethMap.DataMember = "Countries";

            // Loads the map of the world.
            choroplethMap.Area = ShapefileArea.WorldCountries;

            // Specifies a binding between the required map attribute and the data source field.
            choroplethMap.AttributeName      = "NAME";
            choroplethMap.AttributeDimension = new Dimension("Country");

            // Creates a ValueMap object with a measure that provides data for color map shapes.
            // Then, adds this object to the Maps collection of the choropleth map dashboard item.
            ValueMap populationMap = new ValueMap(new Measure("Population"));

            choroplethMap.Maps.Add(populationMap);

            // Adds the choropleth map dashboard item to the dashboard and opens this
            // dashboard in the Dashboard Viewer.
            dashboard.Items.Add(choroplethMap);
            dashboardViewer1.Dashboard = dashboard;
        }