Search code examples
menulinechartspotfire

Tibco SpotFire - Line chart data columns linked to itemized selection list


I'm new to Tibco SpotFire, so please forgive any mistakes in terminology, etc.

I have a line chart with two columns from the data table selected to be shown on the y-axis. I would like to make an itemized menu where you can select one item at a time, such that which two data columns are shown on the y-axis is a function of which item in the itemized menu is chosen.

For example, let's say my data table column names are Col_1, Col_2, Col_3, Col_4, Col_5, and Col_6. I want to make an itemized selection menu with items A, B, and C, such that...

  • If A is selected, Col_1 and Col_2 are the data columns used by the y-axis.
  • If B is selected, Col_3 and Col_4 are the data columns used by the y-axis.
  • If C is selected, Col_5 and Col_6 are the data columns used by the y-axis.

How can I accomplish this? Currently, I know neither how to make an itemized selection menu at all, nor how to link the y-axis data columns to it.

Thanks for any help.

P.S. I'm betting there is a technical name for what I'm calling an "itemized selection menu" above. If someone knows what it is, please let me know and I will edit this post accordingly.


Solution

  • You'll need a text box and a line chart. In the text box, add a Property Control (Drop-down list). You'll want to create a new document property that looks something like this: enter image description here

    After that, you'll need to tie in the Document Property to your plot. Some code like the following should achieve what you are looking for:

    case  when DocumentProperty("Selector")="Col1Col2" then Sum([X]) 
            when DocumentProperty("Selector")="Col3Col4" then Sum([Y]) 
            when DocumentProperty("Selector")="Col5Col6" then Sum([Z])
    end, 
    case  when DocumentProperty("Selector")="Col1Col2" then Sum([XX]) 
            when DocumentProperty("Selector")="Col3Col4" then Sum([YY]) 
            when DocumentProperty("Selector")="Col5Col6" then Sum([ZZ])
    end
    

    Where column [X] and [XX] would be tied to "Col1Col2" and so on. Now, selecting "A" from the drop down in the text box will plot [X] and [XX] on your plot.