Monday, June 17, 2013

Color me Crazy

Every smart person loved my post on Highlighting the Trend. It's the sane alternative to a crazy line chart with a bunch of dumb, indistinguishable colors. Unfortunately, there are a few (communists, one-worlders, salespeople) who asked the question, "why aren't all of the lines different colors?"

Well, it got so that every piss-ant prairie punk who thought he could make a graph would ride into town to try out the Waco Kid. I must have charted more data than Cecil B. DeMille. It got pretty gritty. I started to hear the word "draw" in my sleep. Then one day, I was just walking down the street when I heard a voice behind me say, "Reach for it, mister!" I spun around... and there I was, face to face with a six-year old kid. Well, I just threw my data down and walked away. Little bastard shot me in the ass. So I limped to the nearest saloon, crawled inside a whiskey bottle... and I've been there ever since.


So, I give up. You can have your darn colors. I just refuse to not add a twist that might actually help make them useful. In the spirit of Highlighting the Trend, clicking on a value will grey out the remaining lines.





Step One - Line Chart

Create a line chart. Make sure that it's good and ugly with lots of colors.

Step Two - Inline Color Table

The first step is to define the colors of the values. We could use a big, nasty 'If' statement, but instead we'll use an inline table:

     [DealType Colors]:
     LOAD * INLINE [
         DealRegDealType, DT.r, DT.g, DT.b
         Ssuwd, 55, 102, 204
         CSYG, 204, 51, 51
         KNJ, 51, 204, 102
         MKU, 204, 204, 251
         UDB u/ Yockp UW, 51, 204, 204
         Inmio PEL, 204, 102, 204
     ];

All this is doing is defining the RGB values for each of the items of the field 'DealRegDealType'. The 'DT.' before the rgb makes it so we don't get circular references if there are multiple color maps. (DT = DealType) Reload your document.

Step Three - Expression Attributes

Click on the + next to your expression and enter the following in the editor:

     =If(Match(DealRegDealType,Concat(Distinct DealRegDealType,',')),
          ARGB(255,DT.r,DT.g,DT.b),
          ARGB(100,192,192,192))

The details:
  • The first line matches the concatenated selections in DealRegDealType to the field
  • If it matches, then it uses the colors from the color map defined in your inline table
  • If not, make it grey

FINAL WARNING!

You still need to choose your colors wisely. Watch the video below and you'll see that I didn't! I chose lazily. Don't forget to turn up your speakers!


So don't do me like that.

Update: From swuel on the forums, use something similar in the background color:
if(GetSelectedCount(Benefit),
if(match(only({1}Benefit),$(=chr(39)&concat(Benefit,chr(39)&','&chr(39))&chr(39))),
color(Rowno()),lightgray()),
color(RowNo()))

No comments:

Post a Comment