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 Form1() { InitializeComponent(); Dashboard dashboard = new Dashboard(); dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml"); dashboardViewer1.Dashboard = dashboard; GridDashboardItem grid = (GridDashboardItem)dashboard.Items["gridDashboardItem1"]; GridDimensionColumn salesPerson = (GridDimensionColumn)grid.Columns[0]; GridMeasureColumn extendedPrice = (GridMeasureColumn)grid.Columns[1]; GridItemFormatRule topRule = new GridItemFormatRule(extendedPrice, salesPerson); FormatConditionTopBottom topCondition = new FormatConditionTopBottom(); topCondition.TopBottom = DashboardFormatConditionTopBottomType.Top; topCondition.RankType = DashboardFormatConditionValueType.Number; topCondition.Rank = 3; topCondition.StyleSettings = new IconSettings(FormatConditionIconType.IndicatorGreenCheck); topRule.Condition = topCondition; GridItemFormatRule bottomRule = new GridItemFormatRule(extendedPrice, salesPerson); FormatConditionTopBottom bottomCondition = new FormatConditionTopBottom(); bottomCondition.TopBottom = DashboardFormatConditionTopBottomType.Bottom; bottomCondition.RankType = DashboardFormatConditionValueType.Percent; bottomCondition.Rank = 40; bottomCondition.StyleSettings = new IconSettings(FormatConditionIconType.IndicatorRedFlag); bottomRule.Condition = bottomCondition; GridItemFormatRule aboveAverageRule = new GridItemFormatRule(extendedPrice); FormatConditionAverage aboveAverageCondition = new FormatConditionAverage(); aboveAverageCondition.AverageType = DashboardFormatConditionAboveBelowType.Above; aboveAverageCondition.StyleSettings = new AppearanceSettings(Color.Green, FontStyle.Underline); aboveAverageRule.Condition = aboveAverageCondition; GridItemFormatRule belowAverageRule = new GridItemFormatRule(extendedPrice); FormatConditionAverage belowAverageCondition = new FormatConditionAverage(); belowAverageCondition.AverageType = DashboardFormatConditionAboveBelowType.Below; belowAverageCondition.StyleSettings = new AppearanceSettings(Color.Orange, FontStyle.Underline); belowAverageRule.Condition = belowAverageCondition; grid.FormatRules.AddRange(topRule, bottomRule, aboveAverageRule, belowAverageRule); }