Dashboards & Visualizations

Parse the pan+zoom selection $start$ and $end$ tokens in non-timechart charts

arkadyz1
Builder

We've used <selection> tag quite successfully for our timecharts. The regular

<selection>
  <set token="slider.start">$start$</set>
  <set token="slider.end">$end$</set>
</selection>

addition to a timechart populates the slider.start and slider.end tokens quite fine each time a user makes a selection or pans it. They get the starting and ending epoch times, respectively.

However, the same approach fails miserably for non-time charts. If, say, a span of some column is 965 to 970 of independent variable, and that column happens to become the first one in the selection, we'll get "965-970" inside the $slider.start$ token.

How can we set the token properly - extracting that 965 from it? This panel is going to be exported to HTML at some point, but is there an easier way for now? We still have a lot of development ahead of us.

Tags (4)
0 Karma
1 Solution

arkadyz1
Builder

Well - we finally got some time to look closer into it, and found some way which is not documented for the <selection> tag but is used elsewhere: <eval> tag.

The code looks like this:

<selection>
          <eval token="histogram.start">mvindex(split('start',"-"),0)</eval>
          <eval token="histogram.end">mvindex(split('end',"-"),1)</eval>
</selection>

This code sets the $histogram.start$ token to the lower boundary of the first column inside the selection and $histogram.end$ to the upper one. Also works if there is no selection - defaults to the whole range.

I only wish it were documented better...

View solution in original post

0 Karma

puladamscom
Explorer

Alternatively, a neat little trick to avoid the <eval> thing is to avoid the dashes in the x-axis values in the first place. To do that, just change span=5 to span=5s. I know it seems strange but believe me it works - just do it and you will see!

0 Karma

arkadyz1
Builder

Well - we finally got some time to look closer into it, and found some way which is not documented for the <selection> tag but is used elsewhere: <eval> tag.

The code looks like this:

<selection>
          <eval token="histogram.start">mvindex(split('start',"-"),0)</eval>
          <eval token="histogram.end">mvindex(split('end',"-"),1)</eval>
</selection>

This code sets the $histogram.start$ token to the lower boundary of the first column inside the selection and $histogram.end$ to the upper one. Also works if there is no selection - defaults to the whole range.

I only wish it were documented better...

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...