Dashboards & Visualizations
Highlighted

In a dashboard panel, how do I make a conditional title based on a token value?

New Member

Hello!

I have a chart that shows data based on a variable $sourcetype_tok$. The values of the dropdown list are as follows:

  1. A list of categories from a query
  2. A static one that has the name all and the value * that should represent all the categories combined

However, the chart's title should depend on the selected category. Until now, I have this:

<title>
    Top 10: $sourcetype_tok$ domains
</title>

If the selected category is A, it works.

However, if I select the value all, the title will be Top 10: * domains and I want it to be customizable. Is there a way I can insert fields such as <title> conditionally? Or can I do something so the title would depend on the value of a token?

Thanks!

0 Karma
Highlighted

Re: In a dashboard panel, how do I make a conditional title based on a token value?

Champion

Simple. Add a change event to your input like this:

<input type="dropdown" token="sourcetype_tok">
  <...>
  <change>
    <condition value="*">
      <set token="display_domain_names">Unfiltered</set>
    </condition>
    <condition value="*">
      <set token="display_domain_names">$value$</set>
    </condition>
  </change>
</input>

This should make your input set a second token display_domain_names which contains the text "Unfiltered" if the user selects the "all" option or the selected value if another one is selected. Use this token in your title. If label and value are different in the dropdown and label is nicer, you also have $label$ available. Docs here.

View solution in original post

0 Karma
Highlighted

Re: In a dashboard panel, how do I make a conditional title based on a token value?

New Member

Exactly what I needed!
Thanks!

0 Karma