Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            Dashboard dashboard = new Dashboard(); dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            dashboardViewer1.Dashboard = dashboard;
            GridDashboardItem grid          = (GridDashboardItem)dashboard.Items["gridDashboardItem1"];
            GridMeasureColumn extendedPrice = (GridMeasureColumn)grid.Columns[1];

            extendedPrice.Measure.UniqueId = "extendedPrice";

            DashboardParameter priceParameter = new DashboardParameter();

            priceParameter.LookUpSettings = null;
            priceParameter.Name           = "priceParameter";
            priceParameter.Type           = typeof(decimal);
            priceParameter.Value          = 150000;
            priceParameter.Description    = "Format values that are greater than";
            dashboard.Parameters.Add(priceParameter);

            GridItemFormatRule        greaterThanRule      = new GridItemFormatRule(extendedPrice);
            FormatConditionExpression greaterThanCondition = new FormatConditionExpression();

            greaterThanCondition.Expression    = "extendedPrice > [Parameters.priceParameter]";
            greaterThanCondition.StyleSettings =
                new AppearanceSettings(FormatConditionAppearanceType.PaleGreen);
            greaterThanRule.ApplyToRow = true;
            greaterThanRule.Condition  = greaterThanCondition;

            grid.FormatRules.AddRange(greaterThanRule);
        }
        public void AddFormatRulesToScatterChart(ScatterChartDashboardItem scatterChart)
        {
            double unitCountThreshold = 7000;
            double discountThreshold  = 18;
            ScatterChartItemFormatRule expressionRule1 = new ScatterChartItemFormatRule();

            expressionRule1.DataItem = scatterChart.AxisYMeasure;
            FormatConditionExpression formatCondition = new FormatConditionExpression();

            formatCondition.Expression    = $"{scatterChart.AxisYMeasure.UniqueId} > {unitCountThreshold} && {scatterChart.AxisXMeasure.UniqueId} > {discountThreshold}";
            formatCondition.StyleSettings = new ColorStyleSettings(ColorTranslator.FromHtml("#14abb7"));
            expressionRule1.Condition     = formatCondition;
            expressionRule1.ShowInLegend  = true;
            expressionRule1.DisplayName   = "Discount amount from the quantity of products sold";
            scatterChart.FormatRules.Add(expressionRule1);
            ScatterChartConstantLineUserData moduleData = new ScatterChartConstantLineUserData()
            {
                Enabled = true, VerticalAxisValue = discountThreshold, HorizontalAxisValue = unitCountThreshold
            };

            scatterChart.CustomProperties.SetValue(ScatterChartConstantLineUserValueModule.PropertyName, moduleData.GetStringFromData());
        }