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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...