public Form1() { InitializeComponent(); Dashboard dashboard = new Dashboard(); dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml"); PivotDashboardItem pivot = (PivotDashboardItem)dashboard.Items["pivotDashboardItem1"]; PivotItemFormatRule firstLevelRule = new PivotItemFormatRule(pivot.Values[0]); FormatConditionValue greaterThanCondition = new FormatConditionValue(); greaterThanCondition.Condition = DashboardFormatCondition.Greater; greaterThanCondition.Value1 = 30000; greaterThanCondition.StyleSettings = new AppearanceSettings(FormatConditionAppearanceType.Green); firstLevelRule.Condition = greaterThanCondition; firstLevelRule.IntersectionLevelMode = FormatConditionIntersectionLevelMode.FirstLevel; PivotItemFormatRule lastLevelRule = new PivotItemFormatRule(pivot.Values[0]); FormatConditionRangeGradient rangeCondition = new FormatConditionRangeGradient(FormatConditionRangeGradientPredefinedType.WhiteGreen); lastLevelRule.Condition = rangeCondition; lastLevelRule.IntersectionLevelMode = FormatConditionIntersectionLevelMode.LastLevel; PivotItemFormatRule grandTotalRule = new PivotItemFormatRule(pivot.Values[0]); FormatConditionRangeSet rangeTotalCondition = new FormatConditionRangeSet(FormatConditionRangeSetPredefinedType.ColorsPaleRedGreenBlue); grandTotalRule.Condition = rangeTotalCondition; grandTotalRule.IntersectionLevelMode = FormatConditionIntersectionLevelMode.SpecificLevel; grandTotalRule.Level.Row = pivot.Rows[0]; PivotItemFormatRule topCategoryRule = new PivotItemFormatRule(pivot.Values[0]); FormatConditionTopBottom topCondition = new FormatConditionTopBottom(); topCondition.TopBottom = DashboardFormatConditionTopBottomType.Top; topCondition.RankType = DashboardFormatConditionValueType.Number; topCondition.Rank = 3; topCondition.StyleSettings = new IconSettings(FormatConditionIconType.RatingFullGrayStar); topCategoryRule.Condition = topCondition; topCategoryRule.IntersectionLevelMode = FormatConditionIntersectionLevelMode.SpecificLevel; topCategoryRule.Level.Row = pivot.Rows[0]; topCategoryRule.DataItemApplyTo = pivot.Rows[0]; pivot.FormatRules.AddRange(firstLevelRule, lastLevelRule, grandTotalRule, topCategoryRule); dashboardViewer1.Dashboard = dashboard; }
public void AddFormatRulesToLineSeries(ChartDashboardItem chart) { SimpleSeries series = chart.Panes[0].Series[0] as SimpleSeries; ChartItemFormatRule valueRule1 = new ChartItemFormatRule(series.Value, series); FormatConditionValue valueCondition1 = new FormatConditionValue(DashboardFormatCondition.Greater, 3000); valueCondition1.StyleSettings = new ColorStyleSettings(Color.Green); valueRule1.Condition = valueCondition1; valueRule1.ShowInLegend = true; valueRule1.DisplayName = "UnitPrice is greater than $3K"; chart.FormatRules.Add(valueRule1); ChartItemFormatRule valueRule2 = new ChartItemFormatRule(series.Value, series); FormatConditionValue valueCondition2 = new FormatConditionValue(DashboardFormatCondition.Less, 3000); valueCondition2.StyleSettings = new ColorStyleSettings(Color.Red); valueRule2.Condition = valueCondition2; valueRule2.ShowInLegend = true; valueRule2.DisplayName = "UnitPrice is less than $3K"; chart.FormatRules.Add(valueRule2); }
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]; GridItemFormatRule lessThanRule = new GridItemFormatRule(extendedPrice); FormatConditionValue lessThanCondition = new FormatConditionValue(); lessThanCondition.Condition = DashboardFormatCondition.LessOrEqual; lessThanCondition.Value1 = 100000; lessThanCondition.StyleSettings = new AppearanceSettings(FormatConditionAppearanceType.FontRed); lessThanRule.Condition = lessThanCondition; GridItemFormatRule betweenRule = new GridItemFormatRule(extendedPrice); FormatConditionValue betweenCondition = new FormatConditionValue(); betweenCondition.Condition = DashboardFormatCondition.Between; betweenCondition.Value1 = 100000; betweenCondition.Value2 = 200000; betweenCondition.StyleSettings = new AppearanceSettings(FormatConditionAppearanceType.FontYellow); betweenRule.Condition = betweenCondition; GridItemFormatRule greaterThanRule = new GridItemFormatRule(extendedPrice); FormatConditionValue greaterThanCondition = new FormatConditionValue(); greaterThanCondition.Condition = DashboardFormatCondition.GreaterOrEqual; greaterThanCondition.Value1 = 200000; greaterThanCondition.StyleSettings = new AppearanceSettings(FormatConditionAppearanceType.FontGreen); greaterThanRule.Condition = greaterThanCondition; grid.FormatRules.AddRange(lessThanRule, betweenRule, greaterThanRule); }