0

Crystal Reports 2008を使用したクロスタブを除いて、Excelの「カラースケール」機能と同様の簡略化された結果、つまり最小値(赤)から最大値(緑)に基づくグラデーションカラーリングを実現したいと思います。クロスタブは次のようになります。このような少し:

 HOURS    L1   L2  L3   L4  Total
 1 hours | 5 | 0 | 1 | 16 | 22 |
 2 hours | 0 | 1 | 0 | 10 | 11 |
 3 hours | 8 | 2 | 6 | 12 | 28 |
 TOTAL   |13 | 3 | 7 | 38 | 61 |

私の関数の原理は、クロステーブルで最大値を見つけ、20%、40%、60%、80%の値を使用して背景を着色することです。機能は次のとおりです(形式>背景セクション):

    if currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.2) then color(255,0,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.2) and 
        currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.4)) then color(255,192,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.4) and 
        currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.6)) then color(255,255,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.6) and 
        currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.8)) then color(146,208,80)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.8)) then color(0,176,80)

それはエレガントではなく、適切に機能しません。どんな援助/提案も大歓迎です。「CurrentFieldValue」がフィールドではないことを教えてくれることを除いて、元々は機能すると仮定して以下で作業していたほど複雑になるとは思っていませんでした。

if CurrentFieldValue < ((Maximum (CurrentFieldValue))*0.2) then color(255,0,0)
else if ... etc.
4

1 に答える 1

0

この投稿の助けを借りて:クロス集計列ごとに、最大値を強調表示して、希望する結果を得ることができました。これが他の誰かに役立つことを願っています。乾杯。

local Numbervar max:=0;
local Numbervar col;
local Numbervar row;

for col := 0 to GetNumColumns-2 do 
(
    for row := 0 to GetNumRows-2 do 
    (
        local numbervar value := GridValueAt (row, col, CurrentSummaryIndex);
        if value > max 
            then max := value;
    );
);

ToText(max,"#");

// Reference Red 248,105,107
// ReferenceGreen 99,190,132

local Numbervar cRed;
local Numbervar cGreen;
local Numbervar cBlue;

cRed := Floor(99 + 149 * (1-(GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0)/max)));

cGreen := Floor(105 + 85 * (if (((GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0)/max))*10) > 1 then 1));

cBlue := Floor(107 + 25 * ((GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0)/max)));

color(cRed, cGreen, cBlue)
于 2012-10-08T15:35:16.463 に答える