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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...