Search code examples
bar-chartspotfire

Spotfire, Barchart width, and setting display intervals on x-axis


enter image description here

If I click the x-axis, year, and go to custom expression, it says [Year] for the upper picture. Also, for the upper picture case, I cannot adjust the bar width.

But for some reason if I type <[Year]>, into the expression, it gives me this, and suddenly I can change the bar width to what I want it to be in Properties. enter image description here

I don't understand what is causing this difference.

I want to make my bar chart to be thicker like the bottom one, but I also want my x-axis to display years on 5-year interval like, 1995 - 2000 - 2005 - 2010... but I don't know how I can do it.

Please take into consideration that I don't have any basis with codes for custom expression. So if you were to answer to my question with codes for custom expression, please give me a full code that works.

I am experiencing a really big limitation with me not being able to manipulate custom expressions, but currently I don't have time to start learning it from the basics... I've tried to look it up, but lots of them were talking about binned columns, and I just don't understand.

enter image description here

scsimon

I cannot press ok. I am not sure if I am doing this right tho. Just to be clear, what I want is from the first screenshot, everything stays the same, but just by bar getting thicker. I so still want separate bars for each year, I just want the x-axis label to label on 5 year interval


Solution

  • Binning is used on the back end a lot of times naively and can be tricky to use in a custom expression. The bin function you want to use is BinBySpecificLimits() The first think to do is create a calculated column for your year if you haven't already.

    Year([DateColumn]) as [Year]

    Then use your Bin function.

    BinBySpecificLimits([Year],1994,2000,2005,2010,2015,2020)
    

    This is evaluated as bins where the bin is

    Bin <= 1994
    1994 < Bin <= 2000 
    2000 < Bin <= 2005
    etc...
    

    I can understand your urgency... but I would also strongly suggest you play with the custom expressions. They are very SQL like. Things only get harder :)