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 Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...