Graphics

 View Only
  • 1.  Tie Bar Graph Color to Text Value (look for a specific variable)

    Posted 10-27-2015 21:03
    Hello again all. As the political season is creeping up, I am trying to integrate NewsTicker information to ROSS XPression Studio. For right now, I have them working together quite well and everything showing up as needed, I'm just missing what seems to be simple knowledge of how to make some of this magic work.

    So basically, what I have NewsTicker doing is showing the candidate name and to append the race of the candidate at the end of their last name (i.e. John Doe, R)

    I have a bar graph that takes the percentage of votes and will scale the bar vertically from 0% to 100%, depending on that value. But the bars are colored and need to scale to the appropriate race, so the red bar scales up with republicans, the blue bar scales up with democrats, etc.

    Is there a way to script what bar ties with which name, depending on what race is appended on the end of the name? Because right now, whichever candidate has the most votes is on top, and right now I have the top vote percentage tied with the red bar, the second one is ties with the blue bar, and the third is tied with a white bar, which, depending on which candidate has the most votes, needs to be visually accurate color-wise. Any tips? Do I need to be clearer? Everything right now is done through visual logic.


  • 2.  RE: Tie Bar Graph Color to Text Value (look for a specific variable)

    Posted 10-27-2015 21:06
    Or, what may be easier, is to change the color of the material these bars are, depending on what race they are. That may actually be the best option, if it's possible. To have it look for the appended initial, and maybe an "If, Else" statement, decide what material it has.

    #XPression


  • 3.  RE: Tie Bar Graph Color to Text Value (look for a specific variable)

    Posted 10-28-2015 14:58
    What we did is connect the bars with a specific candidate.



    The scene takes the percentage text from the candidate (our datalinq supplies just a number with no "%" sign), then uses that to determine the size of the bar. I was smart enough to make it 100 px wide if it was 100%, so the script running on the scene is:

    dim bar as xpBaseObject 'this is the scaling bar

    dim perc as xpTextObject 'this is the percentage text

    dim barnum as Integer 'this is the value that will determine how much to stretch it

    dim i as Integer 'because we do this over multiple bars for multiple candidates

    for i = 1 to 2

    Self.GetObjectByName("Bar " & i, bar) 'get the bar

    Self.GetObjectByName("Perc " & i, perc) 'get the percentage

    barnum=Cint(perc.Text) 'the integer value of the text for the script

    bar.ScaleX=(barnum/100) 'scale X of the bar based on the integer from the text

    next i


    Then, to change colors, I grab the text from the candidate's party (this is its own text object in our scene), and change the material of the bar if needed.

    dim bar as xpBaseObject 'this is the bar again

    dim party as xpTextObject 'the text object of the party

    dim rmat as xpMaterial 'the red material

    dim bmat as xpMaterial 'the blue material

    dim wmat as xpMaterial 'the white material

    Engine.GetMaterialByName("Red Material", rmat)

    Engine.GetMaterialByName("Blue Material", bmat)

    Engine.GetMaterialByName("White Material", wmat)

    for i = 1 to 2

    Self.GetObjectByName("Bar " & i, bar)

    Self.GetObjectByName("Party " & i, party)

    if InStr(party.Text, "R") = 1 then

    bar.SetMaterial(0, rmat)

    elseif InStr(party.Text, "D") = 1 then

    bar.SetMaterial(0, bmat)

    else

    bar.SetMaterial(0, wmat)

    end if

    next i


    #XPression