Created
August 9, 2018 14:03
-
-
Save dmitriysolovev/cfef1c4ba07e8e0eb3a408ae216ec505 to your computer and use it in GitHub Desktop.
SVG_KPI_2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KPI_3_position = | |
//Укажите меру. на основании которой будет определяться цвет | |
VAR SourceMeasure = [%Total_with_Tax_PY_Var] //Здесь можно изменить цвета индикатора. | |
// Можно указывать как HEX-коды. | |
// так и названия цветов на английском - red. yerllow. green и т.тд. | |
VAR Color = | |
SWITCH ( | |
TRUE (); | |
SourceMeasure < 0; "#cc3232"; | |
SourceMeasure < 0,25; "#e7b416"; | |
"#99c140" | |
) | |
VAR Size = 30 // определяет размер SVG изображения в пикселях | |
//Формируем SVG -изображение | |
VAR Circle = "<circle cx='" & Size / 2 & "' cy='" & Size / 2 & "' r='" & Size / 2 & "' fill='" & Color & "' stroke='none' stroke-width='3'/>" | |
VAR Rect = "<rect width='" & Size & "' height='" & Size & "' fill='" & Color & "' />" VAR Triangle = "<polygon points='0,0 "&Size/2&","&Size&","&Size&",0' fill='" & Color & "'/>" | |
VAR Shape_ = | |
SWITCH ( | |
TRUE (); | |
SourceMeasure < 0; Triangle; | |
SourceMeasure < 0,25; Rect; | |
Circle | |
) //Задаем логику выбора изображения в зависимости от состояния показателя | |
VAR Output = "data:image/svg+xml;utf8," & "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='" & Size & "' height='" & Size & "'>" & Shape_ & "</svg>" | |
RETURN | |
/*Логику HASONEVALUE стоит подкорректировать в случае. | |
если планируется использовать матрицу с промежуточными итогами. | |
Внутри HASONEVALUE должен присутсвовать столбец. | |
который находится на нижнем уровне иерархии. | |
В противном случае вместо кружка в подитогах будет отображаться код SVG элемента*/ | |
IF ( | |
HASONEVALUE ( 'Cities'[City] ) | |
&& SourceMeasure <> BLANK (); | |
Output; | |
BLANK () | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment