Dashboards & Visualizations

How to set properties in a custom visualization in Javascript?

simpkins1958
Contributor

Trying to use sample code from http://dev.splunk.com/view/webframework-developapps/SP-CAAAESD to set these properties in a custom visualization:

      <viz type="leaflet_maps_app.leaflet_maps" id="clusterMapId">
....
           <option name="leaflet_maps_app.leaflet_maps.mapCenterLat">46.0</option>
            <option name="leaflet_maps_app.leaflet_maps.mapCenterLon">120.0</option>
            <option name="leaflet_maps_app.leaflet_maps.mapCenterZoom">6</option>

With this javascript and not working:

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {


    // Get the Events table
    var myClusterMap = mvc.Components.get('clusterMapId');

    // Programmatically change a property in the Events table
    myClusterMap.getVisualization(function(eventsView) {
        eventsView.settings.set("leaflet_maps_app.leaflet_maps.mapCenterLon", "-120");
    });     
});
0 Karma

zeinstein
Path Finder

You might check out the answer here: https://answers.splunk.com/answers/500008/how-to-add-custom-option-to-a-panel.html
The main point being: custom app's custom options are not working anymore like they did before. So you might need some workarounds.
I hope it helps somewhat.

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 ...