All Apps and Add-ons

Splunk Machine Learning Toolkit: How can I change visualization type programmatically in HTML converted dashboard?

chanfoli
Builder

Hello, I have a dashboard using some of the Visualizations from the Machine Learning Toolkit that I converted to HTML in order to do some interaction with the app's KV store. I would like to programatically change the visualization type under certain conditions.

Here is the div containing the viz:

 <div class="panel-element-row">
    <div id="element1" class="dashboard-element viz" style="width: 100%">
        <div class="panel-body"></div>
    </div>
 </div>

Here is the viz element in the JS:

var element1 = new VisualizationElement({
    "id": "element1",
    "type": "Splunk_ML_Toolkit.OutliersViz",
    "drilldown": "none",
    "trellis.enabled": "0",
    "resizable": true,
    "trellis.size": "medium",
    "trellis.scales.shared": "1",
    "refresh.display": "progressbar",
    "managerid": "search1",
    "el": $('#element1')
}, {tokens: true, tokenNamespace: "submitted"}).render();

If I try to set the type setting on element1 as follows it appears to change its assignment if I then get the type, but the visualization stays as an OutliersViz. I have tried calling render() and some other methods but none actually make it re-render as the desired type:

        else if (form_countTMethod == "TSF") {
            methodString = tsfSearch;
            element1.settings.set("type","Splunk_ML_Toolkit.ForecastViz");
            console.log("element type:",element1.settings.get("type"));
            element1.render();
        }
0 Karma
Get Updates on the Splunk Community!

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

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...