Dashboards & Visualizations

Can map visualizations' latitude, longitude, and zoom respond and adapt to the resultset returned, or on click of a button for a certain region??

hylam
Contributor

Can I have a USA button and a China button that moves and zooms the map?
Can the map move to China if the resultset shows China? Can the map move to USA if the resultset shows USA? Can the move and zoom include China, USA, and Pacific Ocean if the resultset shows both China and USA?

1 Solution

mporath_splunk
Splunk Employee
Splunk Employee

You can do all of that with the dashboard Link Switcher capabilities:

For manual country switching
- Create a form element with your countries
- Setup a link switcher like the one below

<form>
  <label>Test switcher</label>
  <fieldset submitButton="false">
    <input type="radio" token="country">
      <label>Country</label>
      <choice value="China">China</choice>
      <choice value="US">US</choice>
      <default>China</default>
      <change>
        <condition value="China">
          <set token="showChina">true</set>
          <unset token="showUs"></unset>
        </condition>
        <condition value="US">
          <unset token="showChina"></unset>
          <set token="showUs">true</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Current Country</title>
      <map depends="$showUs$">
        <title>$country$</title>
        <search>
          <query>lat lon | head 1000 | lookup geo_countries longitude AS lon, latitude AS lat | stats count by featureId | geom geo_countries</query>
        </search>
            <option name="mapping.map.center">(37.3,-81.65)</option>
            <option name="mapping.map.panning">true</option>
            <option name="mapping.map.scrollZoom">false</option>
            <option name="mapping.map.zoom">4</option>
            <option name="mapping.type">choropleth</option>
            <option name="drilldown">all</option>
      </map>
      <map depends="$showChina$">
        <title>$country$</title>
        <search>
          <query>lat lon | head 1000 | lookup geo_countries longitude AS lon, latitude AS lat | stats count by featureId | geom geo_countries</query>
          <earliest></earliest>
          <latest></latest>
        </search>
            <option name="mapping.map.center">(32.32,103.62)</option>
            <option name="mapping.map.panning">1</option>
            <option name="mapping.map.scrollZoom">0</option>
            <option name="mapping.map.zoom">4</option>
            <option name="mapping.type">choropleth</option>
      </map>
    </panel>
  </row>
</form>

For automatic country switching
Similar as above. Take a look at the "Null search swapper" example in the Splunk 6.x Dashboard Examples app to switch based on the search result

View solution in original post

mporath_splunk
Splunk Employee
Splunk Employee

You can do all of that with the dashboard Link Switcher capabilities:

For manual country switching
- Create a form element with your countries
- Setup a link switcher like the one below

<form>
  <label>Test switcher</label>
  <fieldset submitButton="false">
    <input type="radio" token="country">
      <label>Country</label>
      <choice value="China">China</choice>
      <choice value="US">US</choice>
      <default>China</default>
      <change>
        <condition value="China">
          <set token="showChina">true</set>
          <unset token="showUs"></unset>
        </condition>
        <condition value="US">
          <unset token="showChina"></unset>
          <set token="showUs">true</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Current Country</title>
      <map depends="$showUs$">
        <title>$country$</title>
        <search>
          <query>lat lon | head 1000 | lookup geo_countries longitude AS lon, latitude AS lat | stats count by featureId | geom geo_countries</query>
        </search>
            <option name="mapping.map.center">(37.3,-81.65)</option>
            <option name="mapping.map.panning">true</option>
            <option name="mapping.map.scrollZoom">false</option>
            <option name="mapping.map.zoom">4</option>
            <option name="mapping.type">choropleth</option>
            <option name="drilldown">all</option>
      </map>
      <map depends="$showChina$">
        <title>$country$</title>
        <search>
          <query>lat lon | head 1000 | lookup geo_countries longitude AS lon, latitude AS lat | stats count by featureId | geom geo_countries</query>
          <earliest></earliest>
          <latest></latest>
        </search>
            <option name="mapping.map.center">(32.32,103.62)</option>
            <option name="mapping.map.panning">1</option>
            <option name="mapping.map.scrollZoom">0</option>
            <option name="mapping.map.zoom">4</option>
            <option name="mapping.type">choropleth</option>
      </map>
    </panel>
  </row>
</form>

For automatic country switching
Similar as above. Take a look at the "Null search swapper" example in the Splunk 6.x Dashboard Examples app to switch based on the search result

hylam
Contributor

Can I compute the minimum bounding box dynamically from the resultset w/o hardcoding the coordinates and zoom of China and USA? My number of shapes way more than 2. I have custom maps and tile servers.

0 Karma

mporath_splunk
Splunk Employee
Splunk Employee

No, that's not possible right now

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...