Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

colorizing values in a crosstab

edited April 2002 in General
Hi,

Reportbuilder Enterprise 6.03, Delphi 5

I have a single query that I am using to display readings in a crosstab.
Each record has three readings, and these readings are evaluated according
to criteria specific to that record that is not included in the crosstab.
Depending on the reading value, it is compared to three different ranges and
colorized accordingly. As I said, this evaluation criteria can change with
every set of readings.

This doesn't work properly, because all the readings are colorized using the
last record in the dataset. Is what I require even possible?

Any suggestions are greatly appreciated.

My code (using RAP) looks something like this:

procedure CrossTab1OnCalcDimensionValue(aDimension: TppDimension; var aValue
: Variant);
var
col : TColor;
sCol : String;
begin
if aValue <= lGenQry['CHANGEOUT'] then
sCol :=lGenQry['CHANGEOUTCOLOR']
else
if (aValue > lGenQry['CHANGEOUT']) and (aValue <=
lGenQry['NEXTSDCHANGE']) then
sCol := lGenQry['NEXTSDCHANGECOLOR']
else
if (aValue > lGenQry['NEXTSDCHANGE']) and (aValue <=
lGenQry['NEXTSDALARM']) then
sCol := lGenQry['NEXTSDALARMCOLOR']
else
if aValue >= lGenQry['NEXTSDALARM'] then
sCol := lGenQry['ACCEPTABLECOLOR'];
sCol := lowercase(sCol);
if sCol = 'blue' then col := clblue else
if sCol = 'green' then col := clgreen else
if sCol = 'red' then col := clred else
if sCol = 'aqua' then col := claqua else
if sCol = 'yellow' then col := clyellow else
if sCol = 'black' then col := clblack else
if sCol = 'olive' then col := clolive else
if sCol = 'fuchsia' then col := clfuchsia else
if sCol = 'maroon' then col := clmaroon else
if sCol = 'navy' then col := clnavy else
if sCol = 'white' then col := clBlack else
if sCol = 'lime' then col := cllime else
if sCol = 'dkgray' then col := cldkgray else
if sCol = 'gray' then col := clgray else
if sCol = 'ltgray' then col := clltgray else
if sCol = 'purple' then col := clpurple else
if sCol = 'silver' then col := clsilver else
if sCol = 'teal' then col := clteal;

aElement.font.color := col;
end

Comments

  • edited April 2002
    Set the color in the FormatCell event rather than in CalcDimensionValue.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    How do I check the value of the cell?

    Thanks,

    Leah

    "Alexander Kramnik (Digital Metaphors)" wrote
    in message news:3ccd6546$1@dm500....
  • edited May 2002
    You first need to check if the cell element is a calculated field rather
    than a caption. Then you can access the crosstab matrix to get the value.
    For example:

    procedure TForm1.ppCrossTab1FormatCell(Sender: TObject; aElement:
    TppElement; aColumn, aRow: Integer);
    begin

    if (aElement is TppValueDef) then
    begin
    ...
    myValue := ppCrossTab1.Matrix.Value[aColumn, aRow];
    ...
    end;

    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.