void AddDataBarFormatCondition() {
     DataBarFormatCondition condition = new DataBarFormatCondition();
     condition.FieldName = "Total";
     //condition.PredefinedFormatName = "LightBlueSolidDataBar";
     condition.PredefinedFormatName = "LightBlueGradientDataBar";
     formats.Add("Totals Data Bars", condition);
 }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();

            FilterFieldValues(fieldYear, new int[] { 2016 }, FieldFilterType.Included);

            // Creates a new DataBarFormatCondition instance.
            DataBarFormatCondition formatRulesDataBar = new DataBarFormatCondition();

            // Adds this instance to the FormatConditionCollection.
            pivotGridControl1.AddFormatCondition(formatRulesDataBar);

            // Specifies a column field.
            formatRulesDataBar.ColumnName = "fieldQuarter";

            // Specifies a row field.
            formatRulesDataBar.RowName = "fieldSalesPerson";

            // Specifies a data field.
            formatRulesDataBar.MeasureName = "fieldExtendedPrice";

            // Applies the condition to intersection of row and column fields.
            formatRulesDataBar.ApplyToSpecificLevel = true;

            // Sets the predefined format.
            formatRulesDataBar.PredefinedFormatName = "OrangeGradientDataBar";
        }
Beispiel #3
0
        void AddDataBarFormatCondition()
        {
            DataBarFormatCondition condition = new DataBarFormatCondition();

            condition.FieldName            = "Total";
            condition.PredefinedFormatName = "LightBlueGradientDataBar";
            formats.Add("Totals Data Bars", condition);
        }
        private void CollectionModify(StyleOption styleOption)
        {
            if (styleOption == null)
            {
                return;
            }

            FormatConditionBase formatCondition = null;

            Func <TopBottomRule, FormatConditionBase> createTopBottomRuleFormatConditionHandler = rule =>
            {
                var result = new TopBottomRuleFormatCondition();
                var format = CreateFormat(styleOption);
                if (format != null)
                {
                    result.Format = format;
                }

                result.Rule      = rule;
                result.Threshold = styleOption.Threshold;


                if (styleOption.ApplyToRow)
                {
                    result.Expression = string.Format("[{0}]", styleOption.FieldName);
                }
                else
                {
                    result.FieldName = styleOption.FieldName;
                }

                return(result);
            };

            Action <FormatConditionBase> setAnimatedFormatConditionHandler = fc =>
            {
                formatCondition                      = fc;
                formatCondition.FieldName            = styleOption.FieldName;
                formatCondition.PredefinedFormatName = styleOption.PredefinedFormatName;
            };

            switch (styleOption.FormatConditionType)
            {
            case FormatConditionType.Default:
                var condition = new FormatCondition();
                var format    = CreateFormat(styleOption);
                if (format != null)
                {
                    condition.Format = format;
                }

                formatCondition            = condition;
                formatCondition.FieldName  = styleOption.ApplyToRow ? null : styleOption.FieldName;
                formatCondition.Expression = styleOption.ExpressionString;
                break;

            case FormatConditionType.TopItemsRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.TopItems);
                break;

            case FormatConditionType.TopPersentRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.TopPercent);
                break;

            case FormatConditionType.BottomItemsRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.BottomItems);
                break;

            case FormatConditionType.BottomPercentRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.BottomPercent);
                break;

            case FormatConditionType.AboveAverageRule:
                //Не работает
                styleOption.ApplyToRow = false;
                formatCondition        = createTopBottomRuleFormatConditionHandler(TopBottomRule.AboveAverage);
                break;

            case FormatConditionType.BelowAverageRule:
                //Не работает
                styleOption.ApplyToRow = false;
                formatCondition        = createTopBottomRuleFormatConditionHandler(TopBottomRule.BelowAverage);
                break;

            case FormatConditionType.DataBar:
                var dataBarCondition = new DataBarFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(dataBarCondition);
                break;

            case FormatConditionType.ColorScale:
                var colorScaleCondition = new ColorScaleFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(colorScaleCondition);
                break;

            case FormatConditionType.IconSet:
                var iconSetCondition = new IconSetFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(iconSetCondition);
                break;

            default:
                throw new DeveloperException("Undefined FormatConditionType '{0}'.", styleOption.FormatConditionType);
            }

            if (formatCondition != null)
            {
                View.AddFormatCondition(formatCondition);
            }
        }