2016-06-22 6 views
1

Software: MS Visual Studio Shell 2013SSRS 2013 Heat Map

Ich arbeite derzeit an einer Matrix Heatmap für einen SSRS-Bericht, den ich versuche zu veröffentlichen.

Das Textfeld, auf das ich den Hintergrund anwenden möchte, wird in einer Zeile und einer Spalte gruppiert. Es hat eine Zählfunktion, um den Wert dieser Zelle zu bestimmen.

Bericht-Code Ich verwende ist:

public const ColorScaleRed = "#FF0000" 
public const ColorScalePink= "#ff6666" 

public function ColorScaleWPR(value, minValue, maxValue) as string 

    ColorScaleWPR = ColorScale3(value, _ 
     minValue, "White", _ 
     ColorScalePink, _ 
     maxValue, ColorScaleRed) 

end function 

public function ColorScale3(value as object, minValue as object, minColor as string, midColor as string, maxValue as object, maxColor as string) as string 

    ' Use average of minValue and maxValue as midValue 
    dim midValue as object 
    if IsNumeric(minValue) and IsNumeric(maxValue) then 
     midValue = (CDbl(minValue) + CDbl(maxValue))/2 
    end if 

    ColorScale3 = ColorScale3(value, _ 
     minValue, minColor, _ 
     midValue, midColor, _ 
     maxValue, maxColor) 

end function 

public function ColorScale3(value as object, minValue as object, minColor as string, midValue as object, midColor as string, maxValue as object, maxColor as string) as string 

    if IsNumeric(value) and IsNumeric(midValue) and CDbl(value) < CDbl(midValue) then 
     ColorScale3 = ColorScale(value, minValue, minColor, midValue, midColor) 
    else 
     ColorScale3 = ColorScale(value, midValue, midColor, maxValue, maxColor) 
    end if 

end function 

public function ColorScale(value as object, minValue as object, minColor as string, maxValue as object, maxColor as string, optional errorColor as string = "Transparent") as string 

    ColorScale = errorColor 

    if not IsNumeric(value) or not IsNumeric(minValue) or not IsNumeric(maxValue) then 
     exit function 
    end if 

    ' Do all calculations using doubles (can't mix doubles and decimals) 
    value = CDbl(value) 
    minValue = CDbl(minValue) 
    maxValue = CDbl(maxValue) 

    if minValue >= maxValue then 
     exit function 
    end if 

    if value <= minValue then 
     ColorScale = minColor 
     exit function 
    end if 
    if value >= maxValue then 
     ColorScale = maxColor 
     exit function 
    end if 

    dim scaleValue, r, g, b as double 
    dim minRGB, minR, minG, minB as integer 
    dim maxRGB, maxR, maxG, maxB as integer 

    scaleValue = (value - minValue)/(maxValue - minValue) 

    minRGB = GetRGB(minColor) 
    minR = minRGB/2^16 
    minG = (minRGB mod 2^16)/2^8 
    minB = minRGB mod 2^8 

    maxRGB = GetRGB(maxColor) 
    maxR = maxRGB/2^16 
    maxG = (maxRGB mod 2^16)/2^8 
    maxB = maxRGB mod 2^8 

    r = minR + ((maxR - minR) * scaleValue) 
    g = minG + ((maxG - minG) * scaleValue) 
    b = minB + ((maxB - minB) * scaleValue) 

    ColorScale = string.Format("#{0:X2}{1:X2}{2:X2}", _ 
     CInt(Math.Floor(r)), _ 
     CInt(Math.Floor(g)), _ 
     CInt(Math.Floor(b))) 

end function 

private function GetRGB(colorStr as string) as integer 

    GetRGB = 0 

    if colorStr.StartsWith("#") then 
     GetRGB = Int32.Parse(colorStr.Substring(1), System.Globalization.NumberStyles.AllowHexSpecifier) 
     exit function 
    end if 

    dim c as System.Drawing.Color 
    c = System.Drawing.Color.FromName(colorStr) 

    GetRGB = (c.R * 2^16) + (c.G * 2^8) + c.B 

end function 

Mein Problem ist, wenn ich den Ausdruck Hintergrund.

Ich bin der Lage, die Heatmap zu bekommen richtig mit dem folgenden Ausdruck zu machen:

=Code.ColorScaleWPR(Count(Fields!Candidate_ID.Value),0,10) 

aber ich möchte nicht, statische Werte für die Min- und Max-Werte verwenden. Ich möchte, dass sie dynamisch sind, da diese Min- und Max-Werte abhängig von den gewählten Parametern stark variieren können.

So habe ich den folgenden Code

=Code.ColorScaleWPR(Count(Fields!Candidate_ID.Value), Min(Fields!Candidate_ID.Value,"DataSet1"), Max(Fields!Candidate_ID.Value,"DataSet1")) 

Als ich den Bericht ausgeführt wird, auf die Zellen aufgebracht komplett weiß und keiner der Konditionierung macht.

Alle Vorschläge, um es dynamisch zu machen, wäre genial. Danke!

Antwort

0

Ich denke nicht, dass RS in der Lage ist, alle Gruppierungen im Voraus zu berechnen und dann Min/Max von ihnen zu finden, um die Farbskala anzuwenden. Der beste Ansatz zum Testen besteht darin, Min- und Max-Werte für jede Gruppe in separaten Datasets aus der ursprünglichen Dataset-Abfrage zu berechnen. Ziehen Sie dann die benötigten Werte basierend auf übereinstimmenden Gruppenkriterien mithilfe von Ausdruck. Ich würde diese Richtung gehen ... PS. Ich hatte nicht genug Zeit, um dieses Tier für meinen Fall lebendig zu machen, wenn ich Farbskala auf geschwenkten Matrixgruppierungen verwende :)