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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...