Cross-tab - highligthing max value

Stimulsoft Reports.NET discussion
Post Reply
Dmitry
Posts: 15
Joined: Mon Apr 28, 2014 12:54 pm

Cross-tab - highligthing max value

Post by Dmitry »

Is it possible to highlight max value in each column of cross-tab report?
So, only cell with Max value must be highlight in whole column.

BTW, I do need to calc totals for cross-tab, but not as "Sum" of each value in a column, but as "Max" value.
Unfortunately, I don't see built-in functionality for such a requirement.
I coped with it by this link
http://support.stimulsoft.com/index.php ... -cross-tab
But it seems to me, it would be better, if this functionality is built-in
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Cross-tab - highligthing max value

Post by Alex K. »

Hello,

Please checkthe sample report in teh attachment.

http://forumru.stimulsoft.com/viewtopic.php?f=8&t=3619

Thanky ou.
Attachments
StandardCrossTabPercentByColumn.mrt
(29.93 KiB) Downloaded 381 times
Dmitry
Posts: 15
Joined: Mon Apr 28, 2014 12:54 pm

Re: Cross-tab - highligthing max value

Post by Dmitry »

Thank you for for suggestion, resulting code looks like:

Code: Select all

using System.Collections.Generic;

      private Dictionary<int, decimal> _maximums = new Dictionary<int, decimal>();

		private void AddValue(int row, decimal valueToAdd) {
			if (_maximums.ContainsKey(row)) {
				var existingValue = _maximums[row];
				if (existingValue < valueToAdd) {
					_maximums[row] = valueToAdd;
				}
			} else {
				_maximums.Add(row, valueToAdd);
			}
		}
		
		bool IsMaxValue(int colNum, decimal val)
		{
			if (_maximums.ContainsKey(colNum))
			{
				return val == _maximums[colNum];
			}
			return false;
		}
		

        public void CrossTab1_Sum1_ProcessCell(object sender, Stimulsoft.Report.CrossTab.StiProcessCellEventArgs e)
        {
            if (IsFirstPass)
            {
                AddValue(e.Column, e.Value);
            }
            else
            {
                if (IsMaxValue(e.Column, e.Value))
                {
                    Stimulsoft.Report.Components.StiConditionHelper.ApplyFont(sender,
                        new System.Drawing.Font("Arial", 8.75F, System.Drawing.FontStyle.Bold,  System.Drawing.GraphicsUnit.Point, 204),
                                                                              Stimulsoft.Report.Components .StiConditionPermissions.All);
                }
            }
        }
Also you have to change report processing to double pass.
I don't see the way to accomplish this in 1-pass
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Cross-tab - highligthing max value

Post by Alex K. »

Hello,

Thank you for the information.
Let us know if you need any additional help.

Thank you.
Post Reply