greater than or less than

398
2
05-01-2014 05:21 AM
LukeCzar
New Contributor III
Good morning,


I would like to use a Rule in which I use different color diagrams base on numbers, so If "something is greater than or less than"

How can I write that code?

For example:


[ATTACH=CONFIG]33525[/ATTACH]
Student hours:

219-1000    red color
1000-2000   yellow color
2000-4000   blue color


Lukasz
0 Kudos
2 Replies
LukeCzar
New Contributor III
I have a code:

case  StudentHours > 219  && StudentHours <1000   :
  set(material.color.a,0.8)color("#FF0000")
  extrude(StudentHours/160)

and it works,


what if I want to show different attributes in diagram? See attachment


Lukasz
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hi !


use functions instead, don't write that logic directly in the rules..


e.g.

getColor(value) =
    case value > 2000:
        ""#FF0000""
    case value > 1000:
        "#FF00FF"
    else:
        "#0000FF"



note that this works the same. I used different hex colors here though.

note that if the first case is not true, it goes to the next case, and so on,.. then returns the value.
0 Kudos