Splunk Search

How to enable users to select from a set of chart types on a panel?

zeinstein
Path Finder

Expected result: I have a panel displaying a line chart, the user can access (without the "Edit" option) the pre-set chart type selection (e.g. a dropdown list, as it is in the Edit mode, containing Bar Chart, Line Chart, Area Chart) and the panel's visualization can be set accordingly.
Is there a way to do this, other than creating all the choices and hide/show them according to the user's choice? (Like it was suggested in the answer for "How to create a radio button for chart type?").

0 Karma
1 Solution

rjthibod
Champion

You can use a dropdown or radio button to set the chart type, and then use the token $chart_typ$ in the options for the chart.

<input searchWhenChanged="true" token="chart_type" type="dropdown">
  <label>Select Chart Type</label>
  <choice value="line">Line</choice>
  <choice value="column">Column</choice>
  <choice value="area">Area</choice> 
  <default>line</default>
  <showClearButton>false</showClearButton>
</input>
....

<chart>
  <option name="charting.chart">$chart_type$</option>
</chart>

View solution in original post

rjthibod
Champion

You can use a dropdown or radio button to set the chart type, and then use the token $chart_typ$ in the options for the chart.

<input searchWhenChanged="true" token="chart_type" type="dropdown">
  <label>Select Chart Type</label>
  <choice value="line">Line</choice>
  <choice value="column">Column</choice>
  <choice value="area">Area</choice> 
  <default>line</default>
  <showClearButton>false</showClearButton>
</input>
....

<chart>
  <option name="charting.chart">$chart_type$</option>
</chart>

zeinstein
Path Finder

Thank you! Yes, this is the safest solution I could come up with, as well. My only sadness is that it doesn't show the little icons of the chart types for the users.
Anyhow, I really appreciate your answer!

0 Karma

aaraneta_splunk
Splunk Employee
Splunk Employee

Hi @zeinstein - Did the answer provided by rjthibod help provide a working solution to your question? If yes, please don't forget to resolve this post by clicking "Accept". If no, please leave a comment with more feedback. Thanks!

0 Karma

rjthibod
Champion

Those chart icons are custom menus from Splunk. You have to replicate that and/or create your own, and would likely be a maintenance/support nightmare to maintain.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...