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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...